Yash Verma / Cloud runbook

Ansible commands

13 commands from the cloud runbook. Fill in a placeholder once and every command uses it.

Ping all hosts

Verifies connectivity and python availability on all inventory hosts.

ansible all -m ping -i inventory.ini

ping, connectivity

Playbook dry run

Runs a playbook in check mode to see what would change without actually changing anything.

ansible-playbook playbook.yml --check --diff

playbook, dry-run

Gather facts from host

Collects system information (facts) from a specific host.

ansible <hostname> -m setup

facts, system

Run ad-hoc command

Executes a one-off shell command on all hosts.

ansible all -m shell -a 'uptime' -i inventory.ini

ad-hoc, shell

Encrypt a file with Ansible Vault

Encrypts a sensitive file (like secrets.yml) using Ansible Vault.

ansible-vault encrypt secrets.yml

vault, encrypt, secrets

View an Ansible Vault file

Decrypts and displays the contents of a vault-encrypted file.

ansible-vault view secrets.yml

vault, decrypt, view

Show inventory graph

Displays the host/group structure of your inventory as a tree.

ansible-inventory --graph -i inventory.ini

inventory, graph, hosts

Run playbook with tags

Runs only the tasks tagged with a specific tag.

ansible-playbook playbook.yml --tags deploy

playbook, tags, selective

Install a collection from Ansible Galaxy

Installs a collection of modules and plugins from Ansible Galaxy.

ansible-galaxy collection install community.general

galaxy, collections

Lint playbooks

Checks playbooks for best practices and potential issues.

ansible-lint playbook.yml

lint, best-practices

Run a playbook against one host

Runs a playbook only on the hosts or groups you name.

ansible-playbook playbook.yml -i inventory.ini --limit <host>

limit, playbook

Resume a playbook at a task

Starts a playbook at the named task and asks before running each one.

ansible-playbook playbook.yml -i inventory.ini --start-at-task "<task-name>" --step

playbook, debug

Encrypt a single variable with Vault

Reads a value from stdin (finish with Ctrl+D) and prints an encrypted variable to paste into a vars file.

ansible-vault encrypt_string --stdin-name '<variable-name>'

vault, secrets