playbook.yaml.j2 719 B

12345678910111213141516171819202122232425262728
  1. ---
  2. - name: {{ playbook_name }}
  3. hosts: {{ target_hosts }}
  4. {% if become %}
  5. become: true
  6. {% endif %}
  7. {% if options_enabled and not gather_facts %}
  8. gather_facts: false
  9. {% endif %}
  10. {% if secrets_enabled %}
  11. vars_files:
  12. - {{ secrets_file }}
  13. {% endif %}
  14. tasks:
  15. - name: Install public keys
  16. ansible.posix.authorized_key:
  17. user: {{ '{{' }} lookup('env', 'USER') {{ '}}' }}
  18. state: present
  19. key: {{ '{{' }} lookup('file', '~/.ssh/id_rsa.pub') {{ '}}' }}
  20. - name: Change sudoers file
  21. ansible.builtin.lineinfile:
  22. path: /etc/sudoers
  23. state: present
  24. regexp: '^%sudo'
  25. line: '%sudo ALL=(ALL) NOPASSWD: ALL'
  26. validate: /usr/sbin/visudo -cf %s