这种情况适用于 Linux Ansible 主控和 Windows 目标。
当我跑步时:
ansible all -vvv -u myuser -m ping --ask-pass
ansible -vvv 告诉我:
<aloysius> (1, b'', b'The system cannot find the path specified.\r\n')
<aloysius> Failed to connect to the host via ssh: The system cannot find the path specified.
我注意到它希望拥有:
ControlPath=/home/admin/.ansible/cp/5803c98fce
并且此目录“5803c98fce”在 ansible 主机上不存在。(至少在运行前后):
ansible all -vvv -u myuser -m ping --ask-pass
首先,ansible 是否说它的“ControlPath”在 Linux 主机上不存在?
ControlPath=/home/admin/.ansible/cp/5803c98fce
或者它是在谈论这个我认为应该在远程主机上(顺便说一下,虽然它是 Windows,但这个目录确实存在于远程主机上......):
echo ~/.ansible/tmp
我真的不知道这意味着什么,这可能会有所帮助:
(1, b'', b'The system cannot find the path specified.\r\n')
。
。
还要注意,在 win 目标上,我的正常运行的 ssh 用户实际上拥有 ~/.ansible/tmp==~.ansible\tmp 目录的所有权:
you may have been able to authenticate and did not have permissions on the target directory.
以下是完整的 -vvv 输出:
[barney@bigstack ~]$ ansible all -vvv -u myuser -m ping --ask-pass
ansible 2.9.13
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/admin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.6/site-packages/ansible
executable location = /usr/bin/ansible
python version = 3.6.8 (default, Apr 16 2020, 01:36:27) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
Using /etc/ansible/ansible.cfg as config file
SSH password:
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Parsed /etc/ansible/hosts inventory source with ini plugin
META: ran handlers
<aloysius> ESTABLISH SSH CONNECTION FOR USER: myuser
<aloysius> SSH: EXEC sshpass -d9 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'User="myuser"' -o ConnectTimeout=10 -o ControlPath=/home/admin/.ansible/cp/5803c98fce aloysius '/bin/sh -c '"'"'echo ~myuser && sleep 0'"'"''
<aloysius> (1, b'', b'The system cannot find the path specified.\r\n')
<aloysius> Failed to connect to the host via ssh: The system cannot find the path specified.
<aloysius> ESTABLISH SSH CONNECTION FOR USER: myuser
<aloysius> SSH: EXEC sshpass -d9 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'User="myuser"' -o ConnectTimeout=10 -o ControlPath=/home/admin/.ansible/cp/5803c98fce aloysius '/bin/sh -c '"'"'echo "`pwd`" && sleep 0'"'"''
<aloysius> (1, b'', b'The system cannot find the path specified.\r\n')
<aloysius> Failed to connect to the host via ssh: The system cannot find the path specified.
<aloysius> ESTABLISH SSH CONNECTION FOR USER: myuser
<aloysius> SSH: EXEC sshpass -d9 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'User="myuser"' -o ConnectTimeout=10 -o ControlPath=/home/admin/.ansible/cp/5803c98fce aloysius '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo ~/.ansible/tmp `"&& mkdir "` echo ~/.ansible/tmp/ansible-tmp-1603723134.4556515-646377-252845712428430 `" && echo ansible-tmp-1603723134.4556515-646377-252845712428430="` echo ~/.ansible/tmp/ansible-tmp-1603723134.4556515-646377-252845712428430 `" ) && sleep 0'"'"''
<aloysius> (1, b'', b'The system cannot find the path specified.\r\n')
<aloysius> Failed to connect to the host via ssh: The system cannot find the path specified.
aloysius | UNREACHABLE! => {
"changed": false,
"msg": "Failed to create temporary directory.In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\", for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p \"` echo ~/.ansible/tmp `\"&& mkdir \"` echo ~/.ansible/tmp/ansible-tmp-1603723134.4556515-646377-252845712428430 `\" && echo ansible-tmp-1603723134.4556515-646377-252845712428430=\"` echo ~/.ansible/tmp/ansible-tmp-1603723134.4556515-646377-252845712428430 `\" ), exited with result 1",
"unreachable": true
}
请帮忙,你是我们唯一的希望。
答案1
这平模块仅适用于 Linux 和 BSD 目标。对于 Windows 目标,请使用win_ping_模块。