Order of notify handlers

ansible

I have a task:

- name: uploads docker configuration file
  template:
    src: 'docker.systemd.j2'
    dest: '/etc/systemd/system/docker.service'
  notify:
    - daemon reload
    - restart docker

in Ansible playbook's documentation, there is a sentence:

Notify handlers are always run in the order written.

So, it is expected, that daemon reload will be ran before restart docker, but in logs, i have:

TASK [swarm/docker : uploads docker configuration file] ************************
…
NOTIFIED HANDLER daemon reload
NOTIFIED HANDLER restart docker
…
RUNNING HANDLER [swarm/docker : restart docker] ********************************
…
RUNNING HANDLER [swarm/docker : daemon reload] *********************************
…

There are no more "NOTIFIED HANDLER" in logs. Can anyone explain, what i'm doing wrong? 🙁

Best Answer

I think you may have “restart docker” listed before “daemon reload” in your handlers file.

That part of the ansible documentation is a bit misleading. It means that handlers are executed in the order they are written in the handlers file, not the order they are notified.

This is little more clear in the glossary

Related Topic