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

Included handlers can be notified, but only by the included code #2316

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from

Conversation

kpinc
Copy link

@kpinc kpinc commented Dec 25, 2024

The old text can easily be (mis)read as: "Cannot trigger handlers (from) within includes".

The old text can easily be (mis)read as: "Cannot trigger handlers
(from) within includes".
@ansible-documentation-bot ansible-documentation-bot bot added the new_contributor This PR is the first contribution by a new community member. label Dec 25, 2024
@ansible-documentation-bot
Copy link
Contributor

Thanks for your Ansible docs contribution! We talk about Ansible documentation on Matrix at #docs:ansible.im if you ever want to join us and chat about the docs! We meet on Matrix every Tuesday. See the Ansible calendar for meeting details. We welcome additions to our weekly agenda items too. You can add the dawgs-meeting tag to a forum topic to bring it up at the next meeting.


Notifying handlers Cannot trigger handlers within includes Can trigger individual imported handlers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kpinc The original phrasing seems correct to me. Can you provide examples of what behavior are you referring to?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. In a role I have:

 role/
   tasks/
       main.yaml
       included.yaml
   handlers/
      main.yaml

main.yaml then includes included.yaml, which notifies a handler in handlers/main.yaml. And it works.

Look what I have done. I have literally "triggered a handler within an include". The included code caused a handler to execute. There is no other way to describe what happened than "triggering a handler within an include". But the text says I can't do this.

Point being, the text is vague and can be interpreted multiple ways. It means to say that you cannot trigger a handler that is declared within an included file. But that's not what it says. And, of course, you are allowed to trigger a handler from within an include. But it does not say that this is allowed.

The text needs refinement. My change takes of no more room than the original, at least as my browser renders. And I believe what I've written clarifies things.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Do you think Cannot notify handlers defined within includes or to be consistent with the statement about imports: Cannot notify individual included handlers be better?

@kpinc
Copy link
Author

kpinc commented Feb 28, 2025 via email

@kpinc
Copy link
Author

kpinc commented Feb 28, 2025 via email

@kpinc
Copy link
Author

kpinc commented Feb 28, 2025 via email

@mkrizek
Copy link
Contributor

mkrizek commented Mar 3, 2025

Thinking about it, I prefer "declare" to "define".

"define" is what is used in docs/docsite/rst/playbook_guide/playbooks_handlers.rst.

... You can do, say, an import-playbook

import_playbook cannot be used as a handler.

... included code ...

I am not sure "included code" is established terminology.

"Cannot notify handlers declared within included code,
unless such notification is done within the included code"

I think we need to step back here. The existing text:

Cannot trigger handlers within includes Can trigger individual imported handlers

refers to the situation where include_tasks or import_tasks is being used as a handler. The behavior is already described in https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_handlers.html#includes-and-imports-in-handlers. So unless we are able to describe it in short we might want to just link to that section of the handlers documentation.

@kpinc
Copy link
Author

kpinc commented Mar 3, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new_contributor This PR is the first contribution by a new community member.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants