$ command-helper

Ansible

Ad-hoc commands, running playbooks safely, inventory, vault and debugging.

Requires Google sign-in

Ad-hoc commands

Check connectivity to all hosts
ansible all -i <inventory> -m ping
Run a shell command on a group
ansible <group> -i <inventory> -m shell -a 'uptime'
Restart a service with sudo
ansible <group> -i <inventory> -b -m service -a 'name=nginx state=restarted'
Gather facts about a host
ansible <host> -i <inventory> -m setup

Playbooks

Run a playbook
ansible-playbook -i <inventory> <playbook>.yml
Dry run showing diffs
ansible-playbook -i <inventory> <playbook>.yml --check --diff
Limit to specific hosts
ansible-playbook -i <inventory> <playbook>.yml --limit <host>
Run only tasks with a tag
ansible-playbook -i <inventory> <playbook>.yml --tags <tag>
Pass extra variables
ansible-playbook -i <inventory> <playbook>.yml -e 'version=1.2.3'
List tasks without runningadvanced
ansible-playbook -i <inventory> <playbook>.yml --list-tasks
Start from a specific taskadvanced
ansible-playbook -i <inventory> <playbook>.yml --start-at-task '<task>'

Inventory

Inventory as a tree
ansible-inventory -i <inventory> --graph
All variables of a hostadvanced
ansible-inventory -i <inventory> --host <host>

Vault

Encrypt a file
ansible-vault encrypt <file>
Edit an encrypted file
ansible-vault edit <file>
Encrypt a single value for a vars fileadvanced
ansible-vault encrypt_string '<secret_value>' --name 'db_password'
Run a playbook with a vault password prompt
ansible-playbook -i <inventory> <playbook>.yml --ask-vault-pass

Debugging

Verbose output
ansible-playbook -i <inventory> <playbook>.yml -vvv
Syntax check
ansible-playbook <playbook>.yml --syntax-check
Module documentation
ansible-doc <module>