If you need to use password-based authentication in order to connect to the nodes, you need to append the option ansible_become_pass to your Ansible command.
Here's how you can do it:
1. Open your Ansible inventory file (inventory.ini) or create one if it doesn't exist.
2. Add the target hosts to the inventory file. For example:
[web_servers]
web1 ansible_host=192.168.1.10
web2 ansible_host=192.168.1.11
3. Create a playbook file (e.g., playbook.yml) and define your tasks and hosts.
4. Specify the ansible_become_pass variable in the playbook file to provide the sudo password. For example:
---
- name: Example Playbook
hosts: web_servers
become: yes
become_user: root
vars:
ansible_become_pass: your_sudo_password
tasks:
- name: Your task name
...
Replace your_sudo_password with the actual sudo password you want to use.
5. Save the playbook file and run the Ansible command to execute it. For example:
ansible-playbook -i inventory.ini playbook.yml
Ansible will use the specified sudo password (ansible_become_pass) when executing tasks that require elevated privileges on the target hosts.
Comments (0)