2025-03-14 21:59:59 -06:00
|
|
|
# ansible-playbook
|
|
|
|
|
|
|
|
|
|
> Execute tasks defined in playbook on remote machines over SSH.
|
|
|
|
|
> More information: <https://docs.ansible.com/ansible/latest/cli/ansible-playbook.html>.
|
|
|
|
|
|
|
|
|
|
- Run tasks in playbook:
|
|
|
|
|
|
|
|
|
|
`ansible-playbook {{playbook}}`
|
|
|
|
|
|
2025-04-03 20:36:56 -06:00
|
|
|
- Run tasks in playbook with custom host inventory:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-04-03 20:36:56 -06:00
|
|
|
`ansible-playbook {{playbook}} {{[-i|--inventory]}} {{inventory_file}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-04-03 20:36:56 -06:00
|
|
|
- Run tasks in playbook with extra variables defined via the command-line:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-04-03 20:36:56 -06:00
|
|
|
`ansible-playbook {{playbook}} {{[-e|--extra-vars]}} "{{variable1}}={{value1}} {{variable2}}={{value2}}"`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-04-03 20:36:56 -06:00
|
|
|
- Run tasks in playbook with extra variables defined in a JSON file:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-04-03 20:36:56 -06:00
|
|
|
`ansible-playbook {{playbook}} {{[-e|--extra-vars]}} "@{{variables.json}}"`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Run tasks in playbook for the given tags:
|
|
|
|
|
|
2025-04-03 20:36:56 -06:00
|
|
|
`ansible-playbook {{playbook}} {{[-t|--tags]}} {{tag1,tag2}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Run tasks in a playbook starting at a specific task:
|
|
|
|
|
|
|
|
|
|
`ansible-playbook {{playbook}} --start-at {{task_name}}`
|
|
|
|
|
|
|
|
|
|
- Run tasks in a playbook without making any changes (dry-run):
|
|
|
|
|
|
2025-04-03 20:36:56 -06:00
|
|
|
`ansible-playbook {{playbook}} {{[-C|--check]}} {{[-D|--diff]}}`
|