feature idea: remember the notified handlers in .retry files on fail/error

if ansible fails, ansible creates a retry file. This is nice, but ansible forgets about notified handlers earlier in the play and which should have been executed at the end of the play.

What about executing the handlers even after an error or even better, remember in the retry file the handlers, which should have been executed?

So they would be executed the next time. Something like this would be great.

René

What’s the use case in which you encountered this problem?

I’m basically talking about specifics to make sure the playbook couldn’t be coded better.

For instance if your handler restarts a service, typically you need a task in there to say:

service: name=foo state=started enabled=yes

To make sure it’s running an enabled and re-running the playbook should correct the problem.

If I am reading this correctly, I would also love to see this.

For example, if I update an iptables configuration and notify “iptables reload” but the play fails before the iptables handler executes, the handler is not notified when the play is retried. The handler does not get re-notified on the next play because the configuration didn’t change on the retry play.

I’m wondering if a way to force all the handlers to fire might solve the use cases around this?

ansible-playbook foo.yml -i retry_hosts --force-handlers

?

+1 to this suggestion, it would be very helpful to me as well.

For instance if your handler restarts a service, typically you need a task
in there to say:

service: name=foo state=started enabled=yes

To make sure it's running an enabled and re-running the playbook should
correct the problem.

A common idiom is to have Ansible put a configuration file in place,
then reload/restart the service using that configuration file. You'd
have a task in there making sure it's started, but when the service is
already running in the first place, a "service: name=foo state=started
enabled=yes" would just return OK for that task, thus not correcting
the problem.

“This would work. It risks triggering more handlers than necessary, but
I’d still happily take it over keeping track of which handlers need to
be run by hand after a failure occurred.”

Can you file a feature ticket for this one?

I think it’s probably the most practical to implement.

Thanks!

Can you file a feature ticket for this one?

https://github.com/ansible/ansible/issues/4766