LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

ansible-playbook

Execute Ansible playbooks

TLDR

Run a playbook
$ ansible-playbook [playbook.yml]
copy
Run with inventory file
$ ansible-playbook -i [inventory.ini] [playbook.yml]
copy
Run with sudo
$ ansible-playbook [playbook.yml] --become --ask-become-pass
copy
Check mode (dry run)
$ ansible-playbook [playbook.yml] --check
copy
Run specific tags
$ ansible-playbook [playbook.yml] --tags "[deploy,config]"
copy
Pass extra variables
$ ansible-playbook [playbook.yml] -e "env=production version=1.2.3"
copy

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.

INSTALL

sudo dnf install ansible-core
copy
sudo pacman -S ansible-core
copy
sudo apk add ansible-core
copy
sudo zypper install ansible-core
copy

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

RESOURCES

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid