-
Notifications
You must be signed in to change notification settings - Fork 24k
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
Be much more explicit about variable precedence as it applies to roles #73939
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Precedence is, indeed, complicated and difficult to describe clearly. I've added a few questions and suggestions.
Co-authored-by: Alicia Cozine <879121+acozine@users.noreply.github.com>
Related PR: #72808 |
Co-authored-by: Alicia Cozine <879121+acozine@users.noreply.github.com>
#. play ``vars`` | ||
#. play ``vars_prompt`` | ||
#. play ``vars_files`` | ||
#. role vars from all roles (defined in ``roles/*/vars/main.yml`` or ``vars:``) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should vars
have a colon here, but not for similar cases in lines above (play vars
, play vars_prompt
, play vars_files
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the colon is useful to visually cue the reader that it should be defined in an ansible/playbook/task/whatever file rather than in a standalone vars file.
However, as a reader of the docs, I would not know where this vars:
would be defined. Where would you put vars:
inside a role? On a task? Does vars:
on a task count as a roles var here? Does this mean if I have a list of roles defined in a playbook, and set a variable for one role, the other roles get that variable too?
#. inventory file relative ``group_vars/all`` [3]_ | ||
#. playbook file relative ``group_vars/all`` [3]_ | ||
#. inventory file relative ``group_vars/*`` [3]_ | ||
#. playbook file relative ``group_vars/*`` [3]_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might read better reversed like:
#. ``group_vars/all`` relative to inventory file [3]_
#. ``group_vars/all`` relative to playbook file [3]_
#. ``group_vars/*`` relative to inventory file [3]_
#. ``group_vars/*`` relative to playbook file [3]_
#. inventory file relative ``host_vars/*`` [3]_ | ||
#. playbook file relative ``host_vars/*`` [3]_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might read better reversed like:
#. ``host_vars/*`` relative to inventory file [3]_
#. ``host_vars/*`` relative to playbook file [3]_
#. play ``vars`` | ||
#. play ``vars_prompt`` | ||
#. play ``vars_files`` | ||
#. role vars from all roles (defined in ``roles/*/vars/main.yml`` or ``vars:``) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the colon is useful to visually cue the reader that it should be defined in an ansible/playbook/task/whatever file rather than in a standalone vars file.
However, as a reader of the docs, I would not know where this vars:
would be defined. Where would you put vars:
inside a role? On a task? Does vars:
on a task count as a roles var here? Does this mean if I have a list of roles defined in a playbook, and set a variable for one role, the other roles get that variable too?
#. role vars from all roles (defined in ``roles/*/vars/main.yml`` or ``vars:``) | ||
#. role dependency vars for tasks from a role (defined in ``roles/{dependent_roles}/vars/main.yml``) | ||
#. role vars for tasks from a role (defined in ``role/vars/main.yml``) [5]_ [8]_ [9]_ | ||
#. block ``vars`` (only for tasks in block) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing a
between "in" and "block".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or make block
plural
Thanks for your Ansible docs contribution! We talk about Ansible documentation on maxtrix at #docs:ansible.im and on libera IRC at #ansible-docs if you ever want to join us and chat about the docs! We meet there on Tuesdays (see the Ansible calendar) and welcome additions to our weekly agenda items - scroll down to find the upcoming agenda and add a comment to put something new on that agenda. |
SUMMARY
Be much more explicit about variable precedence as it applies to roles
Also fixes #43543
ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION