Last loaded handler with the same name wins ()

* Last loaded handler with the same name wins

* Add comment explaining reversed
This commit is contained in:
Martin Krizek 2018-11-30 16:30:27 +01:00 committed by GitHub
parent aee9209375
commit c78c8d389f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions
changelogs/fragments
lib/ansible/plugins/strategy

View file

@ -0,0 +1,2 @@
bugfixes:
- Last loaded handler with the same name is used

View file

@ -368,7 +368,8 @@ class StrategyBase:
return self._inventory.get_host(host_name)
def search_handler_blocks_by_name(handler_name, handler_blocks):
for handler_block in handler_blocks:
# iterate in reversed order since last handler loaded with the same name wins
for handler_block in reversed(handler_blocks):
for handler_task in handler_block.block:
if handler_task.name:
handler_vars = self._variable_manager.get_vars(play=iterator._play, task=handler_task)
@ -394,7 +395,8 @@ class StrategyBase:
return None
def search_handler_blocks_by_uuid(handler_uuid, handler_blocks):
for handler_block in handler_blocks:
# iterate in reversed order since last handler loaded with the same name wins
for handler_block in reversed(handler_blocks):
for handler_task in handler_block.block:
if handler_uuid == handler_task._uuid:
return handler_task