Skip to content

Instantly share code, notes, and snippets.

@s-hertel
Created July 16, 2024 20:04
Show Gist options
  • Save s-hertel/f6d7b1abb17e729bff95597597aa6097 to your computer and use it in GitHub Desktop.
Save s-hertel/f6d7b1abb17e729bff95597597aa6097 to your computer and use it in GitHub Desktop.
test_dir
├── roles
│ ├── a
│ │ ├── tasks
│ │ │ ├── subtasks
│ │ │ │ ├── main.yml
│ │ │ │ │ - debug: msg="{{ lookup('file', 'test_relative.yml') }}"
│ │ │ │ ├── test_relative.yml
│ │ │ │ │ - debug: msg="works before 2.16.3"
│ │ │ ├── main.yml
│ │ │ │
├── playbook.yml
│ - hosts: localhost
│ gather_facts: no
│ tasks:
│ - include_role:
│ name: a
│ tasks_from: subtasks/main.yml
Solution 1: tasks/main.yml can be removed to to restore the original non-role search path
Solution 2: use the path recognized within the context of the role according to https://docs.ansible.com/ansible/latest/playbook_guide/playbook_pathing.html#resolving-local-relative-paths (in this example, since it's looking up a 'file' and it isn't in the files directory, it should be "{{ lookup('file', 'tasks/subtasks/test_relative.yml') }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment