Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Role fixes (#82339) * Various fixes to roles - static property is now properly set - role_names and other magic vars now have full list - role public/private var loading is now done when adding to play.roles instead of on each var query - added tests Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit 55065c0) * import_role does not get public until next version
- Loading branch information
Showing
9 changed files
with
112 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
bugfixes: | ||
- roles, the ``static`` property is now correctly set, this will fix issues with ``public`` and ``DEFAULT_PRIVATE_ROLE_VARS`` controls on exporting vars. | ||
- roles, code cleanup and performance optimization of dependencies, now cached, and ``public`` setting is now determined once, at role instantiation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# use this to debug issues | ||
#- debug: msg={{ is_private ~ ', ' ~ is_default ~ ', ' ~ privacy|default('nope')}} | ||
|
||
- hosts: localhost | ||
name: test global privacy setting | ||
gather_facts: false | ||
roles: | ||
- a | ||
pre_tasks: | ||
|
||
- name: 'test roles: privacy' | ||
assert: | ||
that: | ||
- is_private and privacy is undefined or not is_private and privacy is defined | ||
- not is_default or is_default and privacy is defined | ||
|
||
- hosts: localhost | ||
name: test import_role privacy | ||
gather_facts: false | ||
tasks: | ||
- import_role: name=a | ||
|
||
- name: role is private, var should be undefined | ||
assert: | ||
that: | ||
- is_private and privacy is undefined or not is_private and privacy is defined | ||
- not is_default or is_default and privacy is defined | ||
|
||
- hosts: localhost | ||
name: test global privacy setting on includes | ||
gather_facts: false | ||
tasks: | ||
- include_role: name=a | ||
|
||
- name: test include_role privacy | ||
assert: | ||
that: | ||
- not is_default and (is_private and privacy is undefined or not is_private and privacy is defined) or is_default and privacy is undefined | ||
|
||
- hosts: localhost | ||
name: test public yes always overrides global privacy setting on includes | ||
gather_facts: false | ||
tasks: | ||
- include_role: name=a public=yes | ||
|
||
- name: test include_role privacy | ||
assert: | ||
that: | ||
- privacy is defined | ||
|
||
- hosts: localhost | ||
name: test public no always overrides global privacy setting on includes | ||
gather_facts: false | ||
tasks: | ||
- include_role: name=a public=no | ||
|
||
- name: test include_role privacy | ||
assert: | ||
that: | ||
- privacy is undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
privacy: in role a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
is_private: "{{lookup('config', 'DEFAULT_PRIVATE_ROLE_VARS')}}" | ||
is_default: "{{lookup('env', 'ANSIBLE_PRIVATE_ROLE_VARS') == ''}}" |