Is it possible to specify Ansible playbook password in Linux command line? Say my username is foo and password is bar. How do I set password for Ansible playbook in CLI?
The syntax is as follows to provide sudo password at CLI
ansible-playbook -i hosts_file my.yml \ --extra-vars 'ansible_become_pass=YOUR-PASSWORD-HERE'
For security reasons use the following syntxa
ansible-playbook --ask-become-pass -i hosts playbook.yml
Here is how to give ssh user and password at the CLI
ansible-playbook -i hosts playbook.yml \ --extra-vars 'ansible_ssh_pass=YOUR-SSH-PASSWORD-HERE' \ --extra-vars='ansible_ssh_user=YOUR-SSH-USERNAME-HERE'
See for more info