Ensure handlers have proper parent (#39426)
* Ensure role handlers are parented correctly. Fixes #36518 * Add delegate_to test for include_role handlers
This commit is contained in:
parent
85b42a6f68
commit
7db5ce2c86
5 changed files with 16 additions and 2 deletions
|
@ -333,10 +333,10 @@ def load_list_of_tasks(ds, play, block=None, role=None, task_include=None, use_h
|
|||
|
||||
# uses compiled list from object
|
||||
blocks, _ = ir.get_block_list(variable_manager=variable_manager, loader=loader)
|
||||
t = task_list.extend(blocks)
|
||||
task_list.extend(blocks)
|
||||
else:
|
||||
# passes task object itself for latter generation of list
|
||||
t = task_list.append(ir)
|
||||
task_list.append(ir)
|
||||
else:
|
||||
if use_handlers:
|
||||
t = Handler.load(task_ds, block=block, role=role, task_include=task_include, variable_manager=variable_manager, loader=loader)
|
||||
|
|
|
@ -96,6 +96,8 @@ class IncludeRole(TaskInclude):
|
|||
|
||||
# updated available handlers in play
|
||||
handlers = actual_role.get_handler_blocks(play=myplay)
|
||||
for h in handlers:
|
||||
h._parent = self
|
||||
myplay.handlers = myplay.handlers + handlers
|
||||
return blocks, handlers
|
||||
|
||||
|
|
|
@ -136,3 +136,8 @@
|
|||
- name: Include role inside always
|
||||
import_role:
|
||||
name: role3
|
||||
|
||||
- name: Test delegate_to handler is delegated
|
||||
import_role:
|
||||
name: delegated_handler
|
||||
delegate_to: localhost
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
- name: delegated assert handler
|
||||
assert:
|
||||
that:
|
||||
- ansible_delegated_vars is defined
|
|
@ -0,0 +1,3 @@
|
|||
- command: "true"
|
||||
notify:
|
||||
- delegated assert handler
|
Loading…
Reference in a new issue