Ansible: To use the 'ssh' connection type with passwords, you must install the sshpass program"
It is the host machine which needs the sshpass
program installed. For an Ubuntu machine such as 16.04, it's as simple as apt-get install sshpass
. Again, this error message of:
ERROR! to use the 'ssh' connection type with passwords, you must install the sshpass program
Applies to the HOST (provisioner) not the GUEST (machine(s) being provisioned). Thus install sshpass
on the provisioner.
For installing sshpass on Mac OS refer to this link
Just to add to various answers above although this answers the main question as stated in the title. It is possible to pass the parameter using paramiko, which is another python implementation of SSH. This is supported by ansible. This by-passes the need for another library installed on host : sshpass.
instead of using the connection ssh like below,
$ansible-playbook -i hosts -v -b -c ssh --ask-pass myplaybook.yml
you can use
$ansible-playbook -i hosts -v -b -c paramiko --ask-pass myplaybook.yml
if you are interested, you can read more here: http://www.paramiko.org/
The issue was because of use of attribute ansible_password in /defaults/main.yml
. I have maintained lots of variables in this file to be used by script along with attribute ansible_password.
- include_vars: "{{ role_path}}/defaults/main.yml"
The attribute ansible_password
is reserved for use by Ansible. Now I changed the variable name to ansible_pass
and it is working fine.