ansible.posix
ansible.posix copied to clipboard
remote location is corrupted when using rsync SSH formatted paths
SUMMARY
The 'dest' module parameter appears corrupted when mode is set to 'push' and 'dest' is defined as [email protected]:/tmp/bar
the destination path is a prepended with an extraneous local hostname:
inventory_hostname:[email protected]:/tmp/bar
Similar corruption happens to the 'src' path if the mode is set to 'pull'
ISSUE TYPE
- Bug Report
COMPONENT NAME
synchronize
ANSIBLE VERSION
ansible 2.9.6
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/vg/.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.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0]
COLLECTION VERSION
{
"collection_info": {
"namespace": "ansible",
"name": "posix",
"version": "1.3.0",
"authors": [
"Ansible (github.com/ansible)"
],
"readme": "README.md",
"tags": [
"posix",
"networking",
"shell",
"unix"
],
"description": "Ansible Collection targeting POSIX and POSIX-ish platforms.",
"license": [],
"license_file": "COPYING",
"dependencies": {},
"repository": "https://github.com/ansible-collections/ansible.posix",
"documentation": "https://github.com/ansible-collections/ansible.posix/tree/main/docs",
"homepage": "https://github.com/ansible-collections/ansible.posix",
"issues": "https://github.com/ansible-collections/ansible.posix"
},
"file_manifest_file": {
"name": "FILES.json",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "c962387fb94e411365b7399db84920d7241ad5b2d8ce5688ede397e781c3e3f4",
"format": 1
},
"format": 1
}
CONFIGURATION
DEFAULT_CALLBACK_WHITELIST(/etc/ansible/ansible.cfg) = ['ansible.posix.profile_tasks']
DEFAULT_STDOUT_CALLBACK(/etc/ansible/ansible.cfg) = yaml
OS / ENVIRONMENT
linux, aix,
STEPS TO REPRODUCE
execute the playbook pasted below
ansible-playbook -v -l 192.168.123.123 foo.yml
---
- name: foo book
hosts: all
gather_facts: no
become: false
tasks:
- name: Synchronization of src on the control machine to dest on the remote hosts
ansible.posix.synchronize:
src: /tmp/foo
dest: [email protected]:/tmp/bar
EXPECTED RESULTS
when using rsync "ssh transport" formatted paths, preserve dest and src parameters as defined in the playbook, without adding local hostname: in front
ACTUAL RESULTS
the module.params['dest'] is modified somewhere outside of the synchronize.py module. the 'dest' is modified when the mode is 'push'. likewise the 'src' parameter is modified when the mode is 'pull'.
PLAY [foo book] ***************************************************************************************************
TASK [Synchronization of src on the control machine to dest on the remote hosts] **********************************
Friday 13 May 2022 19:40:11 -0400 (0:00:00.012) 0:00:00.012 ************
fatal: [192.168.123.123]: FAILED! => changed=false
cmd: /usr/bin/rsync --delay-updates -F --compress --archive --rsh='/usr/bin/ssh -S none -o StrictHostKeyChecking=
L' /tmp/foo 192.168.123.123:[email protected]:/tmp/bar
msg: |-
Warning: Permanently added '192.168.123.123' (ECDSA) to the list of known hosts.
rsync: link_stat "/tmp/foo" failed: No such file or directory (2)
rsync: change_dir#3 "/home/vg//[email protected]:/tmp" failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(713) [Receiver=3.1.2]
rc: 3
PLAY RECAP ********************************************************************************************************
192.168.123.123 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
Friday 13 May 2022 19:40:12 -0400 (0:00:00.764) 0:00:00.776 ************
===============================================================================
Synchronization of src on the control machine to dest on the remote hosts -----------------------------------------
to me this appears to be the culprit: https://github.com/ansible-collections/ansible.posix/blob/6d5145e285ee5b511586be89a6898fe27e042537/plugins/action/synchronize.py#L71-L72
would if ':' in path:
work better instead to keep all remote paths intact, not just the rsync:// ?