mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-04 23:44:00 -07:00
Imports and includes (#25399)
Initial commit to split includes into static imports/dynamic includes This implements the new include/import syntax for Ansible 2.4: * include_{tasks,role,variables} = dynamic * import_{playbook,tasks,role} = static The old bare `include` will be considered deprecated, as will any use of the `static: {yes|no}` option. This also adds docs for import/include and reorganizing the "Playbook Reuse" section of the documentation.
This commit is contained in:
parent
3549391673
commit
483df9c5f8
32 changed files with 812 additions and 569 deletions
|
@ -215,10 +215,10 @@ class Task(Base, Conditional, Taggable, Become):
|
|||
# top level of the task, so we move those into the 'vars' dictionary
|
||||
# here, and show a deprecation message as we will remove this at
|
||||
# some point in the future.
|
||||
if action == 'include' and k not in self._valid_attrs and k not in self.DEPRECATED_ATTRIBUTES:
|
||||
display.deprecated("Specifying include variables at the top-level of the task is deprecated. "
|
||||
"Please see:\nhttp://docs.ansible.com/ansible/playbooks_roles.html#task-include-files-and-encouraging-reuse\n\n "
|
||||
"for currently supported syntax regarding included files and variables", version="2.7")
|
||||
if action in ('include', 'include_tasks') and k not in self._valid_attrs and k not in self.DEPRECATED_ATTRIBUTES:
|
||||
display.deprecated("Specifying include variables at the top-level of the task is deprecated."
|
||||
" Please see:\nhttp://docs.ansible.com/ansible/playbooks_roles.html#task-include-files-and-encouraging-reuse\n\n"
|
||||
" for currently supported syntax regarding included files and variables", version="2.7")
|
||||
new_ds['vars'][k] = v
|
||||
else:
|
||||
new_ds[k] = v
|
||||
|
@ -331,7 +331,7 @@ class Task(Base, Conditional, Taggable, Become):
|
|||
all_vars = dict()
|
||||
if self._parent:
|
||||
all_vars.update(self._parent.get_include_params())
|
||||
if self.action in ('include', 'include_role'):
|
||||
if self.action in ('include', 'include_tasks', 'include_role'):
|
||||
all_vars.update(self.vars)
|
||||
return all_vars
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue