Notify service restart before executing next playbook action

2,659 views
Skip to first unread message

TextEditor

unread,
Apr 2, 2013, 3:24:03 AM4/2/13
to ansible...@googlegroups.com
My Postfix playbook sends a test email via the mail module. However this fails because postfix has not reloaded the configuration. I now have a manual service restart action in the playbook, however I was wondering if it is possible to have a notify handler executed during a playbook, not at the end of a playbook?

benno joy

unread,
Apr 2, 2013, 3:39:11 AM4/2/13
to ansible...@googlegroups.com
I am not sure if notifiers can be executed during a playbook execution, but i think the manual service restart action can be made conditional based on a particluar action. So for example the task that updates the configuration can be registered and the service restart task can be triggered when the configuration task has changed .

task:
- name: update the postfix conf
  template: src=/foo dest=/bar
  register: result

- name: restart postfix
  service: name=postfix state=reloaded
  when_changed: $result


would this help, if idempotent task was the concern.


Benno



 


On Tue, Apr 2, 2013 at 12:54 PM, TextEditor <ma...@raymii.org> wrote:
My Postfix playbook sends a test email via the mail module. However this fails because postfix has not reloaded the configuration. I now have a manual service restart action in the playbook, however I was wondering if it is possible to have a notify handler executed during a playbook, not at the end of a playbook?

--
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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Brian Coca

unread,
Apr 2, 2013, 8:25:34 AM4/2/13
to ansible...@googlegroups.com

Why not make the mail a handler also?

Brian Coca

TextEditor

unread,
Apr 2, 2013, 2:00:26 PM4/2/13
to ansible...@googlegroups.com
Because I always want the mail, not only when the postfix config changed...

Op dinsdag 2 april 2013 14:25:34 UTC+2 schreef Brian Coca het volgende:

TextEditor

unread,
Apr 2, 2013, 2:00:49 PM4/2/13
to ansible...@googlegroups.com
This is a good idea. Thanks!

Op dinsdag 2 april 2013 09:39:11 UTC+2 schreef benno joy het volgende:
Reply all
Reply to author
Forward
0 new messages