ansible报错:
The full traceback is:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/ansible-2.5.4-py2.7.egg/ansible/executor/task_executor.py", line 138, in run
res = self._execute()
File "/usr/lib/python2.7/site-packages/ansible-2.5.4-py2.7.egg/ansible/executor/task_executor.py", line 519, in _execute
self._connection = self._get_connection(variables=variables, templar=templar)
File "/usr/lib/python2.7/site-packages/ansible-2.5.4-py2.7.egg/ansible/executor/task_executor.py", line 788, in _get_connection
connection = self._shared_loader_obj.connection_loader.get(conn_type, self._play_context, self._new_stdin, ansible_playbook_pid=to_text(os.getppid()))
File "/usr/lib/python2.7/site-packages/ansible-2.5.4-py2.7.egg/ansible/plugins/loader.py", line 366, in get
self._module_cache[path] = self._load_module_source(name, path)
File "/usr/lib/python2.7/site-packages/ansible-2.5.4-py2.7.egg/ansible/plugins/loader.py", line 345, in _load_module_source
module = imp.load_source(full_name, path, module_file)
File "/usr/lib/python2.7/site-packages/ansible-2.5.4-py2.7.egg/ansible/plugins/connection/paramiko_ssh.py", line 163, in <module>
import paramiko
File "build/bdist.linux-x86_64/egg/paramiko/__init__.py", line 22, in <module>
File "build/bdist.linux-x86_64/egg/paramiko/transport.py", line 38, in <module>
File "build/bdist.linux-x86_64/egg/paramiko/auth_handler.py", line 48, in <module>
File "build/bdist.linux-x86_64/egg/paramiko/ssh_gss.py", line 54, in <module>
AttributeError: ‘module‘ object has no attribute ‘GSSException‘
10.0.3.174 | FAILED! => {
"msg": "Unexpected failure during module execution.",
"stdout": ""
}
分析:说到这块就得说下ansible的通信过程,请看下面的一堆详细信息:
ansible 2.5.4
config file = /etc/ansible/ansible.cfg
configured module search path = [u‘/root/.ansible/plugins/modules‘, u‘/usr/share/ansible/plugins/modules‘]
ansible python module location = /usr/lib/python2.7/site-packages/ansible-2.5.4-py2.7.egg/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Apr 11 2018, 07:36:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
Using /etc/ansible/ansible.cfg as config file
Parsed /etc/ansible/hosts inventory source with ini plugin
META: ran handlers
Using module file /usr/lib/python2.7/site-packages/ansible-2.5.4-py2.7.egg/ansible/modules/commands/command.py
<10.0.3.174> ESTABLISH SSH CONNECTION FOR USER: None
<10.0.3.174> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/8f5e18b19f 10.0.3.174 ‘/bin/sh -c ‘"‘"‘echo ~ && sleep 0‘"‘"‘‘
<10.0.3.174> (0, ‘/root\n‘, ‘‘)
<10.0.3.174> ESTABLISH SSH CONNECTION FOR USER: None
<10.0.3.174> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/8f5e18b19f 10.0.3.174 ‘/bin/sh -c ‘"‘"‘( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1529054341.66-117835313708439 `" && echo ansible-tmp-1529054341.66-117835313708439="` echo /root/.ansible/tmp/ansible-tmp-1529054341.66-117835313708439 `" ) && sleep 0‘"‘"‘‘
<10.0.3.174> (0, ‘ansible-tmp-1529054341.66-117835313708439=/root/.ansible/tmp/ansible-tmp-1529054341.66-117835313708439\n‘, ‘‘)
<10.0.3.174> PUT /root/.ansible/tmp/ansible-local-60730UkDx3J/tmpLwKjow TO /root/.ansible/tmp/ansible-tmp-1529054341.66-117835313708439/command.py
<10.0.3.174> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/8f5e18b19f ‘[10.0.3.174]‘
<10.0.3.174> (0, ‘sftp> put /root/.ansible/tmp/ansible-local-60730UkDx3J/tmpLwKjow /root/.ansible/tmp/ansible-tmp-1529054341.66-117835313708439/command.py\n‘, ‘‘)
<10.0.3.174> ESTABLISH SSH CONNECTION FOR USER: None
<10.0.3.174> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/8f5e18b19f 10.0.3.174 ‘/bin/sh -c ‘"‘"‘chmod u+x /root/.ansible/tmp/ansible-tmp-1529054341.66-117835313708439/ /root/.ansible/tmp/ansible-tmp-1529054341.66-117835313708439/command.py && sleep 0‘"‘"‘‘
<10.0.3.174> (0, ‘‘, ‘‘)
<10.0.3.174> ESTABLISH SSH CONNECTION FOR USER: None
<10.0.3.174> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/8f5e18b19f -tt 10.0.3.174 ‘/bin/sh -c ‘"‘"‘/usr/bin/python /root/.ansible/tmp/ansible-tmp-1529054341.66-117835313708439/command.py && sleep 0‘"‘"‘‘
<10.0.3.174> (0, ‘\r\n{"changed": true, "end": "2018-06-15 17:19:02.268596", "stdout": "123\\nansible-2.5.4\\nansible-2.5.4.tar.gz\\nansible.sh\\ncommand.py", "cmd": ["ls"], "rc": 0, "start": "2018-06-15 17:19:02.265698", "stderr": "", "delta": "0:00:00.002898", "invocation": {"module_args": {"warn": true, "executable": null, "chdir": "/data", "_raw_params": "ls", "removes": null, "creates": null, "_uses_shell": false, "stdin": null}}}\r\n‘, ‘Shared connection to 10.0.3.174 closed.\r\n‘)
<10.0.3.174> ESTABLISH SSH CONNECTION FOR USER: None
<10.0.3.174> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/8f5e18b19f 10.0.3.174 ‘/bin/sh -c ‘"‘"‘rm -f -r /root/.ansible/tmp/ansible-tmp-1529054341.66-117835313708439/ > /dev/null 2>&1 && sleep 0‘"‘"‘‘
<10.0.3.174> (0, ‘‘, ‘‘)
10.0.3.174 | SUCCESS | rc=0 >>
123
ansible-2.5.4
ansible-2.5.4.tar.gz
ansible.sh
command.py
META: ran handlers
META: ran handlers
大概意思是:使用ssh测试以下是否能够正常连接,要是可以的话就继续,不可以的话就直接报错了。之后,会用ssh命令在你指定的主机的/root/.ansible/tmp/这个下面穿件一堆临时目录并且从你的ansible的管理机的上面按照你的需求呢生成一个.py的文件(这块怎么生 成的不太清楚反正和各种模块有关系,得看源码但我看不懂。。。)之后就会把这个.py的文件下发到你指定的主机上,怎么下发呢?(要是不相信你可以写一个shell脚本把这个.py文件抓出来看下里面的代码)
就是用sftp或者scp(这个可以在配置文件中指定)传过去到/root/.ansible/tmp/这个下面的临时目录中,之后用ssh远程执行命令/usr/bin/python .py文件,执行完成后再把所有的临时目录和.py文件删除,这个ansible的管理过程就执行完成了。
解决上面的报错:yum -y install openssh-clients
原文地址:https://www.cnblogs.com/tugeboke/p/9188475.html