ansible-playbook
Execute Ansible playbooks
TLDR
SYNOPSIS
ansible-playbook [-i inventory] [-e vars] [--tags tags] [options] playbook.yml
DESCRIPTION
ansible-playbook executes Ansible playbooks, which are YAML files defining automation tasks. Playbooks can provision servers, deploy applications, configure services, and orchestrate complex multi-tier deployments.Unlike ad-hoc ansible commands, playbooks define complete automation workflows with variables, conditionals, loops, and handlers.
PARAMETERS
-i inventory, --inventory inventory
Inventory file/path or comma-separated host list-e vars, --extra-vars vars
Extra variables (key=value, YAML/JSON, or @file.yml)-t tags, --tags tags
Run only plays and tasks tagged with these values--skip-tags tags
Skip plays and tasks whose tags match these values-b, --become
Run with privilege escalation (become)-K, --ask-become-pass
Prompt for privilege escalation password-C, --check
Dry run without making changes-D, --diff
Show differences in changed files (works with --check)-l hosts, --limit hosts
Further limit selected hosts to an additional pattern--list-tasks
List all tasks that would be executed--list-tags
List all available tags-f forks, --forks forks
Number of parallel processes (default: 5)--start-at-task task
Start the playbook at the task matching this name--step
Confirm each task before running--syntax-check
Check the playbook syntax without executing it--flush-cache
Clear the fact cache for every host in inventory
CONFIGURATION
/etc/ansible/ansible.cfg
System-wide Ansible configuration, including default inventory, forks, and connection settings.~/.ansible.cfg
Per-user Ansible configuration overriding system defaults.ansible.cfg
Project-level configuration in the current directory, highest priority./etc/ansible/hosts
Default inventory file used when no inventory is specified.
CAVEATS
Playbook syntax errors fail fast; use --syntax-check first. Check mode may not work perfectly with all modules. Always test in non-production first.
HISTORY
ansible-playbook has been the primary execution method for Ansible automation since the project's creation in 2012, enabling infrastructure as code and declarative automation.
SEE ALSO
ansible(1), ansible-vault(1), ansible-lint(1), ansible-galaxy(1)