Fixes #5622 included tasks in roles now inherit tags from the role

pull/6666/head
James Tanner 11 years ago
parent 9db652a21b
commit d327e3d11a

@ -142,6 +142,8 @@ class Play(object):
self._tasks = self._load_tasks(self._ds.get('tasks', []), load_vars)
self._handlers = self._load_tasks(self._ds.get('handlers', []), load_vars)
# apply any missing tags to role tasks
self._late_merge_role_tags()
if self.sudo_user != 'root':
self.sudo = True
@ -712,6 +714,31 @@ class Play(object):
# *************************************************
def _late_merge_role_tags(self):
# build a local dict of tags for roles
role_tags = {}
for task in self._ds['tasks']:
if 'role_name' in task:
this_role = task['role_name']
if this_role not in role_tags:
role_tags[this_role] = []
if 'tags' in task['vars']:
if isinstance(task['vars']['tags'], basestring):
role_tags[task['role_name']] += shlex.split(task['vars']['tags'])
else:
role_tags[task['role_name']] += task['vars']['tags']
# apply each role's tags to it's tasks
for idx, val in enumerate(self._tasks):
if hasattr(val, 'role_name'):
this_role = val.role_name
if this_role in role_tags:
self._tasks[idx].tags = sorted(set(self._tasks[idx].tags + role_tags[this_role]))
# *************************************************
def _has_vars_in(self, msg):
return "$" in msg or "{{" in msg

Loading…
Cancel
Save