From 7edee91abac3aed03ca2b2238d14c9447936b310 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 17 Mar 2014 11:28:01 -0500 Subject: [PATCH] Fixing a bug in role tag handling where only the first tag was used Fixes #6517 --- lib/ansible/playbook/play.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/ansible/playbook/play.py b/lib/ansible/playbook/play.py index 3ff855c1cb..fc5b4997f0 100644 --- a/lib/ansible/playbook/play.py +++ b/lib/ansible/playbook/play.py @@ -228,24 +228,28 @@ class Play(object): if meta_data: allow_dupes = utils.boolean(meta_data.get('allow_duplicates','')) - if "tags" in passed_vars: - if not self._is_valid_tag(passed_vars["tags"]): - # one of the tags specified for this role was in the - # skip list, or we're limiting the tags and it didn't - # match one, so we just skip it completely - continue - # if any tags were specified as role/dep variables, merge # them into the passed_vars so they're passed on to any # further dependencies too, and so we only have one place # (passed_vars) to look for tags going forward def __merge_tags(var_obj): old_tags = passed_vars.get('tags', []) - new_tags = var_obj.get('tags', []) - if isinstance(new_tags, basestring): - new_tags = [new_tags, ] + if isinstance(var_obj, dict): + new_tags = var_obj.get('tags', []) + if isinstance(new_tags, basestring): + new_tags = [new_tags, ] + else: + new_tags = [] return list(set(old_tags).union(set(new_tags))) + if "tags" in passed_vars: + dep_tags = __merge_tags(dep) + if not self._is_valid_tag(dep_tags): + # one of the tags specified for this role was in the + # skip list, or we're limiting the tags and it didn't + # match one, so we just skip it completely + continue + passed_vars['tags'] = __merge_tags(role_vars) passed_vars['tags'] = __merge_tags(dep_vars)