> A possible workaround would be to make a somewhat non-idiomatic version
of 'handlers' by putting the tasks that restart the services in a separate
play in the end of your playbook with serial: 1. This will cause these
tasks to run one after the other. You would also have 'when' conditionals
on these tasks checking whether any other tasks that should cause restart
of services have actually made changes. Last, if you need to add a delay
between the restarts, you can use the 'wait_for' directive on the tasks
restarting the services.

On the template task, register a variable that says to restart the service,
then at the end of the play I could use the at module to set a service
restart for sometime in the future.

So, handlers seem like they are just special tasks that you can call with
the "notify" option. If that's the case, couldn't I just make a handler
that uses the at module instead of the service module? Actually, I think
I've done that already in a differen role.. Hmm...


What about adjusting how far into the future the at module should run
restart the service? As in, for the first node done, it would be right
away, for the next 5 minutes from now, for the next 10 minutes from now,
and so on. Can I register a variable and then add to it?



> You could also set a simple play like this, which would probably be
cleaner:
>
> - hosts: blarg
>   serial: 1
>   tasks:
>     - pause: seconds={{ n }}
>     - service: name=foo state=restarted

I did think of something like that, but then my playbook would end up
waiting that long to be finished, and I'm not sure how to get the rolling
restarts I want.

Hmm... Maybe waiting to end the playbook is actually a good thing. I'll
have to think about it.

--David Reagan


On Thu, Jul 24, 2014 at 6:38 AM, Michael Peters <michael00pet...@gmail.com>
wrote:

> On Thu, Jul 24, 2014 at 7:00 AM, Michael DeHaan <mich...@ansible.com>
> wrote:
>
> > You could also set a simple play like this, which would probably be
> cleaner:
> >
> > - hosts: blarg
> >   serial: 1
> >   tasks:
> >     - pause: seconds={{ n }}
> >     - service: name=foo state=restarted
>
> Is there a way to do something like this as a handler? I think that's
> the main problem here is that a configuration change should trigger a
> restart handler, but right now there's no way to throttle/serialize
> the execution of that handler. Unless I'm missing something...
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ansible-project/SBo2dPYNuGI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAJQqANe3_nycqbbpcRTEjwck1%2BcmaDQBd3cFgzW6-Y7EphuYKg%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CANo%2B_AeiqjkiD%2BM-x6XHLrMTXfEVcLmUpej7kaVe51b4H84xuA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to