calling handler if package has been updated

Hi,

in a role, I have:

- name: Install packages, needed for named
  pkgng:
    name: "{{ lr_bind9_pkg }}"
    state: latest
    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
  notify Restart named
    when: testresult.changed

But notify does not allow „when“.

What is the solution for my problem?

Axel

Hi,

in a role, I have:

- name: Install packages, needed for named
  pkgng:
    name: "{{ lr_bind9_pkg }}"
    state: latest
    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
  notify Restart named
    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
  pkgng:
    name: "{{ lr_bind9_pkg }}"
    state: latest
  register: testresult
  notify: reload named

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

Regards
        Racke

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