📜
Ad-hoc
| Command | Description | |
|---|---|---|
ansible all -m ping -i inventory.ini | Test connectivity | |
ansible web -m apt -a "name=nginx state=present" -b -i inventory.ini | Install package on group | |
ansible web -m shell -a "uptime" -i inventory.ini | Run shell command | |
ansible-inventory -i inventory.ini --graph | Show inventory tree |
Playbooks
| Command | Description | |
|---|---|---|
ansible-playbook site.yml -i inventory.ini | Run playbook | |
ansible-playbook site.yml --check --diff | Dry run with diffs | |
ansible-playbook site.yml --limit web | Limit to host group | |
ansible-playbook site.yml -e "env=prod" | Extra variables |
Vault & facts
| Command | Description | |
|---|---|---|
ansible-vault encrypt secrets.yml | Encrypt file | |
ansible-playbook site.yml --ask-vault-pass | Run with vault password | |
ansible web -m setup -i inventory.ini | Gather facts |