|
|
@ -31,7 +31,7 @@ DOCUMENTATION = '''
|
|
|
|
author: Ansible Core Team
|
|
|
|
author: Ansible Core Team
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
from ansible.errors import AnsibleError
|
|
|
|
from ansible.errors import AnsibleError, AnsibleAssertionError
|
|
|
|
from ansible.executor.play_iterator import PlayIterator
|
|
|
|
from ansible.executor.play_iterator import PlayIterator
|
|
|
|
from ansible.module_utils.six import iteritems
|
|
|
|
from ansible.module_utils.six import iteritems
|
|
|
|
from ansible.module_utils._text import to_text
|
|
|
|
from ansible.module_utils._text import to_text
|
|
|
@ -52,6 +52,36 @@ except ImportError:
|
|
|
|
|
|
|
|
|
|
|
|
class StrategyModule(StrategyBase):
|
|
|
|
class StrategyModule(StrategyBase):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
noop_task = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _replace_with_noop(self, target):
|
|
|
|
|
|
|
|
if self.noop_task is None:
|
|
|
|
|
|
|
|
raise AnsibleAssertionError('strategy.linear.StrategyModule.noop_task is None, need Task()')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result = []
|
|
|
|
|
|
|
|
for el in target:
|
|
|
|
|
|
|
|
if isinstance(el, Task):
|
|
|
|
|
|
|
|
result.append(self.noop_task)
|
|
|
|
|
|
|
|
elif isinstance(el, Block):
|
|
|
|
|
|
|
|
result.append(self._create_noop_block_from(el, el._parent))
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _create_noop_block_from(self, original_block, parent):
|
|
|
|
|
|
|
|
noop_block = Block(parent_block=parent)
|
|
|
|
|
|
|
|
noop_block.block = self._replace_with_noop(original_block.block)
|
|
|
|
|
|
|
|
noop_block.always = self._replace_with_noop(original_block.always)
|
|
|
|
|
|
|
|
noop_block.rescue = self._replace_with_noop(original_block.rescue)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return noop_block
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _prepare_and_create_noop_block_from(self, original_block, parent, iterator):
|
|
|
|
|
|
|
|
self.noop_task = Task()
|
|
|
|
|
|
|
|
self.noop_task.action = 'meta'
|
|
|
|
|
|
|
|
self.noop_task.args['_raw_params'] = 'noop'
|
|
|
|
|
|
|
|
self.noop_task.set_loader(iterator._play._loader)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return self._create_noop_block_from(original_block, parent)
|
|
|
|
|
|
|
|
|
|
|
|
def _get_next_task_lockstep(self, hosts, iterator):
|
|
|
|
def _get_next_task_lockstep(self, hosts, iterator):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Returns a list of (host, task) tuples, where the task may
|
|
|
|
Returns a list of (host, task) tuples, where the task may
|
|
|
@ -309,12 +339,6 @@ class StrategyModule(StrategyBase):
|
|
|
|
if len(included_files) > 0:
|
|
|
|
if len(included_files) > 0:
|
|
|
|
display.debug("we have included files to process")
|
|
|
|
display.debug("we have included files to process")
|
|
|
|
|
|
|
|
|
|
|
|
# A noop task for use in padding dynamic includes
|
|
|
|
|
|
|
|
noop_task = Task()
|
|
|
|
|
|
|
|
noop_task.action = 'meta'
|
|
|
|
|
|
|
|
noop_task.args['_raw_params'] = 'noop'
|
|
|
|
|
|
|
|
noop_task.set_loader(iterator._play._loader)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
display.debug("generating all_blocks data")
|
|
|
|
display.debug("generating all_blocks data")
|
|
|
|
all_blocks = dict((host, []) for host in hosts_left)
|
|
|
|
all_blocks = dict((host, []) for host in hosts_left)
|
|
|
|
display.debug("done generating all_blocks data")
|
|
|
|
display.debug("done generating all_blocks data")
|
|
|
@ -345,10 +369,7 @@ class StrategyModule(StrategyBase):
|
|
|
|
final_block = new_block.filter_tagged_tasks(play_context, task_vars)
|
|
|
|
final_block = new_block.filter_tagged_tasks(play_context, task_vars)
|
|
|
|
display.debug("done filtering new block on tags")
|
|
|
|
display.debug("done filtering new block on tags")
|
|
|
|
|
|
|
|
|
|
|
|
noop_block = Block(parent_block=task._parent)
|
|
|
|
noop_block = self._prepare_and_create_noop_block_from(final_block, task._parent, iterator)
|
|
|
|
noop_block.block = [noop_task for t in new_block.block]
|
|
|
|
|
|
|
|
noop_block.always = [noop_task for t in new_block.always]
|
|
|
|
|
|
|
|
noop_block.rescue = [noop_task for t in new_block.rescue]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for host in hosts_left:
|
|
|
|
for host in hosts_left:
|
|
|
|
if host in included_file._hosts:
|
|
|
|
if host in included_file._hosts:
|
|
|
|