处理程序未从 Ansible 中的角色调用



>我正在尝试通过调用处理程序来重新启动tomcat,我需要根据变量的条件进行调用。不知何故,它没有被调用。

- block:
- debug:
msg: "Configuration changes detected but no deployment, So proceeding with tomcat restart !!!!"
notify:
- Restart tomcat
- meta: end_play
when: config_var.changed  == true and myvm_release_version == current_release

我可以看到正在显示的消息,这意味着 when 条件满足,但在该处理程序之后没有被调用。

输出-

Sunday 31 May 2020  20:54:53 +0100 (0:00:00.084)       0:00:06.902 ************
server1 ok: {
"changed": false,
"msg": "Configuration changes detected but no deployment, So proceeding with tomcat restart !!!!"
}

你必须记住,处理程序是在剧本的最后执行的,除非它们被 meta 显式刷新。

如果需要立即执行处理程序,可以向flush_handlers添加meta

最新更新