# How to control when notify gets triggered by i.e. command

**URL:** <https://forum.ansible.com/t/how-to-control-when-notify-gets-triggered-by-i-e-command/18167>\
**Category:** Ansible Project\
**Created:** [May 6, 2015, 11:34am UTC](https://forum.ansible.com/t/how-to-control-when-notify-gets-triggered-by-i-e-command/18167 "2015-05-06T11:34:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonas\_Rottmann](https://avatars.discourse-cdn.com/v4/letter/j/e47c2d/32.png) [@Jonas\_Rottmann](https://forum.ansible.com/u/Jonas_Rottmann)\
**Post date:** [May 6, 2015, 11:34am UTC](https://forum.ansible.com/t/how-to-control-when-notify-gets-triggered-by-i-e-command/18167/1 "2015-05-06T11:34:21Z")

</div>

Hi,

I have for an example an task which enables modules in apache2 in debian with the command a2enmod.

So I have:

- name: Debian | Apache | Enable Basic Mods  
command: a2enmod {{ item }}  
with\_items:
- rewrite
- ssl  
when: “ansible\_os\_family == ‘Debian’”  
tags: apache  
notify:
- restart apache2

Now I don’t wan’t to get apache restarted every single time, only if it really enabled an module. I can handle such a task as failed with:

```auto
register: command_result
failed_when: "'Enabling module' in command_result.stderr"

```

```auto
I would need that but for success not for failing.

```

```auto
Is this possible?

```

```auto

```

```auto
thanks

```

```auto

```

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [May 6, 2015, 3:12pm UTC](https://forum.ansible.com/t/how-to-control-when-notify-gets-triggered-by-i-e-command/18167/2 "2015-05-06T15:12:33Z")

</div>

so you have changed\_when, which will control notify the handler, also  
you have the apache2\_module which might make this much easier.

---

<div class="post-metadata">

**Author:** ![Jonas\_Rottmann](https://avatars.discourse-cdn.com/v4/letter/j/e47c2d/32.png) [@Jonas\_Rottmann](https://forum.ansible.com/u/Jonas_Rottmann)\
**Post date:** [May 7, 2015, 6:10am UTC](https://forum.ansible.com/t/how-to-control-when-notify-gets-triggered-by-i-e-command/18167/3 "2015-05-07T06:10:23Z")

</div>

Thanks, the changed\_when was what I was looking for.
