ansible-collections / ansible.posix

Ansible Collection for Posix
Other
159 stars 153 forks source link

synchronize with `src: ..` behaves the same as `src: .` #558

Open dalbertom opened 3 months ago

dalbertom commented 3 months ago
SUMMARY

Hi there, I have a repository that I want to copy over using synchronize but I keep the ansible playbook in a subdirectory, so I set src: .. and to my surprise only the ansible directory gets copied over instead of the entire repository. This behaves exactly the same as src: .. To workaround it, I can use src: ../.. but that's technically incorrect. Another workaround I found is src: "{{ playbook_dir }}/.."

ISSUE TYPE
COMPONENT NAME

synchronize

ANSIBLE VERSION
ansible [core 2.17.1]
  config file = /Users/user/src/repository/ansible/ansible.cfg
  configured module search path = ['/Users/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/Cellar/ansible/10.1.0/libexec/lib/python3.12/site-packages/ansible
  ansible collection location = /Users/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.12.4 (main, Jun  6 2024, 18:26:44) [Clang 15.0.0 (clang-1500.3.9.4)] (/opt/homebrew/Cellar/ansible/10.1.0/libexec/bin/python)
  jinja version = 3.1.4
  libyaml = True
COLLECTION VERSION
Collection        Version
----------------- -------
community.general 9.1.0
ansible.posix 1.5.4
CONFIGURATION
CONFIG_FILE() = None
EDITOR(env: EDITOR) = vi
OS / ENVIRONMENT

macOS Sonoma 14.6

STEPS TO REPRODUCE
touch missing.txt
mkdir ansible
touch ansible/playbook.yml
# ansible/playbook.yml
---
- hosts: localhost
  tasks:
    - name: This should have copied missing.txt
      synchronize:
        src: ..
        dest: "/tmp/destination"
cd ansible
ansible-playbook playbook.yml # only ansible directory is copied
EXPECTED RESULTS

With src: .. I would expect the parent directory to be copied over

ACTUAL RESULTS

both src: . and src: .. evaluate to the ansible directory

TASK [This should have copied missing.txt] *********************************************************************************************************************************************************************************************************
ok: [localhost] => {"changed": false, "cmd": "/opt/homebrew/bin/rsync --delay-updates -F --compress --archive --out-format='<<CHANGED>>%i %n%L' /Users/user/path/ansible /tmp/destination", "msg": "", "rc": 0, "stdout_lines": []}