How to format Ansible output
I want to format Ansible output from:
my_local | SUCCESS | rc=0 >>
116G
my_local2 | SUCCESS | rc=0 >>
116G
to
my_local >> 116G
my_local2 >> 116G
Is it possible?
inventory.ini
my_local ansible_connection=local
my_local2 ansible_connection=local
Bash command :
ansible all -i inventory.ini -u root -m shell -a "df -h / | tail -1 | awk '{print \$4}'"
+3
source to share
1 answer
To achieve exactly what you want, you must write your own stdout callback plugin.
There is a oneline
stdout plugin out of the box , you can apply it with a flag -o
or --one-line
on an executable ansible
to get:
my_local | SUCCESS | rc=0 | (stdout) 116G
my_local2 | SUCCESS | rc=0 | (stdout) 116G
+4
source to share