Run a playbook
on this page
Validate, plan, check, and apply a playbook on one target. To run against many inventory hosts, see Run a playbook against remote hosts.
Prerequisites
preflightinstalled (Install Preflight)- A playbook file
- A
preflight.ymlif the playbook uses shared vars, secrets, or a default inventory
1. Validate the playbook
preflight validate playbooks/lobby.ymlvalidate parses the playbook and resolves every uses: reference. It does not contact targets or gather facts, so a valid playbook can still fail at runtime.
2. Inspect the plan
preflight plan playbooks/lobby.ymlplan prints the expanded task list in execution order, with each task’s name, module, when: expression, and tags. It does not gather facts, so {{ facts.* }} expressions stay unrendered.
3. Dry-run with check
preflight check playbooks/lobby.ymlcheck connects to the target, gathers facts, renders templates, and evaluates when: conditions. No module changes anything.
4. Apply the playbook
preflight apply playbooks/lobby.ymlPreflight stops a target at its first failed task. Set ignore_errors: true on a task to keep going past it. With several targets, --fail-fast stops every target on the first failure.
Override variables
Pass -e/--var to plan, check, or apply. The flag is repeatable and takes precedence over every other variable source.
preflight apply playbooks/lobby.yml \
-e content_root='C:\Exhibits\Content' \
-e app_env=productionSee Variable merge order for the full precedence chain.
Run a subset of tasks
Run only tasks with the given tags:
preflight apply playbooks/lobby.yml --tags kiosk,displaySkip tasks with a tag:
preflight apply playbooks/lobby.yml --skip-tags rebootplan lists every task regardless of tags. check and apply report filtered tasks as skipped.
Control output
--output text|tui|json selects the renderer. Interactive terminals default to tui; other output defaults to text. --verbose shows captured output for every task, not only failed ones.
Troubleshooting
A uses: reference fails to resolve
Preflight resolves actions in this order:
- Embedded stdlib (
preflight/...) ./actionsin the project- The cache at
~/.preflight/actions - Git, for remote refs not yet cached
check, apply, and stage fetch missing remote refs before running. validate and plan read only the cache, so fetch a new ref first:
preflight action fetch github.com/myorg/actions/signage@v2.1