# calling handler if package has been updated

**URL:** <https://forum.ansible.com/t/calling-handler-if-package-has-been-updated/34407>\
**Category:** Ansible Project\
**Created:** [January 7, 2021, 1:07pm UTC](https://forum.ansible.com/t/calling-handler-if-package-has-been-updated/34407 "2021-01-07T13:07:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Axel\_Rau](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Axel\_Rau](https://forum.ansible.com/u/Axel_Rau)\
**Post date:** [January 7, 2021, 1:07pm UTC](https://forum.ansible.com/t/calling-handler-if-package-has-been-updated/34407/1 "2021-01-07T13:07:58Z")

</div>

Hi,

in a role, I have:

- name: Install packages, needed for named  
&nbsp;&nbsp;pkgng:  
&nbsp;&nbsp;&nbsp;&nbsp;name: "{{ lr\_bind9\_pkg }}"  
&nbsp;&nbsp;&nbsp;&nbsp;state: latest  
&nbsp;&nbsp;&nbsp;&nbsp;register: testresult

I want to trigger a reload of named, if pkgng has changed something.  
As pkgng does not have a notify attribute, I tried:

- name schedule reload if pkg installed/upgraded  
&nbsp;&nbsp;notify Restart named  
&nbsp;&nbsp;&nbsp;&nbsp;when: testresult.changed

But notify does not allow „when“.

What is the solution for my problem?

Axel

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [January 7, 2021, 1:18pm UTC](https://forum.ansible.com/t/calling-handler-if-package-has-been-updated/34407/2 "2021-01-07T13:18:23Z")

</div>

> Hi,
> 
> in a role, I have:
> 
> - name: Install packages, needed for named  
> &nbsp;&nbsp;pkgng:  
> &nbsp;&nbsp;&nbsp;&nbsp;name: "{{ lr\_bind9\_pkg }}"  
> &nbsp;&nbsp;&nbsp;&nbsp;state: latest  
> &nbsp;&nbsp;&nbsp;&nbsp;register: testresult
> 
> I want to trigger a reload of named, if pkgng has changed something.  
> As pkgng does not have a notify attribute, I tried:
> 
> - name schedule reload if pkg installed/upgraded  
> &nbsp;&nbsp;notify Restart named  
> &nbsp;&nbsp;&nbsp;&nbsp;when: testresult.changed
> 
> But notify does not allow „when“.
> 
> What is the solution for my problem?

Hello Axel,

as far as I know "notify" is a generic task parameter and not related to the module you are using.

The same goes for register.

- name: Install packages, needed for named  
&nbsp;&nbsp;pkgng:  
&nbsp;&nbsp;&nbsp;&nbsp;name: "{{ lr\_bind9\_pkg }}"  
&nbsp;&nbsp;&nbsp;&nbsp;state: latest  
&nbsp;&nbsp;register: testresult  
&nbsp;&nbsp;notify: reload named

Or you add a "service" task which ensures that named is restarted.

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Axel\_Rau](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Axel\_Rau](https://forum.ansible.com/u/Axel_Rau)\
**Post date:** [January 7, 2021, 3:32pm UTC](https://forum.ansible.com/t/calling-handler-if-package-has-been-updated/34407/3 "2021-01-07T15:32:08Z")

</div>

Hello Racke,

> as far as I know “notify” is a generic task parameter and not related to the module you are using.

Ah, yes, as task parameter, it works:

- name: Install packages, needed for named  
pkgng:  
name: “{{ lr\_bind9\_pkg }}”  
state: latest  
notify:  
Restart named

Thanks, Axel
