diff options
author | Sloane Hertel <19572925+s-hertel@users.noreply.github.com> | 2023-03-30 18:20:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-30 17:20:10 -0500 |
commit | 666188892ed0833e87803a3e80c58923e4cd6bca (patch) | |
tree | add8bdbb0c25578758a6ab32752049a0df72b3f8 /lib/ansible | |
parent | a45dd2a01c9b254bfa10fbd119f8ea99cf881992 (diff) | |
download | ansible-666188892ed0833e87803a3e80c58923e4cd6bca.tar.gz |
fix using templated values for include/import role FA (#80320)
* fix using templated values for include/import role options 'public', 'allow_duplicates', and 'rolespec_validate'
* pass templated values without changing the instance
* Fix templating by setting always_post_validate to True and calling IncludeRole.post_validate() instead
ci_complete
* add changelog
Diffstat (limited to 'lib/ansible')
-rw-r--r-- | lib/ansible/playbook/helpers.py | 1 | ||||
-rw-r--r-- | lib/ansible/playbook/included_file.py | 1 | ||||
-rw-r--r-- | lib/ansible/playbook/role_include.py | 6 |
3 files changed, 5 insertions, 3 deletions
diff --git a/lib/ansible/playbook/helpers.py b/lib/ansible/playbook/helpers.py index 489100e22a..46fe46a111 100644 --- a/lib/ansible/playbook/helpers.py +++ b/lib/ansible/playbook/helpers.py @@ -307,6 +307,7 @@ def load_list_of_tasks(ds, play, block=None, role=None, task_include=None, use_h # template the role name now, if needed all_vars = variable_manager.get_vars(play=play, task=ir) templar = Templar(loader=loader, variables=all_vars) + ir.post_validate(templar=templar) ir._role_name = templar.template(ir._role_name) # uses compiled list from object diff --git a/lib/ansible/playbook/included_file.py b/lib/ansible/playbook/included_file.py index 409eaec795..b833077c95 100644 --- a/lib/ansible/playbook/included_file.py +++ b/lib/ansible/playbook/included_file.py @@ -187,6 +187,7 @@ class IncludedFile: role_name = templar.template(role_name) new_task = original_task.copy() + new_task.post_validate(templar=templar) new_task._role_name = role_name for from_arg in new_task.FROM_ARGS: if from_arg in include_args: diff --git a/lib/ansible/playbook/role_include.py b/lib/ansible/playbook/role_include.py index 4c56a4dc76..155c123c7e 100644 --- a/lib/ansible/playbook/role_include.py +++ b/lib/ansible/playbook/role_include.py @@ -51,9 +51,9 @@ class IncludeRole(TaskInclude): # ATTRIBUTES # private as this is a 'module options' vs a task property - allow_duplicates = NonInheritableFieldAttribute(isa='bool', default=True, private=True) - public = NonInheritableFieldAttribute(isa='bool', default=False, private=True) - rolespec_validate = NonInheritableFieldAttribute(isa='bool', default=True) + allow_duplicates = NonInheritableFieldAttribute(isa='bool', default=True, private=True, always_post_validate=True) + public = NonInheritableFieldAttribute(isa='bool', default=False, private=True, always_post_validate=True) + rolespec_validate = NonInheritableFieldAttribute(isa='bool', default=True, private=True, always_post_validate=True) def __init__(self, block=None, role=None, task_include=None): |