mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
Filter tasks based on tags during iterator setup in v2
This commit is contained in:
@@ -87,10 +87,15 @@ class PlayIterator:
|
||||
FAILED_RESCUE = 4
|
||||
FAILED_ALWAYS = 8
|
||||
|
||||
def __init__(self, inventory, play):
|
||||
def __init__(self, inventory, play, connection_info, all_vars):
|
||||
self._play = play
|
||||
|
||||
self._blocks = self._play.compile()
|
||||
self._blocks = []
|
||||
for block in self._play.compile():
|
||||
new_block = block.filter_tagged_tasks(connection_info, all_vars)
|
||||
if new_block.has_tasks():
|
||||
self._blocks.append(new_block)
|
||||
|
||||
self._host_states = {}
|
||||
for host in inventory.get_hosts(self._play.hosts):
|
||||
self._host_states[host.name] = HostState(blocks=self._blocks)
|
||||
|
||||
@@ -161,7 +161,7 @@ class TaskQueueManager:
|
||||
raise AnsibleError("Invalid play strategy specified: %s" % new_play.strategy, obj=play._ds)
|
||||
|
||||
# build the iterator
|
||||
iterator = PlayIterator(inventory=self._inventory, play=new_play)
|
||||
iterator = PlayIterator(inventory=self._inventory, play=new_play, connection_info=connection_info, all_vars=all_vars)
|
||||
|
||||
# and run the play using the strategy
|
||||
return strategy.run(iterator, connection_info)
|
||||
|
||||
Reference in New Issue
Block a user