ansible icon indicating copy to clipboard operation
ansible copied to clipboard

symlink fixes broke relative symlinks

Open karcaw opened this issue 1 year ago • 1 comments

Summary

When i use symlinks in a role that are not in the base directory of the role, the ansible-galaxy tool makes dangling symlinks.

I believe it is related to these fixes: https://github.com/ansible/ansible/pull/82165 https://github.com/ansible/ansible/pull/82325 https://github.com/ansible/ansible/pull/82324 https://github.com/ansible/ansible/pull/82323

They seem to force all symlinks to be relative to the base, even when the source symlink points at the current directory.

Issue Type

Bug Report

Component Name

galaxy

Ansible Version

$ ansible --version
ansible [core 2.16.3]
  config file = /home/efelix/.ansible.cfg
  configured module search path = ['/home/efelix/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/efelix/.pyenv/versions/3.11.0/lib/python3.11/site-packages/ansible
  ansible collection location = /home/efelix/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/efelix/.pyenv/versions/3.11.0/bin/ansible
  python version = 3.11.0 (main, Feb  1 2023, 09:33:45) [GCC 11.3.0] (/home/efelix/.pyenv/versions/3.11.0/bin/python3.11)
  jinja version = 3.1.2
  libyaml = True


I have tested version back to before 8.0.0 and before the 8.0.0 series this is not an issue

Configuration

# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = /home/<user>/.ansible.cfg
EDITOR(env: EDITOR) = /usr/bin/vim
PAGER(env: PAGER) = less

OS / Environment

Rocky9, Ubuntu 22.04, probably others

Steps to Reproduce

ansible-galaxy install -p /tmp/roles  git+https://github.com/karcaw/test_symlink.git  --force
ls -al /tmp/roles/test_symlink/tasks 

Expected Results

I expect the CentOS9.yml symlink to point at the Rocky9.yml file:

> ls -al /tmp/roles/test_symlink/tasks 
total 12K
drwxr-xr-x 2 user user 4.0K Feb 16 15:31 .
drwxr-xr-x 8 user user 4.0K Feb 16 15:31 ..
lrwxrwxrwx 1 user user   10 Feb 16 15:31 CentOS9.yml -> Rocky9.yml
-rw-rw-r-- 1 user user  179 Feb 16 15:31 main.yml
-rw-rw-r-- 1 user user    0 Feb 16 15:31 Rocky9.yml

Actual Results

> ls -al /tmp/roles/test_symlink/tasks                                  
total 12K
drwxr-xr-x 2 user user 4.0K Feb 16 15:55 .
drwxr-xr-x 8 user user 4.0K Feb 16 15:55 ..
lrwxrwxrwx 1 user user   16 Feb 16 15:55 CentOS9.yml -> tasks/Rocky9.yml
-rw-rw-r-- 1 user user  179 Feb 16 15:31 main.yml
-rw-rw-r-- 1 user user    0 Feb 16 15:31 Rocky9.yml

Code of Conduct

  • [X] I agree to follow the Ansible Code of Conduct

karcaw avatar Feb 16 '24 23:02 karcaw

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the component bot command.

ansibot avatar Feb 16 '24 23:02 ansibot

I can confirm that I am seeing this bug as well. This is what grabbing a role via ansible-galaxy produces:

❯ pwd
/home/jeremy_frasier/.ansible/roles/freeipa_client/vars
roles/freeipa_client/vars 
❯ ls -l
total 8
lrwxrwxrwx 1 jeremy_frasier jeremy_frasier  15 Mar  8 13:28 Debian.yml -> vars/Fedora.yml
-rw-r--r-- 1 jeremy_frasier jeremy_frasier 195 Mar  8 13:21 Fedora.yml
-rw-r--r-- 1 jeremy_frasier jeremy_frasier 191 Mar  8 13:21 RedHat.yml

Whereas the actual role as it stands in GitHub is correct.

jsf9k avatar Mar 08 '24 18:03 jsf9k

@karcaw - Are you able to pin ansible-core to work around this issue?

jsf9k avatar Mar 08 '24 20:03 jsf9k

I did roll back to ansible before 8.0.0 and things worked as expected.

karcaw avatar Mar 08 '24 21:03 karcaw

I found that pinning ansible-core<2.16.3 suffices for me.

jsf9k avatar Mar 08 '24 21:03 jsf9k

Ansible >= 2.15.9 is also affected.

anxstj avatar Apr 19 '24 11:04 anxstj