In Ubuntu 20.04 and Ansible version 2.9, using Ansible ad-hoc command like:
ansible all -m shell -a "df -h"
will print like below
app2 | CHANGED | rc=0 >>
Filesystem Size Used Avail Use% Mounted on
devtmpfs 215M 0 215M 0% /dev
tmpfs 233M 0 233M 0% /dev/shm
tmpfs 233M 6.3M 227M 3% /run
tmpfs 233M 0 233M 0% /sys/fs/cgroup
/dev/mapper/cl-root 52G 2.7G 50G 6% /
/dev/sda1 1014M 198M 817M 20% /boot
/dev/mapper/cl-home 26G 213M 26G 1% /home
tmpfs 47M 0 47M 0% /run/user/1000
app1 | CHANGED | rc=0 >>
Filesystem Size Used Avail Use% Mounted on
devtmpfs 215M 0 215M 0% /dev
tmpfs 233M 0 233M 0% /dev/shm
tmpfs 233M 6.3M 227M 3% /run
tmpfs 233M 0 233M 0% /sys/fs/cgroup
/dev/mapper/cl-root 52G 2.7G 50G 6% /
/dev/sda1 1014M 198M 817M 20% /boot
/dev/mapper/cl-home 26G 213M 26G 1% /home
tmpfs 47M 0 47M 0% /run/user/1000
db1 | CHANGED | rc=0 >>
Filesystem Size Used Avail Use% Mounted on
devtmpfs 215M 0 215M 0% /dev
tmpfs 233M 0 233M 0% /dev/shm
tmpfs 233M 6.3M 227M 3% /run
tmpfs 233M 0 233M 0% /sys/fs/cgroup
/dev/mapper/cl-root 52G 3.0G 49G 6% /
/dev/sda1 1014M 198M 817M 20% /boot
/dev/mapper/cl-home 26G 213M 26G 1% /home
tmpfs 47M 0 47M 0% /run/user/1000
But what I want to have is every node result split like below, node results with new line
app2 | CHANGED | rc=0 >>
Filesystem Size Used Avail Use% Mounted on
devtmpfs 215M 0 215M 0% /dev
tmpfs 233M 0 233M 0% /dev/shm
tmpfs 233M 6.3M 227M 3% /run
tmpfs 233M 0 233M 0% /sys/fs/cgroup
/dev/mapper/cl-root 52G 2.7G 50G 6% /
/dev/sda1 1014M 198M 817M 20% /boot
/dev/mapper/cl-home 26G 213M 26G 1% /home
tmpfs 47M 0 47M 0% /run/user/1000
app1 | CHANGED | rc=0 >>
Filesystem Size Used Avail Use% Mounted on
devtmpfs 215M 0 215M 0% /dev
tmpfs 233M 0 233M 0% /dev/shm
tmpfs 233M 6.3M 227M 3% /run
tmpfs 233M 0 233M 0% /sys/fs/cgroup
/dev/mapper/cl-root 52G 2.7G 50G 6% /
/dev/sda1 1014M 198M 817M 20% /boot
/dev/mapper/cl-home 26G 213M 26G 1% /home
tmpfs 47M 0 47M 0% /run/user/1000
db1 | CHANGED | rc=0 >>
Filesystem Size Used Avail Use% Mounted on
devtmpfs 215M 0 215M 0% /dev
tmpfs 233M 0 233M 0% /dev/shm
tmpfs 233M 6.3M 227M 3% /run
tmpfs 233M 0 233M 0% /sys/fs/cgroup
/dev/mapper/cl-root 52G 3.0G 49G 6% /
/dev/sda1 1014M 198M 817M 20% /boot
/dev/mapper/cl-home 26G 213M 26G 1% /home
tmpfs 47M 0 47M 0% /run/user/1000
While learning Ansible in CentOS 8.4, I've never bothered this output things. But back in Ubuntu I found that if every output result stuck together it is hard to view. Please help me to resolve this 'bother thing'.
My ansible.cfg
[defaults]
inventory = hosts.ini
interpreter_python = /usr/libexec/platform-python
My inventory
file content
# Application servers
[app]
app1
app2
# Database servers
[db]
db1
# Group 'multi' with all servers
[multi:children]
app
db
# Variables that will be applied to all servers
[multi:vars]
ansible_user = vagrant
ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key
I hope all this detail can help people to debug and find the right answer for me, many thanks.