Notifying handler only once

82 views
Skip to first unread message

Jacob Weber

unread,
Apr 6, 2014, 5:31:07 PM4/6/14
to ansible...@googlegroups.com
Is there a way to have multiple plays call a "notify" handler, but have the handler run only once, at the end of all plays?

For example, say I have site.yml:
- include webservers.yml
- include database.yml

And in both webservers.yml and database.yml, I have a role that calls:
  notify: update load balancer

If I put an "update load balancer" handler in some common role included by both webservers.yml and database.yml, it gets called at the end of each of those two plays. I only want it to happen once, at the end of both plays.

And if I put the handler inside site.yml, it can't be found by the included plays.

Thanks.

Timur Batyrshin

unread,
Apr 8, 2014, 1:44:37 AM4/8/14
to ansible...@googlegroups.com
Hi,

But haven't got any replies to it.
And here is a bit earlier ticket with Michael's answer: https://github.com/ansible/ansible/issues/5634

If you find the way to solve your issue please let us know here, as I'm interested in that too.

Thanks,
Timur

понедельник, 7 апреля 2014 г., 1:31:07 UTC+4 пользователь Jacob Weber написал:

Aaron Hunter

unread,
Apr 8, 2014, 2:27:39 PM4/8/14
to ansible...@googlegroups.com
I would like the same thing. I think Ansible needs a global handler  and global notify. This would support the frequently used unix conf.d/ idiom. Right now the way I do it is with a role called "end" that does the restart. You lose idempotency because it always runs (it has to due to no global notify) but it works.

-Aaron

Michael DeHaan

unread,
Apr 9, 2014, 9:57:28 AM4/9/14
to ansible...@googlegroups.com
It's very unlikely that we are going to add a handler that spans plays, due to the way plays are modelled.

However, there are some tricks/patterns where you could create a "handler needs to run" file on the remote host, check for it with stat, and signal a handler in a final play, if you were using more than one play.


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ba3d6c35-6c73-40cb-97f1-862405d440c7%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages