Ansible 2 cheatsheet
Ansible 2: Ad-hoc commands
6 common Ansible 2 tasks.
Ping all hosts
Test that Ansible can connect to every host in the inventory.
ansible all -i inventory.ini -m ping
Run a command on a group
Run a shell command on every host in the webservers group.
ansible webservers -i inventory.ini -m command -a "uptime"
Show a host's facts
Print the facts Ansible collects about a host.
ansible web1 -i inventory.ini -m setup
Copy a file to hosts
Copy a file with the copy module.
ansible webservers -i inventory.ini -m copy -a "src=app.conf dest=/etc/app.conf" --become
Restart a service
Restart a service on a group of hosts.
ansible webservers -i inventory.ini -m service -a "name=nginx state=restarted" --become