如何格式化 Ansible 输出 [英] How to format Ansible output
本文介绍了如何格式化 Ansible 输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想格式化 Ansible 输出:
I want to format Ansible output from:
my_local | SUCCESS | rc=0 >>
116G
my_local2 | SUCCESS | rc=0 >>
116G
到
my_local >> 116G
my_local2 >> 116G
有可能吗?
inventory.ini
:
my_local ansible_connection=local
my_local2 ansible_connection=local
Bash 命令:
ansible all -i inventory.ini -u root -m shell -a "df -h / | tail -1 | awk '{print $4}'"
推荐答案
要实现您想要的,您必须编写自己的 stdout 回调插件.
To achieve exactly what you want, you have to write your own stdout callback plugin.
开箱即用,有 oneline
标准输出插件,您可以使用 -o
或 --one-line
标志将其应用到ansible
可执行文件获取:
Out of the box, there is oneline
stdout plugin, you can apply it with -o
or --one-line
flag to ansible
executable to get:
my_local | SUCCESS | rc=0 | (stdout) 116G
my_local2 | SUCCESS | rc=0 | (stdout) 116G
这篇关于如何格式化 Ansible 输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文