-
Notifications
You must be signed in to change notification settings - Fork 55
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
Consider adding the handlers in the graph #214
Comments
@sphakka I will include the handlers as the last tasks of each play to make things easier and use a special shape/color (or something like that). |
Related #214 - Add the handlers to the graph with `--show-handlers`. **This is the initial support for handlers.** They are by default added at the end of the play and roles only. This doesn't reflect Ansible behavior. - Changes the shape of the graphviz node to make it consistent with Mermaid. The tasks will be rectangle instead of `octagon`: https://graphviz.org/doc/info/shapes.html - Refactor how the node/task index are computed given we can now add handlers after all the tasks are parsed. - Add a new `display_name()` method to the node for a friendly name for the graph. This removes the of passing the `node_label_prefix` in multiple places. - Remove the class **CompositeTasksNode** as it is no longer needed anymore. - Remove the play name from the edge going from playbook to the plays. This was not consistent with the other edges.
Can you give a try to the version on the main branch |
Nice job, thanks! Now, next iteration ;-) Ideally, an arc should link the notifying task node "bar" to the handler node "quux". And, don't forget that also a handler can notify another handler. Example. The following playbook... - name: Test grapher
hosts: localhost
gather_facts: False
become: false
tasks:
- name: foo
assert: { that: true }
changed_when: true
- name: bar
assert: { that: true }
changed_when: true
notify: baz
handlers:
- name: baz
assert: { that: true }
notify: quux
changed_when: true
- name: quux
assert: { that: true } ...could be rendered as (built in mermaidchart.com) ---
config:
flowchart:
curve: bumpX
title: Ansible Playbook Grapher
---
flowchart LR
playbook_ee533f9f("playbooks/test.yml") -- 1 --> play_68c96938["Play: Test grapher (1)"]
play_68c96938 -- 1 --> task_7d159d31["[task] foo"]
play_68c96938 -- 2 --> task_8a415963["[task] bar"]
play_68c96938 -. 3 .-> handler_5c2b84f9{{"[handler] baz"}}
play_68c96938 -. 4 .-> handler_1e09d4a9{{"[handler] quux"}}
task_8a415963 --> handler_5c2b84f9
handler_5c2b84f9 --> handler_1e09d4a9
style play_68c96938 stroke:#19b374,fill:#19b374,color:#ffffff
style task_7d159d31 stroke:#19b374,fill:#ffffff
style task_8a415963 stroke:#19b374,fill:#ffffff
style handler_5c2b84f9 stroke:#19b374,fill:#ffffff,stroke-dasharray: 2
style handler_1e09d4a9 stroke:#19b374,fill:#ffffff,stroke-dasharray: 2
linkStyle 0 stroke:#19b374,color:#19b374,fill:none
linkStyle 1 stroke:#19b374,color:#19b374,fill:none
linkStyle 2 stroke:#19b374,color:#19b374,fill:none
linkStyle 3 stroke:#19b374,color:#19b374,fill:none
linkStyle 4 stroke:#19b374,color:#19b374,fill:none
linkStyle 5 stroke:#D50000,fill:none
linkStyle 6 stroke:#D50000
If you can handle that, you'll get kudos from all my students ^^ |
Welcome :-) Yeah! I wanted to add this in the initial version but I didn't do it due to the additional complexity. It's already partially implemented in the code base. My plan is to only show handlers that are referenced in the tasks. Happy to have your thoughts :-)
Haha! Now I'm interested to know your use cases of the project 👀 |
I teach a bachelor course on Cloud and IT: provisioning and deployment workflows based on Terraform and Ansible are integral parts of it. Students often struggle understanding the logic of Ansible playbooks (YAML can be a nightmare when it comes to follow the notify-handler chain), thus a visual tool would help them (and me too!) quite a lot. BTW, I stumbled on this: https://github.com/ansible/ansible-content-capture |
Yes, opening a ton of YAML is the main reasons I built this tool.
Interesting. I didn't know this project. It can make my life a lot easier if Ansible provides itself all the ASTs and objects. Will definitely take a look. |
Discussed in #212
Originally posted by sphakka December 3, 2024
Hi there,
I'm possibly missing something, but it looks like notify/handlers are ignored.
MWE:
test.yml
Notice the
notify
from taskbar
to handlerquux
.Then (expect handler to be triggered):
I'd expect grapher to show a handler node linked to its notifying task node, but
gives:
No handler shown! Is it normal?
Cheers,
^s
The text was updated successfully, but these errors were encountered: