ansible-collections / ansible.posix

Ansible Collection for Posix
Other
157 stars 152 forks source link

Synchronize not using quotes around arguments like --out-format #190

Open PrestonTaylor opened 3 years ago

PrestonTaylor commented 3 years ago
SUMMARY

quotes not being places around important arguments See here for further details https://github.com/ansible/ansible/issues/46126 Confirmed still buggy in 2.9.6

ISSUE TYPE
COMPONENT NAME

Synchronize

ANSIBLE VERSION
ansible 2.9.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/me/.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.5 (default, Jan 27 2021, 15:41:15) [GCC 9.3.0]
OS / ENVIRONMENT

Ubuntu 20 local Centos 7 remote

STEPS TO REPRODUCE
  - name: rsync
    synchronize:
      src: /home/centos/somedir/*
      dest: /app/somdir
      rsync_opts:
        - "--exclude='someotherdir'" 
      mode: pull
      compress: no
    delegate_to: "{{ inventory_hostname }}"
EXPECTED RESULTS
/usr/bin/rsync --delay-updates -F --archive --exclude='someotherdir' --out-format='<<CHANGED>>%i %n%L' /home/centos/somedir/* /app/somedir
ACTUAL RESULTS
"cmd": "/usr/bin/rsync --delay-updates -F --archive --exclude='someotherdir' --out-format=<<CHANGED>>%i %n%L /home/centos/somedir/* /app/somedir",

---snip---
"msg": "rsync: link_stat \"/home/centos/somedir/*\" failed: No such file or directory (2)\nrsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1179) [sender=3.1.2]\n",

Notice lack of ' on --out-format

Akasurde commented 3 years ago

@PrestonTaylor Could you please check PR #213 works for you and let us know? Thanks.

needs_info

PrestonTaylor commented 3 years ago

Looks good to me, I'm having trouble using galaxy to install this branch to test it (if you have an command that would resolve that then I'll give it a try) but I can't see why this wouldn't resolve it.

preston@asdf~$ ansible-galaxy install -vvvv git+https://github.com/ansible-collections/ansible.posix.git,fix-24-and-190
ansible-galaxy 2.9.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/preston/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible-galaxy
  python version = 3.8.5 (default, May 27 2021, 13:30:53) [GCC 9.3.0]
Using /etc/ansible/ansible.cfg as config file
Processing role ansible.posix
[WARNING]: - ansible.posix was NOT installed successfully: - command /usr/bin/git checkout fix-24-and-190 failed in directory /home/preston/.ansible/tmp/ansible-
local-1258h4wz0_kg/tmppq2a0buw/ansible.posix (rc=1)
ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.
Akasurde commented 3 years ago

@PrestonTaylor Thanks for the feedback. The PR #213 is not merged, yet. So you need to use origin authors repo like -

# ansible-galaxy collection install git+https://github.com/ndgit/ansible.posix.git,fix-24-and-190

Let me know if you require any help.

quidame commented 3 years ago

In my opinion, this is not a bug.

I can reproduce the issue with a glob pattern as the src, like in the description (src: /home/centos/somedir/*). But there is nothing that claims that glob patterns are supported for src parameter, as results tell us:

rsync: link_stat "/home/centos/somedir/*" failed: No such file or directory

@PrestonTaylor , a trailing / in your src path could be what you need to reach your goal. Please refer to the rsync(1) manpage for clarifications about /path/to/source vs. /path/to/source/ behaviors.

cybernotic commented 3 weeks ago

Hi, Im getting the same error message due to lack of quotes around --out-format

os: ubuntu-jammy-22.04-amd64 ansible 2.10.8 config file = None configured module search path = ['/home/ubuntu/.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.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0]

code: synchronize: mode: pull src: "somefolder/*" dest: "somefolder/" with_items:

error: rsync: [sender] link_stat "somefolder/*" failed: No such file or directory (2) rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1338) [sender=3.2.7] cmd: /usr/bin/rsync --delay-updates -F --compress --archive --out-format=<<CHANGED>>%i %n%L /somefolder/* /somefolder/

Running the above command manually on the same system locally did not work, it turned the cursor into '>' as if it's waiting for an input.

I added the quotes around '<<CHANGED>>%i %n%L ' and then the command worked. Removing \ or * made no difference. Is there some quick work around I can do?

cybernotic commented 2 weeks ago

Updating to the latest Ansible version solved my issue.