Show Menu
Cheatography

Ansible Cheat Sheet (DRAFT) by

Ansible CLI Cheat Sheet

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Ansible Logo

Playbooks

ansibl­e-p­laybook <YA­ML>
# Run on all hosts defined
ansibl­e-p­laybook <YA­ML> -f 10
# Run 10 hosts parallel
ansibl­e-p­laybook <YA­ML> --verbose
# Verbose on successful tasks
ansibl­e-p­laybook <YA­ML> -C
# Test run
ansibl­e-p­laybook <YA­ML> -C -D
# Dry run
ansibl­e-p­laybook <YA­ML> -l <ho­st>
# Run on single host
ansibl­e-p­laybook <YA­ML> --list­-hosts
# List hosts
ansibl­e-p­laybook <YA­ML> --list­-tasks
# List tasks
ansibl­e-p­laybook --synt­ax-­check <YA­ML>
# Syntax check
Playbook commands
 

Remote Execution

ansible all -m ping
# Run ping module in all groups from inventory
ansible <ho­stg­rou­p> -a <co­mma­nd>
# Syntax for the arbitrary command execution
ansible all -a "­ifc­onfig -a"
# Execute 'ifconfig -a' arbitrary command in all groups
Execution of remote commands into hosts from inventory file

Debugging

ansible <ho­st> -m setup
# All facts for one host
ansible <ho­st> -m setup -a 'filte­r=a­nsi­ble­_eth*'
# Only ansible fact for one host
ansible all -m setup -a 'filte­r=f­act­er_*'
# Only facter facts but for all hosts
ansible all -m setup --tree /tmp/facts
# Save facts to per-host files in /tmp/facts
List facts and state of a host