Getting handlers to run in-between roles

633 views
Skip to first unread message

Toby Wintermute

unread,
Jun 2, 2015, 4:28:27 AM6/2/15
to ansible...@googlegroups.com
Hi,
I must be doing something wrong, but I don't understand what.
I want notified handlers to run between one role and the next. From reading other posts here, it seems that is how it is supposed to work, but it's not what I'm seeing.

A simplified version of my playbook layout is like this:


playbook.yml - this contains one role, Wholemeal.

Wholemeal/meta/main.yml -- this contains one role as a dependency, Sourdough.
Wholemeal/tasks/main.yml -- this contains some stuff that won't work until the Sourdough handler, below, has restarted something.

Sourdough/tasks/main.yml -- installs a configuration, notifies a service to restart.
Sourdough/handlers/main.yml -- has the notify handler to restart the service


When I run ansible-playbook playbook.yml, I see it run the Sourdough tasks first, then immediately the Wholemeal tasks, and only after them does it run the Sourdough-notified handler :(


Is there a way to get this handler to run between the two roles?
Keeping in mind that I only want to run it if the config file was changed, not *every* time...



Thanks in advance,
Toby

Brian Coca

unread,
Jun 2, 2015, 9:52:19 AM6/2/15
to ansible...@googlegroups.com
last task in each role:

meta: flush-handlers
> --
> 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/0dbeb87d-0c99-4642-8752-6184cc54fadb%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca

Toby Corkindale

unread,
Jun 2, 2015, 8:43:39 PM6/2/15
to ansible...@googlegroups.com
Hi
That didn't work, but you put me on the right path -- it needed to be
meta: flush_handlers
(note underscore instead of dash)

Thanks, appreciate the help,
Toby

Brian Coca

unread,
Jun 2, 2015, 11:42:21 PM6/2/15
to ansible...@googlegroups.com
sorry for mislead, I need to have my email clients start validating my
code blurbs.
> --
> 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/CABEgq96nCjGwRsb_2m4vawQOVJiDODr9VQBV5qA31uHBQ2BmnA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages