# Notify service restart before executing next playbook action

**URL:** <https://forum.ansible.com/t/notify-service-restart-before-executing-next-playbook-action/12615>\
**Category:** Ansible Project\
**Created:** [April 2, 2013, 7:24am UTC](https://forum.ansible.com/t/notify-service-restart-before-executing-next-playbook-action/12615 "2013-04-02T07:24:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TextEditor](https://avatars.discourse-cdn.com/v4/letter/t/a88e57/32.png) [@TextEditor](https://forum.ansible.com/u/TextEditor)\
**Post date:** [April 2, 2013, 7:24am UTC](https://forum.ansible.com/t/notify-service-restart-before-executing-next-playbook-action/12615/1 "2013-04-02T07:24:03Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![benno\_joy](https://avatars.discourse-cdn.com/v4/letter/b/73ab20/32.png) [@benno\_joy](https://forum.ansible.com/u/benno_joy)\
**Post date:** [April 2, 2013, 7:39am UTC](https://forum.ansible.com/t/notify-service-restart-before-executing-next-playbook-action/12615/2 "2013-04-02T07:39:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [April 2, 2013, 12:25pm UTC](https://forum.ansible.com/t/notify-service-restart-before-executing-next-playbook-action/12615/3 "2013-04-02T12:25:34Z")

</div>

Why not make the mail a handler also?

Brian Coca

---

<div class="post-metadata">

**Author:** ![TextEditor](https://avatars.discourse-cdn.com/v4/letter/t/a88e57/32.png) [@TextEditor](https://forum.ansible.com/u/TextEditor)\
**Post date:** [April 2, 2013, 6:00pm UTC](https://forum.ansible.com/t/notify-service-restart-before-executing-next-playbook-action/12615/4 "2013-04-02T18:00:26Z")

</div>

Because I always want the mail, not only when the postfix config changed…

---

<div class="post-metadata">

**Author:** ![TextEditor](https://avatars.discourse-cdn.com/v4/letter/t/a88e57/32.png) [@TextEditor](https://forum.ansible.com/u/TextEditor)\
**Post date:** [April 2, 2013, 6:00pm UTC](https://forum.ansible.com/t/notify-service-restart-before-executing-next-playbook-action/12615/5 "2013-04-02T18:00:49Z")

</div>

This is a good idea. Thanks!
