From 4e08064afae62fdb74a50fbfe690544f8509ccc6 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Fri, 1 May 2015 08:32:26 -0500 Subject: [PATCH] Fix issue where included blocks were not filtered on tags (v2) --- v2/ansible/playbook/taggable.py | 2 +- v2/ansible/plugins/strategies/linear.py | 4 +++- v2/samples/hosts | 1 + v2/samples/include.yml | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 v2/samples/hosts diff --git a/v2/ansible/playbook/taggable.py b/v2/ansible/playbook/taggable.py index 3622dc34b27..40e05d1817a 100644 --- a/v2/ansible/playbook/taggable.py +++ b/v2/ansible/playbook/taggable.py @@ -26,7 +26,7 @@ from ansible.template import Templar class Taggable: untagged = set(['untagged']) - _tags = FieldAttribute(isa='list', default=None) + _tags = FieldAttribute(isa='list', default=[]) def __init__(self): super(Taggable, self).__init__() diff --git a/v2/ansible/plugins/strategies/linear.py b/v2/ansible/plugins/strategies/linear.py index 9988bb3e2a3..95ecac1451f 100644 --- a/v2/ansible/plugins/strategies/linear.py +++ b/v2/ansible/plugins/strategies/linear.py @@ -285,7 +285,9 @@ class StrategyModule(StrategyBase): noop_block.rescue = [noop_task for t in new_block.rescue] for host in hosts_left: if host in included_file._hosts: - all_blocks[host].append(new_block) + task_vars = self._variable_manager.get_vars(loader=self._loader, play=iterator._play, host=host, task=included_file._task) + final_block = new_block.filter_tagged_tasks(connection_info, task_vars) + all_blocks[host].append(final_block) else: all_blocks[host].append(noop_block) diff --git a/v2/samples/hosts b/v2/samples/hosts new file mode 100644 index 00000000000..118379ffd9e --- /dev/null +++ b/v2/samples/hosts @@ -0,0 +1 @@ +testing ansible_connection=local ansible_ssh_host=192.168.122.100 ansible_ssh_user=testing diff --git a/v2/samples/include.yml b/v2/samples/include.yml index 3a2e88f8985..121c4ce0794 100644 --- a/v2/samples/include.yml +++ b/v2/samples/include.yml @@ -1,4 +1,6 @@ - debug: msg="this is the include, a=={{a}}" + tags: + - included #- debug: msg="this is the second debug in the include" #- debug: msg="this is the third debug in the include, and a is still {{a}}"