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

symlink fixes broke relative symlinks #82702

Closed
1 task done
karcaw opened this issue Feb 16, 2024 · 6 comments · Fixed by #82911
Closed
1 task done

symlink fixes broke relative symlinks #82702

karcaw opened this issue Feb 16, 2024 · 6 comments · Fixed by #82911
Assignees
Labels
affects_2.16 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. P3 Priority 3 - Approved, No Time Limitation verified This issue has been verified/reproduced by maintainer

Comments

@karcaw
Copy link

karcaw commented Feb 16, 2024

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:
#82165
#82325
#82324
#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

  • I agree to follow the Ansible Code of Conduct
@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. affects_2.16 labels Feb 16, 2024
@ansibot
Copy link
Contributor

ansibot commented Feb 16, 2024

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.

@s-hertel s-hertel added verified This issue has been verified/reproduced by maintainer P3 Priority 3 - Approved, No Time Limitation and removed needs_triage Needs a first human triage before being processed. labels Feb 20, 2024
@s-hertel s-hertel self-assigned this Feb 20, 2024
@jsf9k
Copy link

jsf9k commented Mar 8, 2024

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 added a commit to cisagov/openvpn-packer that referenced this issue Mar 8, 2024
ansible-core 2.16.4 suffers from the bug discussed in
ansible/ansible#82702, which breaks any symlinked files in vars,
tasks, etc. for any Ansible role installed via ansible-galaxy.
jsf9k added a commit to cisagov/openvpn-packer that referenced this issue Mar 8, 2024
ansible-core 2.16.4 suffers from the bug discussed in
ansible/ansible#82702, which breaks any symlinked files in vars,
tasks, etc. for any Ansible role installed via ansible-galaxy.
@jsf9k
Copy link

jsf9k commented Mar 8, 2024

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

jsf9k added a commit to cisagov/openvpn-packer that referenced this issue Mar 8, 2024
ansible-core 2.16.3 and later suffer from the bug discussed in
ansible/ansible#82702, which breaks any symlinked files in vars,
tasks, etc. for any Ansible role installed via ansible-galaxy.
@karcaw
Copy link
Author

karcaw commented Mar 8, 2024

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

jsf9k added a commit to cisagov/skeleton-packer that referenced this issue Mar 8, 2024
ansible-core 2.16.3 and later suffer from the bug discussed in
ansible/ansible#82702, which breaks any symlinked files in vars,
tasks, etc. for any Ansible role installed via ansible-galaxy.
@jsf9k
Copy link

jsf9k commented Mar 8, 2024

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

jsf9k added a commit to cisagov/skeleton-ansible-role that referenced this issue Mar 10, 2024
ansible-core 2.16.3 and later suffer from the bug discussed in
ansible/ansible#82702, which breaks any symlinked files in vars,
tasks, etc. for any Ansible role installed via ansible-galaxy.
@ansibot ansibot added the has_pr This issue has an associated PR. label Mar 11, 2024
jsf9k added a commit to cisagov/openvpn-packer that referenced this issue Mar 13, 2024
ansible-core 2.16.3 and later suffer from the bug discussed in
ansible/ansible#82702, which breaks any symlinked files in vars,
tasks, etc. for any Ansible role installed via ansible-galaxy.
mcdonnnj pushed a commit to cisagov/skeleton-ansible-role that referenced this issue Mar 27, 2024
ansible-core 2.16.3 and later suffer from the bug discussed in
ansible/ansible#82702, which breaks any symlinked files in vars,
tasks, etc. for any Ansible role installed via ansible-galaxy.
@anxstj
Copy link

anxstj commented Apr 19, 2024

Ansible >= 2.15.9 is also affected.

s-hertel added a commit that referenced this issue Apr 24, 2024
* Fix installing roles containing symlinks

Fix sanitizing tarfile symlinks relative to the link directory instead of the archive

For example:

role
├── handlers
│   └── utils.yml -> ../tasks/utils/suite.yml

The link ../tasks/utils/suite.yml will resolve to a path outside of the link's directory, but within the role

role/handlers/../tasks/utils/suite.yml

the resolved path relative to the role is tasks/utils/suite.yml, but if the symlink is set to that value, tarfile would extract it from role/handlers/tasks/utils/suite.yml

* Replace overly forgiving test case with tests for a symlink in a subdirectory of the archive and a symlink in the archive dir when these are not equivalent.

* Build test case from role files to make it easier to add test cases

Fixes #82702
Fixes #81965
Fixes #82051
s-hertel added a commit to s-hertel/ansible that referenced this issue Apr 24, 2024
* Fix installing roles containing symlinks

Fix sanitizing tarfile symlinks relative to the link directory instead of the archive

For example:

role
├── handlers
│   └── utils.yml -> ../tasks/utils/suite.yml

The link ../tasks/utils/suite.yml will resolve to a path outside of the link's directory, but within the role

role/handlers/../tasks/utils/suite.yml

the resolved path relative to the role is tasks/utils/suite.yml, but if the symlink is set to that value, tarfile would extract it from role/handlers/tasks/utils/suite.yml

* Replace overly forgiving test case with tests for a symlink in a subdirectory of the archive and a symlink in the archive dir when these are not equivalent.

* Build test case from role files to make it easier to add test cases

Fixes ansible#82702
Fixes ansible#81965
Fixes ansible#82051

(cherry picked from commit e84240d)
s-hertel added a commit to s-hertel/ansible that referenced this issue Apr 24, 2024
* Fix installing roles containing symlinks

Fix sanitizing tarfile symlinks relative to the link directory instead of the archive

For example:

role
├── handlers
│   └── utils.yml -> ../tasks/utils/suite.yml

The link ../tasks/utils/suite.yml will resolve to a path outside of the link's directory, but within the role

role/handlers/../tasks/utils/suite.yml

the resolved path relative to the role is tasks/utils/suite.yml, but if the symlink is set to that value, tarfile would extract it from role/handlers/tasks/utils/suite.yml

* Replace overly forgiving test case with tests for a symlink in a subdirectory of the archive and a symlink in the archive dir when these are not equivalent.

* Build test case from role files to make it easier to add test cases

Fixes ansible#82702
Fixes ansible#81965
Fixes ansible#82051

(cherry picked from commit e84240d)
s-hertel added a commit to s-hertel/ansible that referenced this issue Apr 24, 2024
* Fix installing roles containing symlinks

Fix sanitizing tarfile symlinks relative to the link directory instead of the archive

For example:

role
├── handlers
│   └── utils.yml -> ../tasks/utils/suite.yml

The link ../tasks/utils/suite.yml will resolve to a path outside of the link's directory, but within the role

role/handlers/../tasks/utils/suite.yml

the resolved path relative to the role is tasks/utils/suite.yml, but if the symlink is set to that value, tarfile would extract it from role/handlers/tasks/utils/suite.yml

* Replace overly forgiving test case with tests for a symlink in a subdirectory of the archive and a symlink in the archive dir when these are not equivalent.

* Build test case from role files to make it easier to add test cases

Fixes ansible#82702
Fixes ansible#81965
Fixes ansible#82051

(cherry picked from commit e84240d)
s-hertel added a commit to s-hertel/ansible that referenced this issue Apr 24, 2024
* Fix installing roles containing symlinks

Fix sanitizing tarfile symlinks relative to the link directory instead of the archive

For example:

role
├── handlers
│   └── utils.yml -> ../tasks/utils/suite.yml

The link ../tasks/utils/suite.yml will resolve to a path outside of the link's directory, but within the role

role/handlers/../tasks/utils/suite.yml

the resolved path relative to the role is tasks/utils/suite.yml, but if the symlink is set to that value, tarfile would extract it from role/handlers/tasks/utils/suite.yml

* Replace overly forgiving test case with tests for a symlink in a subdirectory of the archive and a symlink in the archive dir when these are not equivalent.

* Build test case from role files to make it easier to add test cases

Fixes ansible#82702
Fixes ansible#81965
Fixes ansible#82051

(cherry picked from commit e84240d)
sivel pushed a commit that referenced this issue Apr 25, 2024
* Fix installing roles containing symlinks

Fix sanitizing tarfile symlinks relative to the link directory instead of the archive

For example:

role
├── handlers
│   └── utils.yml -> ../tasks/utils/suite.yml

The link ../tasks/utils/suite.yml will resolve to a path outside of the link's directory, but within the role

role/handlers/../tasks/utils/suite.yml

the resolved path relative to the role is tasks/utils/suite.yml, but if the symlink is set to that value, tarfile would extract it from role/handlers/tasks/utils/suite.yml

* Replace overly forgiving test case with tests for a symlink in a subdirectory of the archive and a symlink in the archive dir when these are not equivalent.

* Build test case from role files to make it easier to add test cases

Fixes #82702
Fixes #81965
Fixes #82051

(cherry picked from commit e84240d)
@ansible ansible locked and limited conversation to collaborators May 8, 2024
nitzmahone pushed a commit that referenced this issue May 9, 2024
* Fix installing roles containing symlinks

Fix sanitizing tarfile symlinks relative to the link directory instead of the archive

For example:

role
├── handlers
│   └── utils.yml -> ../tasks/utils/suite.yml

The link ../tasks/utils/suite.yml will resolve to a path outside of the link's directory, but within the role

role/handlers/../tasks/utils/suite.yml

the resolved path relative to the role is tasks/utils/suite.yml, but if the symlink is set to that value, tarfile would extract it from role/handlers/tasks/utils/suite.yml

* Replace overly forgiving test case with tests for a symlink in a subdirectory of the archive and a symlink in the archive dir when these are not equivalent.

* Build test case from role files to make it easier to add test cases

Fixes #82702
Fixes #81965
Fixes #82051

(cherry picked from commit e84240d)
nitzmahone pushed a commit that referenced this issue May 9, 2024
* Fix installing roles containing symlinks

Fix sanitizing tarfile symlinks relative to the link directory instead of the archive

For example:

role
├── handlers
│   └── utils.yml -> ../tasks/utils/suite.yml

The link ../tasks/utils/suite.yml will resolve to a path outside of the link's directory, but within the role

role/handlers/../tasks/utils/suite.yml

the resolved path relative to the role is tasks/utils/suite.yml, but if the symlink is set to that value, tarfile would extract it from role/handlers/tasks/utils/suite.yml

* Replace overly forgiving test case with tests for a symlink in a subdirectory of the archive and a symlink in the archive dir when these are not equivalent.

* Build test case from role files to make it easier to add test cases

Fixes #82702
Fixes #81965
Fixes #82051

(cherry picked from commit e84240d)
nitzmahone pushed a commit that referenced this issue May 9, 2024
* Fix installing roles containing symlinks

Fix sanitizing tarfile symlinks relative to the link directory instead of the archive

For example:

role
├── handlers
│   └── utils.yml -> ../tasks/utils/suite.yml

The link ../tasks/utils/suite.yml will resolve to a path outside of the link's directory, but within the role

role/handlers/../tasks/utils/suite.yml

the resolved path relative to the role is tasks/utils/suite.yml, but if the symlink is set to that value, tarfile would extract it from role/handlers/tasks/utils/suite.yml

* Replace overly forgiving test case with tests for a symlink in a subdirectory of the archive and a symlink in the archive dir when these are not equivalent.

* Build test case from role files to make it easier to add test cases

Fixes #82702
Fixes #81965
Fixes #82051

(cherry picked from commit e84240d)
infame-io pushed a commit to infame-io/ansible that referenced this issue Sep 7, 2024
* Fix installing roles containing symlinks

Fix sanitizing tarfile symlinks relative to the link directory instead of the archive

For example:

role
├── handlers
│   └── utils.yml -> ../tasks/utils/suite.yml

The link ../tasks/utils/suite.yml will resolve to a path outside of the link's directory, but within the role

role/handlers/../tasks/utils/suite.yml

the resolved path relative to the role is tasks/utils/suite.yml, but if the symlink is set to that value, tarfile would extract it from role/handlers/tasks/utils/suite.yml

* Replace overly forgiving test case with tests for a symlink in a subdirectory of the archive and a symlink in the archive dir when these are not equivalent.

* Build test case from role files to make it easier to add test cases

Fixes ansible#82702
Fixes ansible#81965
Fixes ansible#82051
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.16 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. P3 Priority 3 - Approved, No Time Limitation verified This issue has been verified/reproduced by maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants