我有很多主机由ansible管理 并且在一个主机设置模块上失败:
user@Work:~ >> ansible -vvvv -i "10.10.10.2," all -m setup [20:00:24]
Using /etc/ansible/ansible.cfg as config file
Loaded callback minimal of type stdout, v2.0
<10.10.10.2> ESTABLISH SSH CONNECTION FOR USER: None
<10.10.10.2> SSH: EXEC ssh -C -vvv -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=/home/user/.ansible/cp/ansible-ssh-%h-%p-%r -tt 10.10.10.2 '/bin/sh -c '"'"'( umask 22 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1464541230.33-190582391613085 `" && echo "` echo $HOME/.ansible/tmp/ansible-tmp-1464541230.33-190582391613085 `" )'"'"''
<10.10.10.2> PUT /tmp/tmpefUyS_ TO /home/user/.ansible/tmp/ansible-tmp-1464541230.33-190582391613085/setup
<10.10.10.2> SSH: EXEC sftp -b - -C -vvv -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=/home/user/.ansible/cp/ansible-ssh-%h-%p-%r '[10.10.10.2]'
<10.10.10.2> ESTABLISH SSH CONNECTION FOR USER: None
<10.10.10.2> SSH: EXEC ssh -C -vvv -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=/home/user/.ansible/cp/ansible-ssh-%h-%p-%r -tt 10.10.10.2 '/bin/sh -c '"'"'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /home/user/.ansible/tmp/ansible-tmp-1464541230.33-190582391613085/setup; rm -rf "/home/user/.ansible/tmp/ansible-tmp-1464541230.33-190582391613085/" > /dev/null 2>&1'"'"''
10.10.10.2 | FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_name": "setup"
},
"module_stderr": "OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014\r\ndebug1: Reading configuration data /home/user/.ssh/config\r\ndebug1: /home/user/.ssh/config line 1: Applying options for *\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 2079\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 10.10.10.2 closed.\r\n",
"module_stdout": "Traceback (most recent call last):\r\n File \"/home/user/.ansible/tmp/ansible-tmp-1464541230.33-190582391613085/setup\", line 5184, in <module>\r\n main()\r\n File \"/home/user/.ansible/tmp/ansible-tmp-1464541230.33-190582391613085/setup\", line 140, in main\r\n data = run_setup(module)\r\n File \"/home/user/.ansible/tmp/ansible-tmp-1464541230.33-190582391613085/setup\", line 84, in run_setup\r\n facts = ansible_facts(module)\r\n File \"/home/user/.ansible/tmp/ansible-tmp-1464541230.33-190582391613085/setup\", line 5119, in ansible_facts\r\n facts.update(Facts().populate())\r\n File \"/home/user/.ansible/tmp/ansible-tmp-1464541230.33-190582391613085/setup\", line 2259, in __init__\r\n self.get_platform_facts()\r\n File \"/home/user/.ansible/tmp/ansible-tmp-1464541230.33-190582391613085/setup\", line 2305, in get_platform_facts\r\n self.get_distribution_facts()\r\n File \"/home/user/.ansible/tmp/ansible-tmp-1464541230.33-190582391613085/setup\", line 2459, in get_distribution_facts\r\n if 'Red Hat' in data:\r\nTypeError: argument of type 'NoneType' is not iterable\r\n",
"msg": "MODULE FAILURE",
"parsed": false
}
系统:
Linux host-01 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linu
在同一个邻居主机上一切正常
格式化后的"module_stdout"
回溯如下所示:
Traceback (most recent call last):
File "/home/user/.ansible/tmp/.../setup", line 5184, in <module>
main()
File "/home/user/.ansible/tmp/.../setup", line 140, in main
data = run_setup(module)
File "/home/user/.ansible/tmp/.../setup", line 84, in run_setup
facts = ansible_facts(module)
File "/home/user/.ansible/tmp/.../setup", line 5119, in ansible_facts
facts.update(Facts().populate())
File "/home/user/.ansible/tmp/.../setup", line 2259, in __init__
self.get_platform_facts()
File "/home/user/.ansible/tmp/.../setup", line 2305, in get_platform_facts
self.get_distribution_facts()
File "/home/user/.ansible/tmp/.../setup", line 2459, in get_distribution_facts
if 'Red Hat' in data:
TypeError: argument of type 'NoneType' is not iterable
upd:它使用-become param,但有一件奇怪的事情:
user@host:~ >> ansible -vvvv -i "10.10.10.2," all -m setup -become | grep -i distr
"ansible_distribution": "RedHat",
"ansible_distribution_major_version": "14",
"ansible_distribution_release": "trusty",
"ansible_distribution_version": "14.04",
"facter_lsbdistrelease": "14.04",
"facter_lsbmajdistrelease": "14",
ansible_distribution:RedHat,但它是Ubuntu 14.04.4
答案 0 :(得分:0)
它与-become param合作:ansible -i“10.10.10.2,”all -m'setup'-become
但是在另一台主机上它没有这个参数
答案 1 :(得分:0)
我遇到了同样的问题,将ansible.cfg中的scp_if_ssh从smart更改为True