Skip to content

Handlers are not instance-aware; multiple role invocations in one play restart the wrong recursor or skip a reload #261

Description

@SrX

Same class of problem as described for the Authoritative role. The recursor role assumes a single instance per host; invoking it multiple times in one play does not give the handlers per-instance context.

handlers/main.yml (master) restarts via a single listen topic and a flush-time-resolved service name:

- name: Restart pdns-recursor
  ansible.builtin.systemd:
    name: "{{ pdns_rec_service_name }}"
    state: restarted
  listen: restart pdns-recursor
  when: pdns_rec_service_state != 'stopped' and not pdns_rec_disable_handlers

Because handlers are global and keyed by the restart pdns-recursor topic, N notifications from N instances collapse into one run; and because {{ pdns_rec_service_name }} is resolved at flush time (outside the include scope that set it), the single restart does not necessarily target the instance that changed. Net effect: one instance restarts, the others are silently skipped.

Repro sketch: two include_role passes in one play with pdns_rec_service_name: pdns-recursor@a / ...@b, both notifying a restart; end-of-play flush restarts only one. meta: flush_handlers between passes is the current workaround.

Suggested direction: instance-scoped handler names / listen topics, or an explicit single-instance-per-play note in the README.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions