Open lucas-benedito opened 4 years ago
Hello! Thank you for the bug report. Using Ansible version 2.9.13 with the ansible.posix
collection version 1.1.1 I'm not able to reproduce this issue, is there any more information that you could provide that might help me reproduce this locally in order to fix the issue?
Hello, The issue is only reproducible in RHEL8 servers and the playbook was used as mentioned in the example, using the synchronize module existent in the installation. Also, the issue only happens when using ssh password but works successfully when using ssh-key.
@lucas-benedito Thank you for the feedback. Seems like there are a few variables at play
Does it fail on non RHEL8 machines with ssh password?
@gundalow from the tests performed I was only able to reproduce it in RHEL8.
Hi @lucas-benedito :) I have replicated a similar issue on the following test environment(2.9.11,2.9.27 and 2.12.0 on RHEL8.5):
Environment:
Control Node: server10 (RHEL8.5) ansible(2.9.11, 2.9.27 and 2.12.0), sshpass, rsync
Managed Node: server11 (RHEL8.5) rsync
Delegate To: server12 (RHEL8.5) rsync
Playbook(issue_89.yml):
---
- name: Sync between servers
hosts: issue_89
tasks:
- file:
path: /tmp/testdir
state: absent
- name: Transfering from between servers using delegate
synchronize:
src: /tmp/testdir
dest: /tmp
delegate_to: server12
Inventory File(inventory):
[issue_89]
server11
Error Message:
$ ansible-playbook -i inventory playbook/issue_89.yml -k -vvv
...snip...
The full traceback is:
File "/tmp/ansible_synchronize_payload_qob31y7j/ansible_synchronize_payload.zip/ansible/module_utils/basic.py", line 2588, in run_command
cmd = subprocess.Popen(args, **kwargs)
File "/usr/lib64/python3.6/subprocess.py", line 729, in __init__
restore_signals, start_new_session)
File "/usr/lib64/python3.6/subprocess.py", line 1364, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
fatal: [server11 -> server12]: FAILED! => {
"changed": false,
"cmd": "sshpass",
"invocation": {
"module_args": {
...snip...
}
},
"msg": "[Errno 2] No such file or directory: b'sshpass': b'sshpass'",
"rc": 2
}
Once I installed sshpass
to delegate_to
host server12
, it worked without errors. So if it is possible, can you re-confirm that sshpass package has already been installed to your delegatet_to host or not?
I can reproduce this on OSX running ansible.posix.synchronize
against a raspberry pi
uname -a
Darwin spuder.local 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 arm64
Using the fluiddpi image based on Rasbian
pi@fluiddpi:~ $cat /etc/issue
Raspbian GNU/Linux 10 \n \l
pi@fluiddpi:~ $ uname -a
Linux fluiddpi 5.10.103-v7+ #1529 SMP Tue Mar 8 12:21:37 GMT 2022 armv7l GNU/Linux
ansible [core 2.12.2]
config file = None
configured module search path = ['/Users/spencer.owen/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/5.3.0/libexec/lib/python3.10/site-packages/ansible
ansible collection location = /Users/spencer.owen/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.10.2 (main, Feb 2 2022, 05:51:25) [Clang 13.0.0 (clang-1300.0.29.3)]
jinja version = 3.0.3
libyaml = True
Playbook
- name: Update klipper config
hosts: ender2pro
remote_user: root
gather_facts: no
tasks:
- name: Synchronize macros folder
ansible.posix.synchronize:
src: macros/
dest: /home/pi/klipper_config/macros/
I am using ssh password auth with paramiko
ansible-playbook -i inventory playbook.yaml -c paramiko --ask-pass
Don't use password based authentication. Either install sshpass
or setup ssh keys with ssh-copy-id
I had the same problem (and workaround) - but is there a way to tell Ansible in the playbook to re-establish the ssh connection (without ask-pass) after the key has been written?
I also reproduced this issue against RHEL 7.6 as well.
I have the same issue on RHEL9
I'm trying to sync files from local to 2 others ( through ssh with key auth ) and it fails on both
part of playbook
- name: Synchronization using rsync protocol on delegate host (push)
ansible.posix.synchronize:
src: "/home/play/tmp/"
dest: "ssh://{{ mta_servers }}/tmp"
loop: "{{ groups['mta'] }}"
loop_control:
loop_var: mta_servers
run_once: true
register: sync_files
# delegate_to: local
TASK [local : Synchronization using rsync protocol on delegate host (push)] ************************************************************************************************************************************
task path: /home/play/ansible/roles/local/tasks/rsync_stuff.yml:20
<10.1.0.4> ESTABLISH LOCAL CONNECTION FOR USER: play
<10.1.0.4> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/play/.ansible/tmp/ansible-local-58642k_j57v48 `"&& mkdir "` echo /home/play/.ansible/tmp/ansible-local-58642k_j57v48/ansible-tmp-1677790164.8864932-59133-200124832178545 `" && echo ansible-tmp-1677790164.8864932-59133-200124832178545="` echo /home/play/.ansible/tmp/ansible-local-58642k_j57v48/ansible-tmp-1677790164.8864932-59133-200124832178545 `" ) && sleep 0'
Using module file /usr/lib/python3.9/site-packages/ansible_collections/ansible/posix/plugins/modules/synchronize.py
<10.1.0.4> PUT /home/play/.ansible/tmp/ansible-local-58642k_j57v48/tmpqg8o39ez TO /home/play/.ansible/tmp/ansible-local-58642k_j57v48/ansible-tmp-1677790164.8864932-59133-200124832178545/AnsiballZ_synchronize.py
<10.1.0.4> EXEC /bin/sh -c 'chmod u+x /home/play/.ansible/tmp/ansible-local-58642k_j57v48/ansible-tmp-1677790164.8864932-59133-200124832178545/ /home/play/.ansible/tmp/ansible-local-58642k_j57v48/ansible-tmp-1677790164.8864932-59133-200124832178545/AnsiballZ_synchronize.py && sleep 0'
<10.1.0.4> EXEC /bin/sh -c '/usr/bin/python3.9 /home/play/.ansible/tmp/ansible-local-58642k_j57v48/ansible-tmp-1677790164.8864932-59133-200124832178545/AnsiballZ_synchronize.py && sleep 0'
<10.1.0.4> EXEC /bin/sh -c 'rm -f -r /home/play/.ansible/tmp/ansible-local-58642k_j57v48/ansible-tmp-1677790164.8864932-59133-200124832178545/ > /dev/null 2>&1 && sleep 0'
failed: [10.1.0.4] (item=10.1.0.3) => {
"ansible_loop_var": "mta_servers",
"changed": false,
"cmd": "/usr/bin/rsync --delay-updates -F --compress --archive --rsh='/usr/bin/ssh -S none -i /home/play/.ssh/pwned -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' --out-format='<<CHANGED>>%i %n%L' /home/play/tmp/ root@10.1.0.4:ssh://10.1.0.3/tmp",
"invocation": {
"module_args": {
"_local_rsync_password": null,
"_local_rsync_path": "rsync",
"_substitute_controller": false,
"archive": true,
"checksum": false,
"compress": true,
"copy_links": false,
"delay_updates": true,
"delete": false,
"dest": "root@10.1.0.4:ssh://10.1.0.3/tmp",
"dest_port": null,
"dirs": false,
"existing_only": false,
"group": null,
"link_dest": null,
"links": null,
"mode": "push",
"owner": null,
"partial": false,
"perms": null,
"private_key": "/home/play/.ssh/pwned",
"recursive": null,
"rsync_opts": [],
"rsync_path": null,
"rsync_timeout": 0,
"set_remote_user": true,
"src": "/home/play/tmp/",
"ssh_args": null,
"ssh_connection_multiplexing": false,
"times": null,
"verify_host": false
}
},
"msg": "Warning: Permanently added '10.1.0.4' (ED25519) to the list of known hosts.\r\nrsync: [Receiver] mkdir \"/root/ssh://10.1.0.3/tmp\" failed: No such file or directory (2)\nrsync error: error in file IO (code 11) at main.c(783) [Receiver=3.2.3]\n",
"mta_servers": "10.1.0.3",
"rc": 11
}
SUMMARY
In Ansible 2.9.11 running on rhel 8, synchronize module fails to transfer with '[Errno 2] No such file or directory' in similar fashion as in #56629. All suggestions from the previous issue were followed and i was unable to solve it. The only way to avoid the issue is to use ssh-key based connection as it doesn't use sshpass.
ISSUE TYPE
COMPONENT NAME
synchronize
ANSIBLE VERSION
OS / ENVIRONMENT
Red Hat Enterprise Linux release 8.2 (Ootpa)
STEPS TO REPRODUCE
freshly installed RHEL 8 environment without any customization. mkdir /tmp/testdir ; echo 'Ansible Managed' >> /tmp/testdir/file-transfer
EXPECTED RESULTS
ACTUAL RESULTS