我在使用 ansible 时遇到了一点问题。我在容器中运行它:
ansible 2.7.7
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0]
我想在一个主机(Packer)中创建一个工件,并将其发送到一组主机(Proxmox)中。工件创建没有问题,棘手的一点是上传。这是我的代码:
---
- name: Test
file:
path: /tmp/Test
state: touch
delegate_to: "{{ groups.Packer[0] }}"
tags:
- Proxmox
- touch
- name: Sending artifact on Proxmox machines
synchronize:
src: /tmp/template/Output-file1.mf
dest: /tmp/Output-file1.mf
delegate_to: "{{ groups.Packer[0] }}"
tags:
- Proxmox
- sync
第 1 个任务成功,在 Packer Host 上创建了测试文件,证明 SSH 连接可以正常运行。
问题出现在第二个任务上:
TASK [download : Sending artifact on Proxmox machines] *****************************************************************************************************************************************************************************************************
task path: /code/roles/download/tasks/main.yaml:12
Read vars_file './secrets.yaml'
Read vars_file './secrets.yaml'
<192.168.1.69> ESTABLISH SSH CONNECTION FOR USER: jerome
<192.168.1.69> SSH: EXEC sshpass -d14 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o User=jerome -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/0e5690fa3d 192.168.1.69 '/bin/sh -c '"'"'echo ~jerome && sleep 0'"'"''
<192.168.1.69> (0, b'/Users/jerome\n', b'OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 192.168.1.69 is address\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 = 3016\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
<192.168.1.69> ESTABLISH SSH CONNECTION FOR USER: jerome
<192.168.1.69> SSH: EXEC sshpass -d14 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o User=jerome -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/0e5690fa3d 192.168.1.69 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /Users/jerome/.ansible/tmp/ansible-tmp-1590246409.0440042-124922614268739 `" && echo ansible-tmp-1590246409.0440042-124922614268739="` echo /Users/jerome/.ansible/tmp/ansible-tmp-1590246409.0440042-124922614268739 `" ) && sleep 0'"'"''
<192.168.1.69> ESTABLISH SSH CONNECTION FOR USER: jerome
<192.168.1.69> SSH: EXEC sshpass -d14 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o User=jerome -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/0e5690fa3d 192.168.1.69 '/bin/sh -c '"'"'echo ~jerome && sleep 0'"'"''
<192.168.1.69> (0, b'ansible-tmp-1590246409.0440042-124922614268739=/Users/jerome/.ansible/tmp/ansible-tmp-1590246409.0440042-124922614268739\n', b'OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 192.168.1.69 is address\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 = 3016\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
<192.168.1.69> (0, b'/Users/jerome\n', b'OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 192.168.1.69 is address\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 = 3016\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
<192.168.1.69> ESTABLISH SSH CONNECTION FOR USER: jerome
<192.168.1.69> SSH: EXEC sshpass -d14 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o User=jerome -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/0e5690fa3d 192.168.1.69 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /Users/jerome/.ansible/tmp/ansible-tmp-1590246409.0874155-34347585212584 `" && echo ansible-tmp-1590246409.0874155-34347585212584="` echo /Users/jerome/.ansible/tmp/ansible-tmp-1590246409.0874155-34347585212584 `" ) && sleep 0'"'"''
<192.168.1.69> (0, b'ansible-tmp-1590246409.0874155-34347585212584=/Users/jerome/.ansible/tmp/ansible-tmp-1590246409.0874155-34347585212584\n', b'OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 192.168.1.69 is address\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 = 3016\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
Using module file /usr/lib/python3/dist-packages/ansible/modules/files/synchronize.py
Using module file /usr/lib/python3/dist-packages/ansible/modules/files/synchronize.py
<192.168.1.69> PUT /root/.ansible/tmp/ansible-local-2942lvy6sp_q/tmpcqvbocif TO /Users/jerome/.ansible/tmp/ansible-tmp-1590246409.0440042-124922614268739/AnsiballZ_synchronize.py
<192.168.1.69> PUT /root/.ansible/tmp/ansible-local-2942lvy6sp_q/tmppr419rda TO /Users/jerome/.ansible/tmp/ansible-tmp-1590246409.0874155-34347585212584/AnsiballZ_synchronize.py
<192.168.1.69> SSH: EXEC sshpass -d14 sftp -o BatchMode=no -b - -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o User=jerome -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/0e5690fa3d '[192.168.1.69]'
<192.168.1.69> SSH: EXEC sshpass -d14 sftp -o BatchMode=no -b - -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o User=jerome -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/0e5690fa3d '[192.168.1.69]'
<192.168.1.69> (0, b'sftp> put /root/.ansible/tmp/ansible-local-2942lvy6sp_q/tmppr419rda /Users/jerome/.ansible/tmp/ansible-tmp-1590246409.0874155-34347585212584/AnsiballZ_synchronize.py\n', b'OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 192.168.1.69 is address\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 = 3016\r\ndebug3: mux_client_request_session: session request sent\r\ndebug2: Remote version: 3\r\ndebug2: Server supports extension "[email protected]" revision 1\r\ndebug2: Server supports extension "[email protected]" revision 2\r\ndebug2: Server supports extension "[email protected]" revision 2\r\ndebug2: Server supports extension "[email protected]" revision 1\r\ndebug2: Server supports extension "[email protected]" revision 1\r\ndebug2: Unrecognised server extension "[email protected]"\r\ndebug3: Sent message fd 3 T:16 I:1\r\ndebug3: SSH_FXP_REALPATH . -> /Users/jerome size 0\r\ndebug3: Looking up /root/.ansible/tmp/ansible-local-2942lvy6sp_q/tmppr419rda\r\ndebug3: Sent message fd 3 T:17 I:2\r\ndebug3: Received stat reply T:101 I:2\r\ndebug1: Couldn\'t stat remote file: No such file or directory\r\ndebug3: Sent message SSH2_FXP_OPEN I:3 P:/Users/jerome/.ansible/tmp/ansible-tmp-1590246409.0874155-34347585212584/AnsiballZ_synchronize.py\r\ndebug3: Sent message SSH2_FXP_WRITE I:4 O:0 S:32768\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: In write loop, ack for 4 32768 bytes at 0\r\ndebug3: Sent message SSH2_FXP_WRITE I:5 O:32768 S:32768\r\ndebug3: Sent message SSH2_FXP_WRITE I:6 O:65536 S:10733\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: In write loop, ack for 5 32768 bytes at 32768\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: In write loop, ack for 6 10733 bytes at 65536\r\ndebug3: Sent message SSH2_FXP_CLOSE I:4\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
<192.168.1.69> (0, b'sftp> put /root/.ansible/tmp/ansible-local-2942lvy6sp_q/tmpcqvbocif /Users/jerome/.ansible/tmp/ansible-tmp-1590246409.0440042-124922614268739/AnsiballZ_synchronize.py\n', b'OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 192.168.1.69 is address\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 = 3016\r\ndebug3: mux_client_request_session: session request sent\r\ndebug2: Remote version: 3\r\ndebug2: Server supports extension "[email protected]" revision 1\r\ndebug2: Server supports extension "[email protected]" revision 2\r\ndebug2: Server supports extension "[email protected]" revision 2\r\ndebug2: Server supports extension "[email protected]" revision 1\r\ndebug2: Server supports extension "[email protected]" revision 1\r\ndebug2: Unrecognised server extension "[email protected]"\r\ndebug3: Sent message fd 3 T:16 I:1\r\ndebug3: SSH_FXP_REALPATH . -> /Users/jerome size 0\r\ndebug3: Looking up /root/.ansible/tmp/ansible-local-2942lvy6sp_q/tmpcqvbocif\r\ndebug3: Sent message fd 3 T:17 I:2\r\ndebug3: Received stat reply T:101 I:2\r\ndebug1: Couldn\'t stat remote file: No such file or directory\r\ndebug3: Sent message SSH2_FXP_OPEN I:3 P:/Users/jerome/.ansible/tmp/ansible-tmp-1590246409.0440042-124922614268739/AnsiballZ_synchronize.py\r\ndebug3: Sent message SSH2_FXP_WRITE I:4 O:0 S:32768\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: In write loop, ack for 4 32768 bytes at 0\r\ndebug3: Sent message SSH2_FXP_WRITE I:5 O:32768 S:32768\r\ndebug3: Sent message SSH2_FXP_WRITE I:6 O:65536 S:10735\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: In write loop, ack for 5 32768 bytes at 32768\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: In write loop, ack for 6 10735 bytes at 65536\r\ndebug3: Sent message SSH2_FXP_CLOSE I:4\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
<192.168.1.69> ESTABLISH SSH CONNECTION FOR USER: jerome
<192.168.1.69> ESTABLISH SSH CONNECTION FOR USER: jerome
<192.168.1.69> SSH: EXEC sshpass -d14 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o User=jerome -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/0e5690fa3d 192.168.1.69 '/bin/sh -c '"'"'chmod u+x /Users/jerome/.ansible/tmp/ansible-tmp-1590246409.0874155-34347585212584/ /Users/jerome/.ansible/tmp/ansible-tmp-1590246409.0874155-34347585212584/AnsiballZ_synchronize.py && sleep 0'"'"''
<192.168.1.69> SSH: EXEC sshpass -d14 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o User=jerome -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/0e5690fa3d 192.168.1.69 '/bin/sh -c '"'"'chmod u+x /Users/jerome/.ansible/tmp/ansible-tmp-1590246409.0440042-124922614268739/ /Users/jerome/.ansible/tmp/ansible-tmp-1590246409.0440042-124922614268739/AnsiballZ_synchronize.py && sleep 0'"'"''
<192.168.1.69> (0, b'', b'OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 192.168.1.69 is address\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 = 3016\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
<192.168.1.69> (0, b'', b'OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 192.168.1.69 is address\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 = 3016\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
<192.168.1.69> ESTABLISH SSH CONNECTION FOR USER: jerome
<192.168.1.69> ESTABLISH SSH CONNECTION FOR USER: jerome
<192.168.1.69> SSH: EXEC sshpass -d14 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o User=jerome -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/0e5690fa3d -tt 192.168.1.69 '/bin/sh -c '"'"'/usr/bin/python /Users/jerome/.ansible/tmp/ansible-tmp-1590246409.0440042-124922614268739/AnsiballZ_synchronize.py && sleep 0'"'"''
<192.168.1.69> SSH: EXEC sshpass -d14 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o User=jerome -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/0e5690fa3d -tt 192.168.1.69 '/bin/sh -c '"'"'/usr/bin/python /Users/jerome/.ansible/tmp/ansible-tmp-1590246409.0874155-34347585212584/AnsiballZ_synchronize.py && sleep 0'"'"''
<192.168.1.69> (255, b"\[email protected]'s password: ", b'OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 192.168.1.69 is address\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 = 3016\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Control master terminated unexpectedly\r\nShared connection to 192.168.1.69 closed.\r\n')
<192.168.1.69> (255, b"\[email protected]'s password: ", b'OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 192.168.1.69 is address\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 = 3016\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Control master terminated unexpectedly\r\nShared connection to 192.168.1.69 closed.\r\n')
fatal: [192.168.1.83]: UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 192.168.1.69 is address\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 = 3016\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Control master terminated unexpectedly\r\nShared connection to 192.168.1.69 closed.",
"unreachable": true
}
fatal: [192.168.1.1]: UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 192.168.1.69 is address\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 = 3016\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Control master terminated unexpectedly\r\nShared connection to 192.168.1.69 closed.",
"unreachable": true
}
这似乎是我的 ssh_config 文件的问题,但我不明白哪里出了问题