ansible

Log | Files | Refs | README

main.yml (842B)


      1 ---
      2 - name: Create user cjr
      3   user:
      4     name: cjr
      5     shell: /bin/bash
      6     groups:
      7       - sudo
      8       - docker
      9     append: true
     10     password: "{{ cjr_password }}"
     11     state: present
     12 
     13 - name: Add SSH key for cjr
     14   authorized_key:
     15     user: cjr
     16     key: "{{ lookup('file', '~/.ssh/id_ed25519_learningunix_t15.pub') }}"
     17     state: present
     18 
     19 
     20 - name: Allow sudo with password
     21   lineinfile:
     22     path: /etc/sudoers.d/cjr
     23     line: "cjr ALL=(ALL) ALL"
     24     create: true
     25     validate: 'visudo -cf %s'
     26 
     27 - name: Disable password authentication
     28   lineinfile:
     29     path: /etc/ssh/sshd_config
     30     regexp: '^#?PasswordAuthentication'
     31     line: 'PasswordAuthentication no'
     32   notify: restart sshd
     33 
     34 - name: Disable root SSH login
     35   lineinfile:
     36     path: /etc/ssh/sshd_config
     37     regexp: '^#?PermitRootLogin'
     38     line: 'PermitRootLogin no'
     39   notify: restart sshd