mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
Dynamic role include (#17401)
* dynamic role_include * more fixes for dynamic include roles * set play yfrom iterator when dynamic * changes from jimi-c * avoid modules that break ad hoc TODO: should really be a config
This commit is contained in:
parent
d5aecfdd14
commit
ff34f5548d
9 changed files with 148 additions and 49 deletions
|
@ -403,7 +403,7 @@ class TaskExecutor:
|
|||
return dict(changed=False, skipped=True, skip_reason='Conditional check failed', _ansible_no_log=self._play_context.no_log)
|
||||
except AnsibleError:
|
||||
# skip conditional exception in the case of includes as the vars needed might not be avaiable except in the included tasks or due to tags
|
||||
if self._task.action != 'include':
|
||||
if self._task.action in ['include', 'include_role']:
|
||||
raise
|
||||
|
||||
# if we ran into an error while setting up the PlayContext, raise it now
|
||||
|
@ -425,10 +425,10 @@ class TaskExecutor:
|
|||
# if this task is a IncludeRole, we just return now with a success code so the main thread can expand the task list for the given host
|
||||
elif self._task.action == 'include_role':
|
||||
include_variables = self._task.args.copy()
|
||||
role = include_variables.pop('name')
|
||||
role = templar.template(self._task._role_name)
|
||||
if not role:
|
||||
return dict(failed=True, msg="No role was specified to include")
|
||||
return dict(name=role, include_variables=include_variables)
|
||||
return dict(include_role=role, include_variables=include_variables)
|
||||
|
||||
# Now we do final validation on the task, which sets all fields to their final values.
|
||||
self._task.post_validate(templar=templar)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue