ansible-collections / ansible.posix

Ansible Collection for Posix
Other
159 stars 153 forks source link

#361 breaks synchronize when paths contain `:` and `@` #591

Open flowerysong opened 1 week ago

flowerysong commented 1 week ago
SUMMARY

361 attempted to broaden the format of acceptable paths for the synchronize module beyond what was previously working, but it did so in a very broken way. : and @ are valid characters for a filename to contain.

ISSUE TYPE
COMPONENT NAME

synchronize

ANSIBLE VERSION
ansible [core 2.17.4]
  config file = /home/ec2-user/ansible-aws/ansible/ansible.cfg
  configured module search path = ['/home/ec2-user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ec2-user/ansible-aws/.venv/lib/python3.12/site-packages/ansible
  ansible collection location = /home/ec2-user/ansible-aws/ansible/collections
  executable location = /home/ec2-user/ansible-aws/.venv/bin/ansible
  python version = 3.12.1 (main, Feb 19 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/home/ec2-user/ansible-aws/.venv/bin/python)
  jinja version = 3.1.4
  libyaml = True
COLLECTION VERSION
Collection    Version
------------- -------
ansible.posix 1.6.2
CONFIGURATION
ANSIBLE_PIPELINING(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = True
COLLECTIONS_PATHS(env: ANSIBLE_COLLECTIONS_PATH) = ['/home/ec2-user/ansible-aws/ansible/collections']
CONFIG_FILE() = /home/ec2-user/ansible-aws/ansible/ansible.cfg
DEFAULT_ACTION_PLUGIN_PATH(env: ANSIBLE_ACTION_PLUGINS) = ['/home/ec2-user/ansible-aws/.venv/lib/python3.9/site-packages/ara/plugins/action', '/home/ec2-user/ansible-aws/.venv/lib/python3.12/site-packages/ara/plugins/action']
DEFAULT_BECOME(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = True
DEFAULT_BECOME_METHOD(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = sudo
DEFAULT_CALLBACK_PLUGIN_PATH(env: ANSIBLE_CALLBACK_PLUGINS) = ['/home/ec2-user/ansible-aws/.venv/lib/python3.9/site-packages/ara/plugins/callback', '/home/ec2-user/ansible-aws/.venv/lib/python3.12/site-packages/ara/plugins/callback']
DEFAULT_GATHERING(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = explicit
DEFAULT_HOST_LIST(env: ANSIBLE_INVENTORY) = ['/home/ec2-user/ansible-aws/ansible/inventory_nonprod']
DEFAULT_JINJA2_NATIVE(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = True
DEFAULT_LOAD_CALLBACK_PLUGINS(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = True
DEFAULT_LOOKUP_PLUGIN_PATH(env: ANSIBLE_LOOKUP_PLUGINS) = ['/home/ec2-user/ansible-aws/.venv/lib/python3.9/site-packages/ara/plugins/lookup', '/home/ec2-user/ansible-aws/.venv/lib/python3.12/site-packages/ara/plugins/lookup']
DEFAULT_REMOTE_USER(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = ec2-user
DEVEL_WARNING(env: ANSIBLE_DEVEL_WARNING) = False
EDITOR(env: EDITOR) = vim
HOST_KEY_CHECKING(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = False
INJECT_FACTS_AS_VARS(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = False
INTERPRETER_PYTHON(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = /usr/local/venv/system/bin/python3
INVENTORY_ENABLED(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = ['auto', 'yaml', 'ini']
RETRY_FILES_ENABLED(/home/ec2-user/ansible-aws/ansible/ansible.cfg) = False
OS / ENVIRONMENT
STEPS TO REPRODUCE
- hosts: Class_syslog
  vars:
    testfiles:
      - g:b
      - g:@b
  tasks:
    - ansible.builtin.file:
        dest: /var/tmp/{{ item }}
        state: touch
      loop: "{{ testfiles }}"

    - ansible.posix.synchronize:
        mode: pull
        src: /var/tmp/{{ item }}
        dest: /var/tmp/testfile
      loop: "{{ testfiles }}"
EXPECTED RESULTS

Synchronization of the valid file path that I provided, as was done in ansible.posix 1.5.4.

changed: [crimson-lengspider.syslog.x.mail.umich.edu] => (item=g:b) => 
    ansible_loop_var: item
    changed: true
    cmd: /bin/rsync --delay-updates -F --compress --archive --rsh='/bin/ssh -S none -o
        StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' --rsync-path='sudo -u
        root rsync' --out-format='<<CHANGED>>%i %n%L' ec2-user@crimson-lengspider.syslog.x.mail.umich.edu:/var/tmp/g:b
        /var/tmp/testfile
    item: g:b
    msg: |-
        >f+++++++++ g:b
    rc: 0
    stdout_lines:
    - '>f+++++++++ g:b'
changed: [crimson-lengspider.syslog.x.mail.umich.edu] => (item=g:@b) => 
    ansible_loop_var: item
    changed: true
    cmd: /bin/rsync --delay-updates -F --compress --archive --rsh='/bin/ssh -S none -o
        StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' --rsync-path='sudo -u
        root rsync' --out-format='<<CHANGED>>%i %n%L' ec2-user@crimson-lengspider.syslog.x.mail.umich.edu:/var/tmp/g:@b
        /var/tmp/testfile
    item: g:@b
    msg: |-
        >f+++++++++ g:@b
    rc: 0
    stdout_lines:
    - '>f+++++++++ g:@b'
ACTUAL RESULTS
TASK [ansible.posix.synchronize] ***********************************************
failed: [crimson-lengspider.syslog.x.mail.umich.edu] (item=g:b) => 
    ansible_loop_var: item
    changed: false
    cmd: /bin/rsync --delay-updates -F --compress --archive --rsh='/bin/ssh -S none -o
        StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' --rsync-path='sudo -u
        root rsync' --out-format='<<CHANGED>>%i %n%L' ec2-user@/var/tmp/g:b /var/tmp/testfile
    item: g:b
    msg: |-
        rsync: [sender] change_dir "/home/ec2-user/ec2-user@/var/tmp" failed: No such file or directory (2)
        rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1330) [sender=3.2.3]
    rc: 23
failed: [crimson-lengspider.syslog.x.mail.umich.edu] (item=g:@b) => 
    ansible_loop_var: item
    changed: false
    cmd: /bin/rsync --delay-updates -F --compress --archive --rsh='/bin/ssh -S none -o
        StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' --rsync-path='sudo -u
        root rsync' --out-format='<<CHANGED>>%i %n%L' /var/tmp/g:@b /var/tmp/testfile
    item: g:@b
    msg: |-
        rsync: [sender] link_stat "/var/tmp/g:@b" failed: No such file or directory (2)
        rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1330) [sender=3.2.3]
    rc: 23