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

Fix task-adjacent search path in roles #83621

Merged
merged 3 commits into from
Aug 6, 2024

Conversation

s-hertel
Copy link
Contributor

@s-hertel s-hertel commented Jul 16, 2024

SUMMARY

Fixes #82695

Fix searching relative to the current task file's directory for as documented in https://docs.ansible.com/ansible/latest/playbook_guide/playbook_pathing.html#resolving-local-relative-paths (item 3):

Specifically, Ansible tries to find the file in the following order:
  1. In the current role.
      1. In its appropriate subdirectory: “files”, “vars”, “templates”, or “tasks”; depending on the kind of file Ansible is searching for.
      2. Directly in its directory.
  2. Like 1, in the parent role that called into this current role with include_role, import_role, or with a role dependency. If the parent role has its own parent role, Ansible will repeat this step with that role.
  3. Like 1, in the current task file’s directory.
  4. Like 1, in the current play file’s directory.
ISSUE TYPE
  • Bugfix Pull Request

@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. has_issue labels Jul 16, 2024
@s-hertel s-hertel force-pushed the fix-relative-search-path-roles branch from 5563ce0 to 96de72a Compare July 16, 2024 22:12
@webknjaz
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label Jul 23, 2024
@mkrizek mkrizek requested a review from bcoca July 23, 2024 15:34
@s-hertel
Copy link
Contributor Author

Here's the documentation change that added the first reference to the "task file's directory" #73818. I don't think the documentation was entirely correct at the time it was added, since lookups didn't correctly identify roles prior to #82290 (3 and 4 would have worked but not 1 and 2).

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jul 30, 2024
@tolland
Copy link
Contributor

tolland commented Jul 31, 2024

This is also a problem on the stable-16 branch. would be good to fix there as well. Thanks!

@s-hertel

This comment was marked as resolved.

This comment was marked as resolved.

@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Aug 2, 2024
@s-hertel s-hertel merged commit 0be66ed into ansible:devel Aug 6, 2024
67 checks passed
s-hertel added a commit to s-hertel/ansible that referenced this pull request Aug 6, 2024
* Restore search path in the current task file’s directory for roles

(cherry picked from commit 0be66ed)
s-hertel added a commit to s-hertel/ansible that referenced this pull request Aug 6, 2024
* Restore search path in the current task file’s directory for roles

(cherry picked from commit 0be66ed)
bcoca pushed a commit to bcoca/ansible that referenced this pull request Aug 12, 2024
* Restore search path in the current task file’s directory for roles
sivel pushed a commit that referenced this pull request Aug 28, 2024
* Restore search path in the current task file’s directory for roles

(cherry picked from commit 0be66ed)
sivel pushed a commit that referenced this pull request Aug 28, 2024
* Restore search path in the current task file’s directory for roles

(cherry picked from commit 0be66ed)
@ansible ansible locked and limited conversation to collaborators Sep 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug. has_issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Including tasks with first_found fails to find files within same task directory
6 participants