-
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
variables defined with 'vars:' keyword below 'role:' have unexpected values when used in imported/included roles #50278
Comments
Files identified in the description: If these files are inaccurate, please update the |
This is the expected behavior when using As such, You can set role vars as private to change this behavior: https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-private-role-vars |
@sivel then should not the output result be
? In order to highlight the difference, here is the diff with the actual result: PLAY [all] ***
-TASK [include testrole2 (blah)] ***
+TASK [include testrole2 (www.blah)] ***
TASK [testrole2 : test task (www.blah)] ***
ok: [localhost] => { |
Probably. It's probably some nuance that I don't see right now in regards to templating out the task name for callbacks. |
This is happening due to the following code: ansible/lib/ansible/vars/manager.py Lines 394 to 395 in 013c42b
When templating the name for callbacks in |
We will need to document whatever the resolution to this issue is. |
It was mentioned during an ansible-doc meeting:
|
What are actually role params? I thought that role params are just the |
here is an example of role parameter:
here is an example of role variable:
Both expressions |
yes, they are listed there, but their meaning is AFAICT not explained, so I always thought that
and
is not explained, so even if one is aware of the former (I don't remember seeing it in the docs) one would assume that it is a syntactic sugar for the latter. Confusingly, the latter is called a parameter, not role variable:
|
@pilou- Anyway, thanks for the explanation. |
I also see above that
and
which seem to have opposite views of the semantics (if "bleed" means "leak out to the whole play"). |
Lets update the doc for this properly and soon.
Lets update this doc:
There is a lot of confusion about this: |
@pcahyna they 'bleed' in the context that they get mixed and/or overridden by actual role parameters, not in the scope of other variables nor play objects. for example:
since |
@SimonHeimberg |
Should not the current behavior - unchanged since several versions - be documented ? |
##### SUMMARY Documentation playbooks_reuse_roles is more explicit about where role variables of a role are accessible. ##### ISSUE TYPE - Docs Pull Request +label: docsite_pr improves ansible#50278
Clear usage of terms. Role parameters exist as well (see ansible#50278), but the example uses variables. So use the term variable.
Use terms clearly. Role parameters exist as well (see ansible#50278), but the example uses variables. So use the term variable.
This was a long-standing bug with vars inheritance. This was fixed by #75034, so now all three example playbooks do the same thing. Role params and role variables are not equivalent/just syntactic sugar though. There's a draft PR to document the differences here: #73939.
|
SUMMARY
Variables defined with
vars:
keyword belowrole:
have unexpected values when used in imported/included role.I am not sure:
vars
keyword belowrole
androle params
the same thing ?role params
torole vars
, implying that variables defined withvars
keyword belowrole
arerole params
(but behaviors differ, see ADDITIONAL INFO section)vars
keywords at role/task level share the same definitionISSUE TYPE
COMPONENT NAME
role
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
import_role
here doesn't change anything):EXPECTED RESULTS
ACTUAL RESULTS
ADDITIONAL INFORMATION
Note that output is the same that the one expected when using these playbooks:
The text was updated successfully, but these errors were encountered: