Open MalfuncEddie opened 1 year ago
might be related to #395
Did some more testing test case playbook
- name: Testcase for synchronize
become: true
become_method: sudo
gather_facts: yes
hosts: 172.31.222.241
tasks:
- name: Synchronize
ansible.posix.synchronize:
src: /tmp/testfile
dest: /tmp/testfile
use_ssh_args: True
delegate_to: "172.31.222.101"
ansible.cfg
[defaults]
host_key_checking = False
ansible_ssh_common_args='-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'
timeout = 30
[ssh_connection]
ssh_args = -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
playbook command
ansible-playbook -i ,172.31.222.241,172.31.222.101 task.yml -k -K
SSH password:
BECOME password[defaults to SSH password]:
this works versions: ansible.posix: 1.4.0 ansible-playbook [core 2.12.5]
This does not work: ansible.posix: 1.5.1 ansible-playbook [core 2.12.5]
upgrade ansible versions
This does not work: ansible.posix: 1.5.1 ansible-playbook [core 2.14.2]
This does not work: ansible.posix: 1.4.0 ansible-playbook [core 2.14.2]
So I am not sure it is a problem with synchronize or with ansible-core. Will try to debug some more. I do not think that ansible-core deprecated some ansible.cfg settings. I also did a test with ansible-core 2.13.0 and 1.4.0 collection but also does not work.
I have a dirty patch that work in my specific case:
if delegate_to is None and remote_transport is False:
dest_is_local = True
elif delegate_to is not None and delegate_to in dest_host_ids:
dest_is_local = True
+ elif delegate_to in ("localhost", src_host):
+ dest_is_local = True
# CHECK FOR NON-DEFAULT SSH PORT
I'm quite sure there are better ways to check if delegate_to
is control node.
I think adding control node in dest_host_ids
may be the solution but I'm too new to ansible code base to be confidant about this.
EDIT : indent in code bloc
ansible version 2.12.10 / ansible.posix version 1.5.4
This also does not work from a playbook, but work from the command line (with localhost as the target).
- hosts: my_external_server
tasks:
- name: "Sync files from local computer to localhost"
synchronize:
mode: pull
src: mylocalcomputer:/path/to/dir
dest: /tmp/destination/
rsync_path: "sudo rsync"
rsync_opt:
- "--rsh='...'"
delegate_to: localhost
If I run without rsync_opt
the specific port of my_external_server is added to the --rsh
parameter.
And my_external_server is prepended to the source. Instead of connecting to mylocalcomputer from localhost, he try to connect to my_external_server and sync the folder my_external_server/mylocalcomputer:/path/to/dir
.
What I expect is that rsync is executed without modyfing the src or dest urls.
I tried different options, take a look at the source code, I am new to ansible and it's the first time I tried to use this task, I ended to use a shell
task for this.
I found old closed issue with the same problem.
SUMMARY
Synchronize version from release 1.5.1 does not work anymore it did work in 1.4.0
I do use the following settings in ansible.cfg (playbook is executed on new deployed servers so no host checking is needed
in version 1.5.1. ik looks like a prompt (allow yes/no) ssh prompt is given
snipit does the following. delegate to a server that has access to the new server en rsync some file from path1 to path 2.
ISSUE TYPE
COMPONENT NAME
Synchronize
ANSIBLE VERSION
COLLECTION VERSION
in version
OS / ENVIRONMENT
is in an execution environment
STEPS TO REPRODUCE
see above
EXPECTED RESULTS
ACTUAL RESULTS
synchronize hangs since it s waiting for an "allow host ssh prompt"
I'll try and debug more in the coming days