2017-03-16 682 views
4

Recenlty我在現有項目中創建了一個名爲spd的新角色,而其他腳本在設置中正常工作。我是怎麼回事錯在這裏要使用帶有密碼的'ssh'連接類型,必須安裝sshpass程序「

ansible/roles 
     spd 
     tasks 
     templates 
     defaults 

部署,spd.yml

- hosts: 
    roles: 
    - spd 

清單文件

[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 

失敗

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-%[email protected]%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-%[email protected]%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-%[email protected]%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'"'"'' 
+0

它與你的Ansible劇本沒有多大關係。 SSH工作正常嗎?你可以通過用戶'centos'的密鑰認證訪問目標嗎? – techraf

+0

@techraf我能夠在centos vm.and ansible -i盤點/庫存上執行ssh ping所有工作正常。 –

+0

@Chris_vr你有成功運行(.237)和失敗運行(.225-.227)的不同IP。請仔細檢查一下。 –

回答

1

問題是因爲使用屬性的在/defaults/main.yml ansible_password。我在這個文件中保留了大量的vairbales以供腳本和attaribute ansible_password一起使用。

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

此屬性ansible_password由ansible.Now保留使用我改變了變量名ansible_pass.Now它工作正常。

9

這是需要安裝sshpass程序的主機。對於像16.04這樣的Ubuntu機器,它就像apt-get install sshpass一樣簡單。再次,此錯誤消息:

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

適用於HOST(供應者)未(被供應機(S))的客人。因此在供應商上安裝sshpass

+0

對於CentOS/Red Hat:'sudo yum install -y http:// mirror.centos.org/centos/7/extras/x86_64/Packages/sshpass-1.06-2.el7.x86_64.rpm' –

相關問題