Skip to content

Instantly share code, notes, and snippets.

@arlando
Last active March 11, 2017 18:55
Show Gist options
  • Select an option

  • Save arlando/c2733b2ffc097b341d0fad18712118de to your computer and use it in GitHub Desktop.

Select an option

Save arlando/c2733b2ffc097b341d0fad18712118de to your computer and use it in GitHub Desktop.
Ansible cheat sheet

Notes from Ansible

List All Hosts in the Inventory File

A quick way to get a list of all the servers Ansible is aware of:

ansible -i hosts all --list-hosts

Execute Arbitrary Commands On Servers

Execute a command on a particular group in your Inventory File:

ansible -i hosts GROUP -m shell -a "uptime" For example, execute a command on all servers:

ansible -i hosts all -m shell -a "uptime" --user remote --sudo Another example, execute a command on servers in group chicago:

ansible -i hosts chicago -m shell -a "uptime" --user remote --sudo Execute a command on one server in your Inventory File:

ansible -i hosts HOSTNAME -m shell -a "uptime" For example, execute a command on server1.example.com:

ansible -i hosts server1.example.com -m shell -a "uptime" --user remote --sudo

ansible -i hosts all -m setup

https://gist.github.com/MrNice/89a3bbe44e218c9d2309

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment