【发布时间】:2019-04-02 18:41:28
【问题描述】:
考虑以下 Ansible 任务:
- name: stop tomcat
gather_facts: false
hosts: pod1
pre_tasks:
- include_vars:
dir: "vars/{{ environment }}"
vars:
hipchat_message: "stop tomcat pod1 done."
hipchat_notify: "yes"
tasks:
- include: tasks/stopTomcat8AndClearCache.yml
- include: tasks/stopHttpd.yml
- include: tasks/hipchatNotification.yml
这会在 n 台服务器上停止 tomcat。我想要它做的是在它完成后发送一个 hipchat 通知。但是,此代码为任务发生的每个服务器发送单独的 hipchat 消息。这会使 hipchat 窗口充满冗余消息。在所有目标上完成 stop tomcat/stop httpd 任务后,有没有办法让 hipchat 任务发生一次?我希望任务关闭所有服务器上的 tomcat,然后发送一条时髦的聊天消息说“tomcat 在 pod 1 上停止”。
【问题讨论】:
-
run_once: true可能是你的朋友,但它(据我记得)不能用于包含。我不认为你的 hipchat yml 有这么多任务。您可能可以在那里使用它。