有时主机较多时,咱们只想关注有问题的主机。html
Ansible callback 插件中有一个 actionable
,官方描述为:bash
actionable - shows only items that need attention
即只输出须要关注的部分。app
可是 callback 插件只对 playbook 生效,如何对 Ad-hoc 起做用呢?spa
参考文档:https://docs.ansible.com/ansible/2.6/plugins/callback.html#managing-adhoc插件
能够经过修改配置文件code
[defaults] bin_ansible_callbacks=True
或者修改环境变量来实现xml
export ANSIBLE_LOAD_CALLBACK_PLUGINS=1
这里咱们经过环境变量的方式来进行,这样比较轻量,无需修改文件htm
在运行 Ad-hoc 命令时,前面加上两个参数便可:教程
ANSIBLE_LOAD_CALLBACK_PLUGINS=1 ANSIBLE_STDOUT_CALLBACK=actionable
资源
完整命令以下:
ANSIBLE_LOAD_CALLBACK_PLUGINS=1 ANSIBLE_STDOUT_CALLBACK=actionable ansible all -m ping
另外,ansible 环境变量汇总见页面:https://docs.ansible.com/ansible/2.6/reference_appendices/config.html#ansible-configuration-settings
参考:
关注本公众号,后台回复「2018」便可获取传智播客 2018 最新 Python 和 Java 教程。公众号提供CSDN资源免费下载服务!