ansible-collections / ansible.posix

Ansible Collection for Posix
Other
158 stars 153 forks source link

synchronize can't handle paths with spaces in them #305

Open azhelev opened 2 years ago

azhelev commented 2 years ago
SUMMARY

synchronize can't handle paths with spaces in them

ISSUE TYPE
COMPONENT NAME

synchronize

ANSIBLE VERSION
ansible [core 2.12.1]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/var/lib/jenkins/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /var/lib/jenkins/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0]
  jinja version = 2.10.1
  libyaml = True
COLLECTION VERSION
$ ansible-galaxy collection list ansible.posix

# /usr/lib/python3/dist-packages/ansible_collections
Collection    Version
------------- -------
ansible.posix 1.3.0
CONFIGURATION
$ ansible-config dump --only-changed
DEFAULT_STDOUT_CALLBACK(/etc/ansible/ansible.cfg) = yaml
OS / ENVIRONMENT

Ubuntu 20.04 ansible installed from ppa:ansible/ansible

$ dpkg -l | grep ansible
ii  ansible                            5.1.0-1ppa~focal                                                   all          batteries-included package providing a curated set of Ansible collections in addition to ansible-core
ii  ansible-core                       2.12.1-1ppa~focal                                                  all          Ansible IT Automation
STEPS TO REPRODUCE
- hosts: tag_Type_webserver
  become: yes
  vars:
    ansible_python_interpreter: '/usr/bin/python3'
    ansible_ssh_common_args: '-o StrictHostKeyChecking=no'
  remote_user: jenkins
  tasks:
    - name: Transfer files to instances
      synchronize:
        src: "/tmp/dir with spaces"
        dest: "/var/www/webapp/releases/build-test/"
        links: yes
        perms: yes
        recursive: yes
        times: yes
        rsync_opts:
          - --chown=www-data:www-data
          - --exclude=.git
          - --exclude=node_modules
EXPECTED RESULTS

It works

ACTUAL RESULTS
$ ansible-playbook -i aws_ec2.yml test.yml

PLAY [tag_Type_webserver] *************************************************************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************************************************
ok: [ec2-3-122-238-188.eu-central-1.compute.amazonaws.com]

TASK [Transfer files to instances] ****************************************************************************************************************************************
fatal: [ec2-3-122-238-188.eu-central-1.compute.amazonaws.com]: FAILED! => changed=false 
  cmd: /usr/bin/rsync --delay-updates -F --compress --archive --rsh='/usr/bin/ssh -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' --rsync-path='sudo -u root rsync' --chown=www-data:www-data --exclude=.git --exclude=node_modules --out-format='<<CHANGED>>%i %n%L' /tmp/dir with spaces jenkins@ec2-3-122-238-188.eu-central-1.compute.amazonaws.com:/var/www/webapp/releases/build-test/
  msg: |-
    Warning: Permanently added 'ec2-3-122-238-188.eu-central-1.compute.amazonaws.com,3.122.238.188' (ECDSA) to the list of known hosts.
    rsync: link_stat "/tmp/dir" failed: No such file or directory (2)
    rsync: link_stat "/var/lib/jenkins/.local/ansible/searchie-dev-eu/with" failed: No such file or directory (2)
    rsync: link_stat "/var/lib/jenkins/.local/ansible/searchie-dev-eu/spaces" failed: No such file or directory (2)
    rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1207) [sender=3.1.3]
  rc: 23

PLAY RECAP ****************************************************************************************************************************************************************
ec2-3-122-238-188.eu-central-1.compute.amazonaws.com : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

$ ls -la "/tmp/dir with spaces"
total 12
drwxrwxr-x  2 jenkins jenkins 4096 Dec 30 21:40 .
drwxrwxrwt 24 root    root    4096 Dec 30 21:39 ..
-rw-rw-r--  1 jenkins jenkins    5 Dec 30 21:40 test_file
saito-hideki commented 2 years ago

Hi @azhelev ! Thank you for reporting this. I have confirmed that the issue has been fixed by #278 in my test environment. If it is possible, can you try to use devel version ansible.posix?

azhelev commented 2 years ago

Hi, sorry for late reply. I was able to test, works for me now. Thanks

db-it commented 9 months ago

Hi, what's the status here? Is there a fix, that could be released?

Facing the same issue. :(