I've looked around but couldn't find a proper solution, I want to run playbook for multiple users on multiple hosts and my roles use the user specific info such as name, email, id ... Now instead of running the playbook for each user I wrote a python script that invokes the ansible
ansible-playbook -i hosts --ask-become-pass --ask-pass ./playbooks/myplaybook.yml
But for the above command to work I want to pass SSH password and SUDO password as arguments to the command. I checked ansible-playbook documentation but was unable to find it. What would be the best way to achieve this?
Providing the sudo Password If the remote user needs to provide a password in order to run sudo commands, you can include the option --ask-become-pass to your Ansible command. This will prompt you to provide the remote user sudo password: ansible all -m ping --ask-become-pass.
To specify a password for sudo, run ansible-playbook with --ask-become-pass ( -K for short). If you run a playbook utilizing become and the playbook seems to hang, most likely it is stuck at the privilege escalation prompt. Stop it with CTRL-c , then execute the playbook with -K and the appropriate password.
You can specify the following parameters from the command line:
… -e "ansible_user=username ansible_ssh_pass=xxx ansible_sudo_pass=xxx" …
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With