Setup
Ansible gives you a powerful option to run commands ad-hoc. This negates the need to write a script, if you only need some quick information. There are two separate options for gathering data via ad-hoc. If you are running just a single command than use the ‘command’ module. If you need to run multiple commands, use the ‘shell’ module.
You may or may not need to reference the your inventory file, if you are using DNS names. If you are using IP addresses, then you probably do not need it.
-m = module (shell or command)
-a = argument (command you want to run on the remote system).
Run a Single Command against Multiple Hosts
ansible -i inventory.ini -m command -a 'ip a' server1,server2
Run Multiple Commands against a Single Machine
ansible -i inventory.ini -m shell -a 'hostname ; ipa | grep 10.10 ; df -h | grep /dev/mapper ; lsb_release -a' server1