To use the 'ssh' connection type with passwords, you must install the sshpass program "

Recenlty I created new spd roles in my existing project. While another script works fine in customization. this new created failure. Please indicate to me what is wrong here.

ansible/roles spd tasks templates defaults 

deploy-spd.yml

  - hosts: roles: - spd 

inventory file

 [kube-master] kubernetes-master-1 ansible_host=10.20.0.225 ansible_user=centos ansible_become=true kubernetes-master-2 ansible_host=10.20.0.226 ansible_user=centos ansible_become=true kubernetes-master-3 ansible_host=10.20.0.227 ansible_user=centos ansible_become=true 

Renouncement

 bash-4.3# ansible-playbook -i inventory/inventory deploy-test-ms.yml --ask-vault-pass Vault password: PLAY [kube-master] ************************************************************* TASK [setup] ******************************************************************* Thursday 16 March 2017 13:32:05 +0000 (0:00:00.026) 0:00:00.026 ******** fatal: [kubernetes-master-1]: FAILED! => {"failed": true, "msg": "to use the 'ssh' connection type with passwords, you must install the sshpass program"} fatal: [kubernetes-master-2]: FAILED! => {"failed": true, "msg": "to use the 'ssh' connection type with passwords, you must install the sshpass program"} fatal: [kubernetes-master-3]: FAILED! => {"failed": true, "msg": "to use the 'ssh' connection type with passwords, you must install the sshpass program"} PLAY RECAP ********************************************************************* kubernetes-master-1 : ok=0 changed=0 unreachable=0 failed=1 kubernetes-master-2 : ok=0 changed=0 unreachable=0 failed=1 kubernetes-master-3 : ok=0 changed=0 unreachable=0 failed=1 

UPDATE:

 **With failed script** Using module file /usr/lib/python2.7/site-packages/ansible/modules/core/system/setup.py <10.20.0.227> ESTABLISH SSH CONNECTION FOR USER: centos Using module file /usr/lib/python2.7/site-packages/ansible/modules/core/system/setup.py Using module file /usr/lib/python2.7/site-packages/ansible/modules/core/system/setup.py Using module file /usr/lib/python2.7/site-packages/ansible/modules/core/system/setup.py <172.23.169.137> ESTABLISH SSH CONNECTION FOR USER: centos <10.20.0.225> ESTABLISH SSH CONNECTION FOR USER: centos <10.20.0.226> ESTABLISH SSH CONNECTION FOR USER: centos **With successfull script** Thursday 16 March 2017 14:03:49 +0000 (0:00:00.066) 0:00:00.066 ******** Using module file /usr/lib/python2.7/site-packages/ansible/modules/core/system/setup.py <10.20.0.237> ESTABLISH SSH CONNECTION FOR USER: centos <10.20.0.237> SSH: EXEC ssh -F ./ssh.cfg -o ControlMaster=auto -o ControlPersist=30m -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=centos -o ConnectTimeout=30 -o 'ControlPath=~/.ssh/ansible-% r@ %h:%p' 10.20.0.237 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1489673029.48-15997231643297 4 `" && echo ansible-tmp-1489673029.48-159972316432974="` echo $HOME/.ansible/tmp/ansible-tmp-1489673029.48-159972316432974 `" ) && sleep 0'"'"'' <10.20.0.237> PUT /tmp/tmpnHJPbc TO /home/centos/.ansible/tmp/ansible-tmp-1489673029.48-159972316432974/setup.py <10.20.0.237> SSH: EXEC scp -F ./ssh.cfg -o ControlMaster=auto -o ControlPersist=30m -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=centos -o ConnectTimeout=30 -o 'ControlPath=~/.ssh/ansible-% r@ %h:%p' /tmp/tmpnHJPbc '[10.20.0.237]:/home/centos/.ansible/tmp/ansible-tmp-1489673029.48-159972316432974/setup.py' <10.20.0.237> ESTABLISH SSH CONNECTION FOR USER: centos <10.20.0.237> SSH: EXEC ssh -F ./ssh.cfg -o ControlMaster=auto -o ControlPersist=30m -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=centos -o ConnectTimeout=30 -o 'ControlPath=~/.ssh/ansible-% r@ %h:%p' 10.20.0.237 '/bin/sh -c '"'"'chmod u+x /home/centos/.ansible/tmp/ansible-tmp-1489673029.48-159972316432974/ /home/cento s/.ansible/tmp/ansible-tmp-1489673029.48-159972316432974/setup.py && sleep 0'"'"'' 
+24
source share
3 answers

The problem was due to the use of the ansible_password attribute in /defaults/main.yml . In this file I saved a lot of variables that will be used by the script along with the ansible_password attribute.

 - include_vars: "{{ role_path}}/defaults/main.yml" 

The ansible_password attribute ansible_password reserved for use by Ansible. Now I changed the variable name to ansible_pass and it works fine.

+6
source

This is the host machine that requires the installed sshpass program. For a Ubuntu machine like 16.04, it's as simple as apt-get install sshpass . Again, this error message:

ERROR! To use the 'ssh' connection type with passwords, you need to install the sshpass program

Applies to HOST (initiator), not GUEST (machines). Therefore, install sshpass on the provider.

To install sshpass on Mac OS, refer to this link

+32
source

Just to add to the various answers above, although this answers the main question, as indicated in the header. You can pass a parameter using paramiko, which is another python SSH implementation. This is supported by ansible. This ignores the need to install another library on the host: sshpass.

instead of using an SSH connection as shown 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/

+8
source

Source: https://habr.com/ru/post/1265553/


All Articles