mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-09 01:39:10 -07:00
Cleanup some include logic
* Properly mark hosts with failures in includes as failed * Don't send callbacks until we're sure we're done, and also fix how we increment stats so failures don't show up as ok's * Fix a bug in the include file logic where a failed include could lead to an infinite loop in the task iteration logic Fixes #12933
This commit is contained in:
parent
56b310b18d
commit
5d92b00d9c
3 changed files with 48 additions and 32 deletions
|
@ -275,25 +275,29 @@ class StrategyModule(StrategyBase):
|
|||
# list of noop tasks, to make sure that they continue running in lock-step
|
||||
try:
|
||||
new_blocks = self._load_included_file(included_file, iterator=iterator)
|
||||
|
||||
for new_block in new_blocks:
|
||||
noop_block = Block(parent_block=task._block)
|
||||
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:
|
||||
if host in included_file._hosts:
|
||||
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(play_context, task_vars)
|
||||
all_blocks[host].append(final_block)
|
||||
else:
|
||||
all_blocks[host].append(noop_block)
|
||||
|
||||
except AnsibleError as e:
|
||||
for host in included_file._hosts:
|
||||
self._tqm._failed_hosts[host.name] = True
|
||||
iterator.mark_host_failed(host)
|
||||
self._display.warning(str(e))
|
||||
self._display.error(e, wrap_text=False)
|
||||
continue
|
||||
|
||||
for new_block in new_blocks:
|
||||
noop_block = Block(parent_block=task._block)
|
||||
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:
|
||||
if host in included_file._hosts:
|
||||
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(play_context, task_vars)
|
||||
all_blocks[host].append(final_block)
|
||||
else:
|
||||
all_blocks[host].append(noop_block)
|
||||
|
||||
# finally go through all of the hosts and append the
|
||||
# accumulated blocks to their list of tasks
|
||||
for host in hosts_left:
|
||||
iterator.add_tasks(host, all_blocks[host])
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue