CLI reference

on this page

Every command exits 0 on success and 1 on any error, including a failed task. The error is printed to standard error.

preflight --version prints the version, commit, and build date.

Shared flags

Each command lists the flag groups it accepts.

Targeting

FlagShortTypeDefaultDescription
--target-tstring listall inventory hosts, or the local machine without an inventoryHost names, group names, all, local, or localhost; repeat or comma-separate. See Selector resolution

Variables

FlagShortTypeDescription
--var-ekey=value, repeatableSet a variable. A value without = sets the key to an empty string. Later flags win. See Variable merge order

Tags

FlagTypeDescription
--tagsstring listRun only tasks with at least one listed tag
--skip-tagsstring listSkip tasks with any listed tag

Output

FlagShortTypeDefaultDescription
--outputtext, tui, jsontui when stdout is a terminal, else textOutput format; any other value selects text
--verbose-vboolfalseShow output of successful tasks and debug logging
--max-fail-linesint80Lines of output shown for a failed task; 0 is unlimited
--colorauto, always, neverautoColor output
--no-colorboolfalseDisable color; overrides --color

Run

FlagTypeDefaultDescription
--fail-fastboolfalseStop all targets on the first failure
--run-idstringgeneratedRun identifier and run directory name
--keep-runsint20Number of run directories with a run.json to keep under .preflight/runs/; 0 disables pruning

Concurrency and timeout

FlagTypeDefaultDescription
--concurrencyint0Maximum targets in parallel; 0 is unlimited; negative values fail
--timeoutGo durationnoneOverall timeout, such as 30m or 1h

Run commands

preflight apply <playbook>

Plans and applies a playbook on each selected target. Fetches uncached remote action refs first.

Flags: targeting, variables, tags, output, run, concurrency and timeout, plus:

FlagTypeDescription
--bundlepathApply a staged bundle instead of a playbook; see Bundle apply
--secret-identitypathage identity file for encrypted bundle secrets; requires --bundle
bash
preflight apply playbooks/lobby.yml --target lobby
preflight apply --bundle dist/bundles/<bundle>.zip

Errors:

  • apply: playbook path and --bundle cannot be used together
  • apply: --secret-identity requires --bundle
  • apply: expected exactly one playbook path

preflight check <playbook>

Runs the apply pipeline as a dry run: each module runs Check() only and reports the changes it would make.

Flags: targeting, variables, tags, output, run, concurrency and timeout.

preflight stage <playbook>

Writes one bundle zip per selected target. See Bundle reference.

Flags: targeting, variables, tags, output, run, concurrency and timeout, plus:

FlagTypeDefaultDescription
--bundle-output-dirpath<project>/dist/bundlesDirectory for bundle zips
--allow-plaintext-secrets-in-bundleboolfalseWrite resolved secrets into the bundle in plaintext

A host with platform is staged without a connection.

preflight plan <playbook>

Prints the execution plan for each selected target without connecting to it. Unknown facts, target, and env placeholders stay unrendered. Does not fetch remote action refs; an uncached ref fails.

Flags: targeting, variables, tags, output, timeout.

preflight validate <playbook>

Parses the playbook and resolves every uses ref, including refs inside actions. Does not connect to targets or fetch remote refs.

Flags: output.

preflight facts [target...]

Gathers facts from each selected target. Positional targets and --target values are combined. Reads preflight.yml and discovers plugins from the working directory.

Flags: targeting, output, concurrency and timeout. --tags and --skip-tags fail.

bash
preflight facts
preflight facts local
preflight facts lobby lobby-pc-01

In json output, each target produces one facts event.

action

action list and action info read actions/ and preflight.lock in the working directory. action fetch writes preflight.lock in the project root.

CommandDescription
preflight action listList stdlib actions and project actions under ./actions
preflight action info <ref>Print an action’s name, version, description, author, inputs, and task names; remote refs must be cached
preflight action fetch <ref>Fetch a remote ref and the remote refs it uses into ~/.preflight/actions, and record each commit SHA in the project root’s preflight.lock (the nearest parent directory with preflight.yml, preflight.lock, actions/, or .git; the working directory if none)

Flags: output.

inventory

CommandDescription
preflight inventory listList each host’s name, address, transport, port, and groups from preflight.yml in the working directory

Flags: output. tui renders as text.

Fails with inventory list: no inventory configured in preflight.yml when the file has no inventory.

plugin

CommandDescription
preflight plugin listList each discovered plugin’s name, version, status (ready or error), and path
preflight plugin info <name>Print one plugin’s name, version, path, source directory, and initialization result

plugin list accepts the output flags; tui renders as text. plugin info prints text only. Both discover ./plugins from the working directory. See Discovery.

secret

These commands read and write preflight.yml in the working directory. See Manage secrets.

preflight secret list

Lists the secrets in secrets.entries. Flags: output; tui renders as text.

preflight secret encrypt <name>

Encrypts a value to secrets.recipients and writes it to the entry’s file. A new entry is added to preflight.yml with file: secrets/<name>.age; characters other than letters, digits, ., _, and - in the file name become -.

FlagTypeDescription
--from-filepathRead the value from a file
--from-stdinboolRead the value from standard input; one trailing newline is trimmed
--recipientstring listRecipients to use instead of secrets.recipients; saved to preflight.yml
--identitypathIdentity path saved to secrets.identity

With neither source flag, the command prompts twice without echo. When standard input is not a terminal, it fails with no plaintext source: pass --from-file, --from-stdin, or run from a terminal. --from-file and --from-stdin are mutually exclusive.

Fails with secret encrypt: no recipients configured (set secrets.recipients or pass --recipient) when no recipients are set.

preflight secret edit <name>

Decrypts the secret to a temporary file, opens it in $EDITOR, and re-encrypts the result. EDITOR defaults to notepad on Windows.

FlagTypeDescription
--recipientstring listRecipients to use instead of secrets.recipients; saved to preflight.yml
--identitypathIdentity path saved to secrets.identity

preflight secret rekey [names...]

Decrypts the named secrets, or every secret when no names are given, and re-encrypts them to the current recipients.

FlagTypeDescription
--recipientstring listRecipients to use; saved to preflight.yml
--identitypathIdentity to use; saved to preflight.yml

With names, --recipient and --identity fail with secret rekey: --identity and --recipient overrides require rekeying all configured secrets.

preflight secret identity generate --out <path>

Writes a new age X25519 identity file and prints its path and public recipient. Creates parent directories. Fails when the file exists.

preflight secret identity recipient <path>

Prints the public recipient of each identity in the file, one per line.

Output formats

FormatDescription
textPlain text
tuiTerminal UI with a live preview of the last 3 output lines of each running task
jsonOne JSON event per line

text and tui print a failed task’s output by default, and successful tasks’ output with --verbose.

JSON events

Every event has type and ts. Run events:

TypeFields
task_started, task_ok, task_changedtask_id, task, target
task_skippedas above, plus reason and optional message; see Skip reason codes
task_failedas above, plus error and optional reason; see Failure reason codes
task_outputtask_id, target, lines
target_unreachabletarget, reason; see Unreachable targets
target_completetarget, ok_count, changed_count, failed_count, skipped_count

Other event types: version, run_start, target_start, run_summary, activity_start, activity_end, warning, diagnostic, facts, plan, validate, action_list, action_info, action_fetch, plugin_list, inventory_list, secret_list.

Run directory

apply, check, and stage write .preflight/runs/<run-id>/ in the project directory:

FileContents
run.jsonlEvent log
run.jsonRun summary
statussuccess or failed
rcExit code