Quickstart
on this page
This tutorial gets a minimal Preflight project running in one sitting. You will create a project, validate it, inspect the plan, dry-run it, apply it, and confirm idempotency.
Before You Start
You need:
- A
preflightbinary installed and on yourPATH - A terminal in an empty working directory
If you still need the CLI, follow Install Preflight.
Confirm the binary is available:
preflight --version1. Create A Project Directory
mkdir -p preflight-quickstart/playbooks
cd preflight-quickstartCreate preflight.yml:
project: docs-demo
environment: development
vars:
demo_dir: "./tmp/demo"
demo_file: "./tmp/demo/hello.txt"preflight.yml is the project-level config file. In this example it only carries shared variables, but the same file also holds repo-backed secret settings when you need them later.
2. Create A Playbook
Create playbooks/quickstart.yml:
name: quickstart
description: Minimal local run
tasks:
- name: Create demo directory
directory:
path: "{{ vars.demo_dir }}"
ensure: present
- name: Write demo file
shell:
cmd: /bin/sh
args:
- -c
- printf 'Hello from Preflight\n' > "{{ vars.demo_file }}"
creates: "{{ vars.demo_file }}"This playbook uses two built-in modules:
directoryensures the directory exists.shellruns a command, but only whencreatesis missing, which makes the task naturally idempotent.
3. Validate The Input Files
Run:
preflight validate playbooks/quickstart.ymlExpected result:
OKWhy this matters:
- It proves the YAML parses.
- It catches direct
uses:resolution errors before you contact any targets. - It is the fastest way to catch structural mistakes early.
4. Inspect The Plan
Run:
preflight plan playbooks/quickstart.ymlYou should see a flattened task list. plan is intentionally pure: it expands tasks and renders whatever it can from known variables, but it does not gather facts or mutate the machine.
5. Dry-Run The Changes
Run:
preflight check playbooks/quickstart.ymlThis drives every task through the Check() side of the module contract. Nothing is changed, but you get the same planning, templating, dependency ordering, and task filtering behavior that a real run would use.
6. Apply The Playbook
Run:
preflight apply playbooks/quickstart.ymlInspect the results:
cat ./tmp/demo/hello.txt
preflight state showAt this point you have both a concrete machine change and a persisted state snapshot under state/provision.json.
7. Run It Again
Run the same command a second time:
preflight apply playbooks/quickstart.ymlThe second run should report fewer or no changes. That is the core promise of Preflight: modules report whether work is needed first, then apply only when necessary.
What You Learned
You now have a working mental model for the normal flow:
- Define shared project configuration in
preflight.yml. - Describe desired state in a playbook.
- Use
validateto catch structural issues. - Use
planto inspect what will run. - Use
checkto dry-run real execution logic. - Use
applyto converge the machine and record state.
Next Step
Move on to Run a playbook for everyday execution patterns, or jump to Playbook and action YAML reference when you need exact field names and task shapes.