config-add-sshkey.yaml 477 B

1234567891011121314151617
  1. ---
  2. - name: add ssh key
  3. hosts: "{{ my_hosts | d([]) }}"
  4. become: yes
  5. tasks:
  6. - name: install public keys
  7. ansible.posix.authorized_key:
  8. user: "{{ lookup('env','USER') }}"
  9. state: present
  10. key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
  11. - name: change sudoers file
  12. ansible.builtin.lineinfile:
  13. path: /etc/sudoers
  14. state: present
  15. regexp: '^%sudo'
  16. line: '%sudo ALL=(ALL) NOPASSWD: ALL'
  17. validate: /usr/sbin/visudo -cf %s