ansible - ansible 中 flush_handlers 的替代方案

标签 ansible ansible-2.x

我的 Ansible 剧本中有处理程序,我想立即触发这些通知。如何在不调用 meta_handler = flush_handler 的情况下实现这一点? ?
这在 Ansible 2.5.6 中运行良好,但在此版本之后会显示一条警告:

[WARNING]: flush_handlers task does not support when conditional


任何帮助,将不胜感激。

最佳答案

这是一个 Unresolved 问题 meta: flush_handlers doesn't honor when clause #41313 .
(2021-04-20 问题仍未解决。如果状态发生变化,请在此处评论)
引用我的comment :

Let me describe a valid scenario (below). "flush_hadlers" is needed after tasks abc.yml complete and before tasks def.yml start. But the file with the tasks xyz.yml is imported when OS is RH only. Here Ansible complains:

[WARNING]: flush_handlers task does not support when conditional
能够抑制警告会很好。
# cat xyz.yml
- include_tasks: abc.yml
- meta: flush_handlers
- include_tasks: def.yml

# cat playbook.yml
  ...
  tasks:
    - import_tasks: xyz.yml
      when: (ansible_os_family == "RedHat" )

关于ansible - ansible 中 flush_handlers 的替代方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53400555/

相关文章:

Ansible:剧本在角色目录中的目录中调用角色

java - apt_repository 模块失败

Ansible Lineinfile : Find a key and replace only the value

每个数据库名称 Ansible 运行一次任务

ssl - 带有 cacert 选项的 Ansible URI 模块

ansible - 通过 set_fact 分配的一些 float 被转换为字符串

ansible - 使用列表迭代哈希

Ansible With_Together 循环迭代

linux - 在 ansible 剧本中添加 sudo_user 会使命令永远执行

jenkins - 以 [user] 身份从 Jenkins 运行 Ansible