Skip to content

Commit

Permalink
Fix include loading for handler runs
Browse files Browse the repository at this point in the history
When using the free (or host_pinned) strategy if your playbook includes
a tasks, roles and handlers, an error can occur when handlers are run
and there are included files to process. In the free.py strategy[0], when
included files are run there is an additional check to see if the
included file is a role and to process that differently than if it's an
included file.

[0] https://github.com/ansible/ansible/blob/c8704573396e7480b3e1b33b2ddda2b6325d0d80/lib/ansible/plugins/strategy/free.py#L244-L254

Resolves #69457
  • Loading branch information
mwhahaha committed May 12, 2020
1 parent aa36b02 commit b678be2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/ansible/plugins/strategy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,17 @@ def _do_handler_run(self, handler, handler_name, iterator, play_context, notifie
if len(included_files) > 0:
for included_file in included_files:
try:
new_blocks = self._load_included_file(included_file, iterator=iterator, is_handler=True)
if included_file._is_role:
ir = self._copy_included_file(included_file)
# get_block_list returns (blocks, handlers)
# and in this isntance we only care about the handler
# blocks
(_, new_blocks) = ir.get_block_list(
play=iterator._play,
variable_manager=self._variable_manager,
loader=self.loader)
else:
new_blocks = self._load_included_file(included_file, iterator=iterator, is_handler=True)
# for every task in each block brought in by the include, add the list
# of hosts which included the file to the notified_handlers dict
for block in new_blocks:
Expand Down

0 comments on commit b678be2

Please sign in to comment.