What is the difference between `notify` and just a task at the end of a playbook?

67 views
Skip to first unread message

Andrew Pashkin

unread,
May 1, 2014, 5:00:18 AM5/1/14
to ansible...@googlegroups.com
Hi!
I just started to learn Ansible.
In the docs, there is such words:

These ‘notify’ actions are triggered at the end of each block of tasks in a playbook, and will only be triggered once even if notified by multiple different tasks.

For instance, multiple resources may indicate that apache needs to be restarted because they have changed a config file, but apache will only be bounced once to avoid unnecessary restarts.

Is it correct, that if I want that apache to be restarted after certain task, not after all tasks, I need to insert task with restart action, after that task?

Docs also states:
Handlers are lists of tasks, not really any different from regular tasks...

Is it all means, that there is no difference between notify and if I just put special tasks )with restarts etc) in the end of a playbook?

James Cammarata

unread,
May 1, 2014, 1:12:01 PM5/1/14
to ansible...@googlegroups.com
Handlers are typically more useful in that multiple tasks can trigger them via the notify: action, so they will only run if the task has changed. Otherwise, the task will always run and you may bounce services unnecessarily. 


--
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/954c3f78-4ee0-4cda-935f-0dd24c500ced%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages