如何避免在 Ansible 中记录跳过的角色的输出



我正在使用 when 条件跳过 Ansible 中的一个角色,但在我运行剧本时它仍在打印任务。有没有办法不记录这些任务,或者如果他们正在记录,然后添加类似"跳过任务"之类的内容?

/roles/copyrepo/tasks/main.yml

---
- include: real_tasks.yml
when: temp.stat.isdir is undefined

/roles/copyrepo/tasks/real_tasks.yml

- name: Ensuring that the web deployment folder is created on nodes for each web application
file:
path: "{{release_location}}/Release{{release_version}}/{{item}}/webapp"
state: directory
mode: 0755
with_items:
- "{{ myapps }}"
- name: Copying the release war files from local server to tomcat nodes
copy: src={{local_server_release_location}}/{{release_version}}/{{item}}-{{release_version}}.war dest={{release_location}}/Release{{release_version}}/{{item}}
with_items:
- "{{ myapps }}"
- name: Overriding the directory name
command: mv /temp/myapp-web /temp/myapp

display_skipped_hosts = False在这里不起作用,因为无论是否跳过任务,任务标题仍将显示。

如何避免在输出中显示以下标题,因为它们没有被执行?

Ensuring that the web deployment folder is created on nodes for each web application...
Tuesday 02 June 2020  16:54:11 +0100 (0:00:00.216)       0:00:07.378 **********
Copying the MyVM release war files from local server to tomcat nodes...
Tuesday 02 June 2020  16:54:11 +0100 (0:00:00.204)       0:00:07.582 **********
Overriding the directory name...
Tuesday 02 June 2020  16:54:12 +0100 (0:00:00.205)       0:00:07.787 **********

如果有人可以提出建议,请告诉我。

如果您对提供的 stdout 回调插件选择不满意,那么您可以编写自己的代码,以准确显示您想要的输出,并完全按照您想要的方式格式化。据我所知,如果您想打包插件以沿着正常的剧本分发机制运行,甚至可以将它们放在每个剧本中

最新更新