ansible-playbook
The command that runs a playbook, printing a banner for each play and task, a result per host, and a recap at the end.
In more detail
Useful flags include --check and --diff to preview changes, --list-hosts to see targets, -i to choose an inventory, -e to pass extra variables and --ask-become-pass to supply a sudo password. It reads ansible.cfg from the current directory first.
Example
ansible-playbook --check --diff preview.ymlRelated terms
- playbook — A YAML file containing one or more plays, which together describe the state Ansible should bring a set of hosts to.
- check mode — A rehearsal run that asks each module what it would change and stops before changing anything.
- diff mode — An option that makes modules print a before-and-after diff of each file they change, or would change in check mode.
- play recap — The summary at the end of a playbook run with one line per host counting tasks that were ok, changed, unreachable, failed, skipped, rescued and ignored.
- extra variables — Variables passed on the command line when a playbook starts, which override values from every other source.
Taught in
- Playbook Syntax And YAML — Ansible Configuration Management at Scale
- Writing Your First Playbook — Ansible Configuration Management at Scale
- Modules And Idempotency — Ansible Configuration Management at Scale
- Check Mode And Diff — Ansible Configuration Management at Scale
- Handlers And Notify — Ansible Configuration Management at Scale
- Graded On A Machine You Never Touched — RHCE in Ansible (EX294): Automate Red Hat Systems
- Exam Strategy: The First Fifteen Minutes And ansible-doc — RHCE in Ansible (EX294): Automate Red Hat Systems
- Static Inventories: Hosts, Groups And Groups Of Groups — RHCE in Ansible (EX294): Automate Red Hat Systems
- ansible.cfg: Which File Wins, And The Settings That Matter — RHCE in Ansible (EX294): Automate Red Hat Systems
- SSH Keys And An Account For Ansible — RHCE in Ansible (EX294): Automate Red Hat Systems
- Anatomy Of A Playbook: Plays, Tasks And Modules — RHCE in Ansible (EX294): Automate Red Hat Systems
- Variables And Where They Win: group_vars, host_vars And Play Vars — RHCE in Ansible (EX294): Automate Red Hat Systems
- ansible-navigator: The Settings File The Exam Reads — RHCE in Ansible (EX294): Automate Red Hat Systems
- Roles: The Directory Ansible Expects, Defaults And Handlers — RHCE in Ansible (EX294): Automate Red Hat Systems
- requirements.yml: Installing Roles And Collections — RHCE in Ansible (EX294): Automate Red Hat Systems
- Ansible Vault: Secrets Encrypted, Runs Without A Prompt — RHCE in Ansible (EX294): Automate Red Hat Systems
- Drill: People, Passwords And sudo From The Vault — RHCE in Ansible (EX294): Automate Red Hat Systems