# Conditional restart

**URL:** <https://forum.ansible.com/t/conditional-restart/18141>\
**Category:** Ansible Project\
**Created:** [April 30, 2015, 12:11pm UTC](https://forum.ansible.com/t/conditional-restart/18141 "2015-04-30T12:11:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Toby\_Hobson](https://avatars.discourse-cdn.com/v4/letter/t/7993a0/32.png) [@Toby\_Hobson](https://forum.ansible.com/u/Toby_Hobson)\
**Post date:** [April 30, 2015, 12:11pm UTC](https://forum.ansible.com/t/conditional-restart/18141/1 "2015-04-30T12:11:34Z")

</div>

I have a fairly typical set of tasks, which basically ensure that given packages are installed and up to date. I can run the playbook several times and ansible is smart enough to check whether the packages are already installed before trying to install them again. Is there a way to tie in a conditional restart similar to the way salt has watches? Basically I want to restart the server only when a change has been made.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [April 30, 2015, 12:26pm UTC](https://forum.ansible.com/t/conditional-restart/18141/2 "2015-04-30T12:26:22Z")

</div>

I believe what you are looking for are handlers. See [http://docs.ansible.com/playbooks\_intro.html#handlers-running-operations-on-change](http://docs.ansible.com/playbooks_intro.html#handlers-running-operations-on-change)

It allows you to define a task (handler) which can be notified to run by another task that returns a change.
