ansible fails to restart if handler is broken?

45 views
Skip to first unread message

Kevin Burton

unread,
Dec 9, 2014, 10:00:31 PM12/9/14
to ansible...@googlegroups.com
this is a bug...

TASK: [pdns-recursor | recursor.conf file] ************************************ 
changed: [10.56.252.12]
ERROR: change handler (restart pdns-recursor) is not defined


... so my issue was that the handler wasn't defined (typo).  So now it has a new file, and the daemon NEEDS to be restarted , but it isn't.

Now, when I run ansible again, it does NOT restart the daemon, because the template is already updated.  

The solution here would obviously need to restart the daemon and properly run the handler.

I think the fix is to revert the 'template' so that the previous file was used.  

Michael DeHaan

unread,
Dec 11, 2014, 11:15:55 AM12/11/14
to ansible...@googlegroups.com
Don't see how this is a bug.  Can you elaborate.

Tried --force-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/de02e7e4-b996-4f1c-b4df-0bd773512d7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael DeHaan

unread,
Dec 11, 2014, 11:57:27 AM12/11/14
to ansible...@googlegroups.com, burto...@gmail.com
No, you actually use that after.

If you had a failure and you needed a handler to run on the next run because something should have triggered but did not, you can use that flag.

The retry suggestion has been made before.


On Thu, Dec 11, 2014 at 11:54 AM, Petros Moisiadis <erne...@yahoo.gr> wrote:
On 12/11/14 18:15, Michael DeHaan wrote:
Don't see how this is a bug.  Can you elaborate.

Tried --force-handlers ?


The option --force-handlers will work only proactively. You must use it _before_ the failure occurs. However, this is almost never the case. Normally, you don't expect your playbook tasks to fail.
A much better solution would be to extend retry files to include handlers that have already been notified before the failure, so that when using the retry files, these handlers are pre-notified regardless of the results of the tasks that notify them normally. I guess that would be a nice feature for v2. :)

Kevin Burton

unread,
Dec 11, 2014, 1:58:28 PM12/11/14
to ansible...@googlegroups.com, burto...@gmail.com
Interesting.  Nice discussion. 

I think one issue is that there would be no easy way to revert tasks that fail without some type of API that instrumented changes.  Either that or have the tasks run in some sort of container that logged changes.  But of course you're not sure what type of changes to expect.  It could be a sysctl, FS changes, API call, etc.  How do you reliably roll those back?

So I guess the solution is to just be careful and know what your scripts are doing.  And maybe in the future tasks could implement a rollback API for when they fail but of course this might not be reliably supported everywhere. 

Michael DeHaan

unread,
Dec 11, 2014, 5:31:29 PM12/11/14
to ansible...@googlegroups.com, Kevin Burton
"I am afraid this is not correct. I am testing it now with 1.8.2 and I can assure you that  '--force-handlers' will not trigger a handler if that handler has not been notified by a task."

Can you please paste a minimal playbook that shows this as well as your CLI invocation?

Thanks!



--
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.
Reply all
Reply to author
Forward
0 new messages