2017-01-27 10:39:22 +01:00
|
|
|
# ansible-playbook
|
|
|
|
|
|
|
|
> Execute tasks defined in playbook on remote machines over SSH.
|
2019-06-03 02:06:36 +02:00
|
|
|
> More information: <https://docs.ansible.com/ansible/latest/cli/ansible-playbook.html>.
|
2017-01-27 10:39:22 +01:00
|
|
|
|
|
|
|
- Run tasks in playbook:
|
|
|
|
|
|
|
|
`ansible-playbook {{playbook}}`
|
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
- Run tasks in playbook with custom host inventory:
|
2017-01-27 10:39:22 +01:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
`ansible-playbook {{playbook}} {{[-i|--inventory]}} {{inventory_file}}`
|
2017-10-26 18:07:08 -02:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
- Run tasks in playbook with extra variables defined via the command-line:
|
2017-10-26 18:07:08 -02:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
`ansible-playbook {{playbook}} {{[-e|--extra-vars]}} "{{variable1}}={{value1}} {{variable2}}={{value2}}"`
|
2017-10-26 18:07:08 -02:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
- Run tasks in playbook with extra variables defined in a JSON file:
|
2017-10-26 18:07:08 -02:00
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
`ansible-playbook {{playbook}} {{[-e|--extra-vars]}} "@{{variables.json}}"`
|
2020-07-17 18:58:11 +02:00
|
|
|
|
|
|
|
- Run tasks in playbook for the given tags:
|
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
`ansible-playbook {{playbook}} {{[-t|--tags]}} {{tag1,tag2}}`
|
2020-07-17 18:58:11 +02:00
|
|
|
|
|
|
|
- Run tasks in a playbook starting at a specific task:
|
|
|
|
|
|
|
|
`ansible-playbook {{playbook}} --start-at {{task_name}}`
|
2024-06-05 12:18:21 +02:00
|
|
|
|
|
|
|
- Run tasks in a playbook without making any changes (dry-run):
|
|
|
|
|
2025-03-28 05:26:23 +02:00
|
|
|
`ansible-playbook {{playbook}} {{[-C|--check]}} {{[-D|--diff]}}`
|