1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

clarified omit intended usage

fixes #13986
This commit is contained in:
Brian Coca 2016-09-23 10:18:46 -04:00
parent cf4d436e07
commit 52bf021904
2 changed files with 8 additions and 11 deletions

View file

@ -74,11 +74,10 @@ being raised.
.. _omitting_undefined_variables: .. _omitting_undefined_variables:
Omitting Undefined Variables and Parameters Omitting Parameters
------------------------------------------- -------------------
As of Ansible 1.8, it is possible to use the default filter to omit variables and module parameters using the special As of Ansible 1.8, it is possible to use the default filter to omit module parameters using the special `omit` variable::
`omit` variable::
- name: touch files with an optional mode - name: touch files with an optional mode
file: dest={{item.path}} state=touch mode={{item.mode|default(omit)}} file: dest={{item.path}} state=touch mode={{item.mode|default(omit)}}

View file

@ -53,7 +53,6 @@ class IncludeRole(Task):
super(IncludeRole, self).__init__(block=block, role=role, task_include=task_include) super(IncludeRole, self).__init__(block=block, role=role, task_include=task_include)
self._role_name = None
self.statically_loaded = False self.statically_loaded = False
self._from_files = {} self._from_files = {}
self._parent_role = role self._parent_role = role
@ -67,7 +66,7 @@ class IncludeRole(Task):
else: else:
myplay = play myplay = play
ri = RoleInclude.load(self._role_name, play=myplay, variable_manager=variable_manager, loader=loader) ri = RoleInclude.load(self.name, play=myplay, variable_manager=variable_manager, loader=loader)
ri.vars.update(self.vars) ri.vars.update(self.vars)
#ri._role_params.update(self.args) # jimi-c cant we avoid this? #ri._role_params.update(self.args) # jimi-c cant we avoid this?
@ -91,14 +90,13 @@ class IncludeRole(Task):
ir = IncludeRole(block, role, task_include=task_include).load_data(data, variable_manager=variable_manager, loader=loader) ir = IncludeRole(block, role, task_include=task_include).load_data(data, variable_manager=variable_manager, loader=loader)
#TODO: use more automated list: for builtin in r.get_attributes(): #jimi-c: doing this to avoid using role_params and conflating include_role specific opts with other tasks
# set built in's # set built in's
ir._role_name = ir.args.get('name') attributes = frozenset(self._valid_attrs.keys())
for builtin in ['static', 'private']: for builtin in attributes:
if ir.args.get(builtin): if ir.args.get(builtin):
setattr(ir, builtin, ir.args.get(builtin)) setattr(ir, builtin, ir.args.get(builtin))
# build options for roles # build options for role includes
for key in ['tasks', 'vars', 'defaults']: for key in ['tasks', 'vars', 'defaults']:
from_key = key + '_from' from_key = key + '_from'
if ir.args.get(from_key): if ir.args.get(from_key):
@ -110,7 +108,7 @@ class IncludeRole(Task):
new_me = super(IncludeRole, self).copy(exclude_parent=exclude_parent, exclude_tasks=exclude_tasks) new_me = super(IncludeRole, self).copy(exclude_parent=exclude_parent, exclude_tasks=exclude_tasks)
new_me.statically_loaded = self.statically_loaded new_me.statically_loaded = self.statically_loaded
new_me._role_name = self._role_name new_me.name = self.name
new_me._from_files = self._from_files.copy() new_me._from_files = self._from_files.copy()
new_me._parent_role = self._parent_role new_me._parent_role = self._parent_role