1. 程式人生 > >ansible報錯記錄

ansible報錯記錄

管理機 get inter -m search usr 就會 bject exc

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

ansible報錯記錄