通知处理程序的顺序 [英] Order of notify handlers

查看:57
本文介绍了通知处理程序的顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个任务:

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

在Ansible剧本的文档中,有一句话:

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

通知处理程序始终按写入的顺序运行.

Notify handlers are always run in the order written.

因此,预计 daemon reload 将在 restart docker 之前运行,但是在日志中,我有:

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] *********************************
…

日志中没有"NOTIFIED HANDLER".谁能解释,我在做什么错? :(

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

推荐答案

我认为您可能在处理程序文件中的重新加载守护进程"之前列出了重新启动docker".

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

ansible文档的那一部分有点误导.这意味着处理程序是按照它们在处理程序文件中写入的顺序执行的,而不是它们被通知的顺序.

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.

这在词汇表

这篇关于通知处理程序的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆