ansible sudo password code example
Example 1: Ansible playbook to set passwordless sudo
---
- hosts: all
tasks:
- lineinfile:
path: /etc/sudoers
state: present
regexp: '^%sudo'
line: '%sudo ALL=(ALL) NOPASSWD: ALL'
validate: 'visudo -cf %s'
Example 2: ansible sudo pass
ansible-playbook playbook.yml -i inventory.ini --extra-vars "ansible_sudo_pass=yourPassword"