Run Ansible playbooks to automate multi-host configuration.
high risk
ansible-playbook site.yml --check --diff --limit <host>Dry-run on a single host.ansible-playbook site.yml --list-hostsSee which hosts would be targeted.ansible-playbook executes YAML playbooks that define desired state across managed hosts. Supports tags for selective execution, limits for targeting host subsets, and check mode for dry-run previews. The --diff flag shows exactly what files will change.
| Flag | Meaning |
|---|---|
-i --inventory | Inventory file or directory |
--check | Dry run — don't make changes |
--diff | Show diffs of changed files |
--limit | Limit execution to specific hosts/groups |
--tags | Only run tasks with these tags |
--skip-tags | Skip tasks with these tags |
-v/-vv/-vvv | Verbosity levels |
ansible-playbook site.yml -i inventory.ini --check --diffDry run with diff output · explain & risk-check →ansible-playbook deploy.yml -i prod-inventory.ini --limit webserversRun against webservers group only · explain & risk-check →ansible-playbook site.yml --tags nginx,sslRun only nginx and ssl tasks · explain & risk-check →ansible-playbook site.yml -e 'app_version=1.2.3'Override variable from command line · explain & risk-check →Always run with `--check --diff` before the real run in production — it shows exactly what would change without risk. Add this as a required CI step before any production ansible run.
Reference text is hand-written and may be incomplete — check man ansible-playbook for your version. Test destructive commands on a non-production system first.