Ansible:当你 运行 任务时如何摆脱蓝绿色 "included: " 语句?
Ansible: How to get rid of teal "included: " statement when you run a Task?
我正试图在我的 Ansible 剧本运行中隐藏这个蓝绿色 include:
语句。似乎每次有一个包含变量的 Mode Script
时,都会出现这个蓝绿色的语句。非常感谢能够隐藏它的任何帮助。非常感谢!
Photo: Include statement
这些行由回调插件的 v2_playbook_on_include
方法打印。
这是默认标准输出插件的查找方式:
def v2_playbook_on_include(self, included_file):
msg = 'included: %s for %s' % (included_file._filename, ", ".join([h.name for h in included_file._hosts]))
self._display.display(msg, color=C.COLOR_SKIP)
如果你需要省略这个,要么使用 less "talkative" stdout 回调插件(例如 actionable
),要么编写你自己的具有所需功能的 stdout 插件。
测试其他回调的简单方法:
$ ANSIBLE_STDOUT_CALLBACK=actionable ansible-playbook myplaybook.yml
我选择了一个非常简单的解决方案,但它有效:
ansible-playbook main.yml | grep -v --line-buffered '^included:'
因为我使用 gitlab-ci 来 运行 剧本,所以我可以很容易地在每个 运行.
中包含 grep
部分
我正试图在我的 Ansible 剧本运行中隐藏这个蓝绿色 include:
语句。似乎每次有一个包含变量的 Mode Script
时,都会出现这个蓝绿色的语句。非常感谢能够隐藏它的任何帮助。非常感谢!
Photo: Include statement
这些行由回调插件的 v2_playbook_on_include
方法打印。
这是默认标准输出插件的查找方式:
def v2_playbook_on_include(self, included_file):
msg = 'included: %s for %s' % (included_file._filename, ", ".join([h.name for h in included_file._hosts]))
self._display.display(msg, color=C.COLOR_SKIP)
如果你需要省略这个,要么使用 less "talkative" stdout 回调插件(例如 actionable
),要么编写你自己的具有所需功能的 stdout 插件。
测试其他回调的简单方法:
$ ANSIBLE_STDOUT_CALLBACK=actionable ansible-playbook myplaybook.yml
我选择了一个非常简单的解决方案,但它有效:
ansible-playbook main.yml | grep -v --line-buffered '^included:'
因为我使用 gitlab-ci 来 运行 剧本,所以我可以很容易地在每个 运行.
中包含grep
部分