考虑以下 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 上停止”。