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 and this method directly resolves and answers the main issue as stated in the title.
It is possible to pass the parameter using paramiko
, which is another pure python
implementation of SSH
. This is supported by ansible and would be the preferred option as it relies on less cross language dependancies that has to be separately managed; Thus this essentially by-passes the need for another library installed on your host machine : sshpass
.
instead of using the connection ssh as below :
$ansible-playbook -i hosts -v -b -c ssh --ask-pass myplaybook.yml
you can and will find it easier to use the following :
$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/
thanks for additional comments as mention, via the paramiko
way, you can also set it in your inventory file, or set it as a playbook option.