Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
PrestonTaylor opened this issue May 24, 2021 · 6 comments
Open
Labels
needs_verified Needs to reproduced before processing

Comments

@PrestonTaylor
Copy link

PrestonTaylor commented May 24, 2021

SUMMARY

quotes not being places around important arguments
See here for further details ansible/ansible#46126
Confirmed still buggy in 2.9.6

ISSUE TYPE
  • Bug Report
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 Akasurde added the needs_verified Needs to reproduced before processing label Jun 3, 2021
@Akasurde
Copy link
Member

Akasurde commented Jul 8, 2021

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

needs_info

@PrestonTaylor
Copy link
Author

PrestonTaylor commented Jul 13, 2021

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
Copy link
Member

@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.

ansible-zuul bot added a commit that referenced this issue Jul 14, 2021
synchronize: quotes around arguments

fix quoting for specific cmd arguments
Fixes:

#24
#190

ISSUE TYPE:

Bugfix Pull Request

COMPONENT NAME:
module: synchronize

Reviewed-by: Abhijeet Kasurde <None>
Reviewed-by: Robert Rettig <None>
Reviewed-by: Hideki Saito <[email protected]>
Reviewed-by: Mike Graves <[email protected]>
@quidame
Copy link
Contributor

quidame commented Jul 26, 2021

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
Copy link

cybernotic commented Sep 7, 2024

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:
- "test1.xml"
- classic.xml
- default.xml

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
Copy link

Updating to the latest Ansible version solved my issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs_verified Needs to reproduced before processing
Projects
None yet
Development

No branches or pull requests

4 participants