Create an inventory file
host1.something
host2.something
[group1]
group1host.something
group2host.something
Run a command on all hosts
ansible -i inventory_file all -m command -a "uptime"
This specifies the inventory file (-i) run on all hosts (all) and run the command module (runs a remote command) with the module argument uptime (-a)
Run a command on all hosts simpler
ansible -i inventory_file all -a "uptime"
Same as above. Notice that the module name was not specified as the command module is used by default
Run a command on hosts in group1 with sudo
ansible -i inventory_file group1 -s -K -a "service rsyslog status"
-s Use sudo
-K ask for the sudo password (can be omitted if not required)
Copy a file to all hosts
ansible -i inventory_file all -m copy -a "src=~/.vimrc dest=~"