Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure handlers have proper parent #39426

Merged
merged 2 commits into from
Apr 27, 2018
Merged

Ensure handlers have proper parent #39426

merged 2 commits into from
Apr 27, 2018

Conversation

sivel
Copy link
Member

@sivel sivel commented Apr 27, 2018

SUMMARY

This PR ensures that handlers have the correct parent. This change does for handlers what tasks already had done.

This ensures that things like the following apply to handlers:

- import_role:
    name: thing
  delegate_to: localhost

Fixes #36518

Additionally, on a small note, task_list.extend is in place and returns nothing, don't assign to t.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME
ANSIBLE VERSION

ADDITIONAL INFORMATION

@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. labels Apr 27, 2018
@sivel
Copy link
Member Author

sivel commented Apr 27, 2018

FYI, before this change, the new integration test produces:

RUNNING HANDLER [delegated_handler : delegated assert handler] *****************
fatal: [testhost]: FAILED! => {
    "assertion": "ansible_delegated_vars is defined",
    "changed": false,
    "evaluated_to": false
}

@sivel sivel added this to In Progress in include and import issues Apr 27, 2018
@sivel sivel removed the needs_triage Needs a first human triage before being processed. label Apr 27, 2018
@sivel sivel merged commit 7db5ce2 into ansible:devel Apr 27, 2018
include and import issues automation moved this from In Progress to Done Apr 27, 2018
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this pull request May 12, 2018
* Ensure role handlers are parented correctly. Fixes ansible#36518

* Add delegate_to test for include_role handlers
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this pull request May 14, 2018
* Ensure role handlers are parented correctly. Fixes ansible#36518

* Add delegate_to test for include_role handlers
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this pull request May 14, 2018
* Ensure role handlers are parented correctly. Fixes ansible#36518

* Add delegate_to test for include_role handlers
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this pull request May 15, 2018
* Ensure role handlers are parented correctly. Fixes ansible#36518

* Add delegate_to test for include_role handlers
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this pull request May 15, 2018
* Ensure role handlers are parented correctly. Fixes ansible#36518

* Add delegate_to test for include_role handlers
@SivaKrishna05
Copy link

SivaKrishna05 commented Aug 3, 2018

This issue not resolved yet. I have been facing similar issue with both Ansible 2.6.1 and 2.6.2.
issue delegate_to not working to change the host for include_role.

- include_role:
    name: role_name
  delegate_to: hostname

I have tried same code with 2.4.3 it's working expected.

@sivel
Copy link
Member Author

sivel commented Aug 3, 2018

@SivaKrishna05 delegate_to on an include_role does nothing in Ansible 2.5+. This issue was in regards to using import_role.

Please see: https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.5.html#dynamic-includes-and-attribute-inheritance

@SivaKrishna05
Copy link

@sivel you mean to say that's expected behavior and nothing to do with next Ansible version updates

@DylanYoung
Copy link

I'm still seeing this issue on 2.6.5, but I suspect it's related to a meta: flush_handlers call after the import_role.

That is, the workflow is slightly more complex.

Does meta support delegate_to?

@DylanYoung
Copy link

Scratch that. The wrong parent is still being recorded. The import_role is nested under an include_role, if that helps :p

ilicmilan pushed a commit to ilicmilan/ansible that referenced this pull request Nov 7, 2018
* Ensure role handlers are parented correctly. Fixes ansible#36518

* Add delegate_to test for include_role handlers
@ansible ansible locked and limited conversation to collaborators Apr 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests.
Projects
Development

Successfully merging this pull request may close these issues.

import_role with delegate_to does not run handlers on the delegated to host
4 participants