Quickstart
on this page
In this tutorial you create a minimal Preflight project, then validate, plan, dry-run, and apply it on your own machine. A second apply shows that a converged machine needs no changes.
Before you start
You need:
- A Windows machine with
preflighton itsPATH. Without an inventory, Preflight runs against the local machine, and the local target requires Windows. - A PowerShell window in an empty working directory
On a macOS or Linux controller, skip to Manage your first Windows target, which applies a playbook to a remote Windows host.
If you still need the CLI, follow Install Preflight.
Confirm the binary runs:
preflight --version1. Create a project
mkdir preflight-quickstart\playbooks
cd preflight-quickstartCreate preflight.yml:
project: docs-demo
environment: development
vars:
demo_dir: 'C:\PreflightQuickstart'
demo_file: 'C:\PreflightQuickstart\hello.txt'preflight.yml is the project config file. Here it holds shared variables. Later it can also hold an inventory and secret settings.
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
powershell:
script: Set-Content -Path '{{ vars.demo_file }}' -Value 'Hello from Preflight'
creates: "{{ vars.demo_file }}"The playbook uses two built-in modules:
directorycreates the directory if it is missing.powershellruns the script only when thecreatespath does not exist, so the task is idempotent.
3. Validate the playbook
preflight validate playbooks/quickstart.ymlPreflight reports the playbook name, its task count, and any uses: references it resolved. Validation parses the YAML and resolves action references without contacting a target.
4. Inspect the plan
preflight plan playbooks/quickstart.ymlYou see the flattened task list. plan does not gather facts or change the machine.
5. Dry-run the changes
preflight check playbooks/quickstart.ymlcheck calls each module’s Check() and reports the directory and file as pending changes. Nothing changes yet.
6. Apply the playbook
preflight apply playbooks/quickstart.yml
Get-Content C:\PreflightQuickstart\hello.txtThe file contains Hello from Preflight.
7. Run it again
preflight apply playbooks/quickstart.ymlThis time both tasks report no change. Each module checks first and applies only when the machine differs from the playbook.
Next steps
Continue with Manage your first Windows target to add an inventory, encrypt a credential, and apply a playbook over SSH. For everyday execution options, see Run a playbook.