Lifecycle & Convergence¶
The single most architecturally significant choice: lifecycle.mode selects the phase graph
the pipeline runs — build container images (image, the default), validate GitOps manifests
(gitops), reconcile governance (governance), or drive the docker lifecycle (docker).
Each mode has its own config section. Audition is the same in every mode: the gates, then the
dependency update when dependency: is enabled.
Convergence subsystems COEXIST rather than compete: the perform phase runs every configured
reconciler — a gitops repo keeps mode: gitops and adds opentofu: and ansible: beside it,
and all of them converge in the same reconcile pass: infrastructure, then hosts, then clusters.
Real examples
dungeon runs mode: gitops; MaintenancePolicy runs mode: governance — see
Getting Started.
lifecycle¶
Selects the repository lifecycle mode — the phase graph the pipeline runs. The single most architecturally significant config choice: it determines whether the repo builds container images, validates GitOps manifests, or reconciles governance. When omitted, the lifecycle defaults to image.
lifecycle:
preset: <string> # Preset references an external lifecycle fragment to inherit (the generic preset: fragment-include…
mode: <string> # Mode selects the phase graph. Empty defaults to image. image — build → review → publish image… · required
Phase applicability is mode-derived: the
reviewandpublishphases do work only inimagemode;gitops,governance, anddockermark them not_applicable. Capability requirements differ per mode (e.g.gitopsrequires Reconcile + ImpactAnalysis, plus ClusterAuth whengitops.clusteris set); the lifecycle backend is checked against them at plan time.
gitops¶
GitOps defines the gitops lifecycle target clusters, keyed by cluster name.
gitops:
<id>: # entry key = the unique id
preset: <string>
backend: <string> # Backend selects the GitOps reconciliation backend (e.g. "flux", "argo"). · required
endpoint: <string> # Endpoint is the cluster API server URL (e.g. https://host:6443). · required
exposure: # Exposure classifies endpoint reachability (rule-based). · required
rules: # required
- level: <string> # internet | intranet | cluster · required
endpoints: [<string>] # ip:port (highest precedence) · required
gateways: [<string>] # required
ingress_classes: [<string>] # Ingress spec.ingressClassName · required
cidrs: [<string>] # required
ports: [...] # AND with CIDRs (empty = any port) · required
service_types: [<string>] # ClusterIP | NodePort | LoadBalancer · required
categories: # Categories groups the cluster's namespaces into app inventory sections.
- name: <string> # required
tier: <string> # Tier declares what the namespaces' workloads are: app, platform or hidden. Left empty, discovery…
namespaces: [<string>] # required
inventory: # Inventory configures how the app inventory reads the cluster.
groups:
from:
annotation: <string>
label: <string>
field: <string>
oidc: # OIDC defines authentication configuration for the cluster. · required
audience: <string> # required
governance¶
Governance declares the control repo's governance profiles. It is PRESENCE-GATED, not mode-gated: the reconcile facet activates whenever governance.profiles is non-empty (like the ansible/gitops subsystems), so a control repo needs no lifecycle.mode: governance. A satellite instead carries governance.source (a pointer at its policy repo).
governance:
profiles: # required
<id>: # entry key = the unique id
repos: {} # the location-anchored catalog (raw here)
config: {} # the profile's shared StageFreight config
credentials: <string> # env var prefix for the write token
A catalog entry's config: merges over its profile's config the way local keys merge over a
preset: maps by key, scalars and lists replaced, and null removes an inherited key
(publish: { preset: null, … } declares a section from scratch).
docker¶
Docker defines configuration for the docker lifecycle mode.
docker:
preset: <string>
backend: <string> # Backend selects the Docker execution engine (e.g. "compose"). · required
targets: # Targets defines how reconciliation targets are resolved. · required
source: <string> # Source is the inventory adapter (e.g. "ansible"). · required
inventory: <string> # Inventory is the path to the inventory file (relative to repo root). · required
selector: # Selector declares which hosts from inventory are eligible. · required
groups: [<string>] # required
iac: # IaC defines the Infrastructure as Code directory layout. · required
path: <string> # Path is the IaC directory relative to repo root (default: "docker-compose"). · required
secrets: # Secrets defines the secrets decryption provider. · required
provider: <string> # Provider selects the secrets backend (e.g. "sops", "vault", "infisical"). · required
drift: # Drift defines drift detection and reconciliation policy. · required
tier2_action: <string> # report | reconcile (default: report) · required
orphan_action: <string> # report | down | prune (default: report) · required
orphan_threshold: <int> # block if more than N orphans (default: 5) · required
prune_requires_confirmation: false # require --force for prune (default: true) · required
ansible¶
Ansible defines the ansible host-convergence subsystem. Presence-gated (any converge playbook activates it) and independent of lifecycle.mode.
ansible:
preset: <string>
backend: <string> # Backend selects the host-convergence backend. Default: "ansible". · required
image: <string> # Image is the execution image the playbooks (and ansible-lint) run in — the ansible runtime… · required
inventory: <string> # Inventory is the repo-relative ansible inventory file. · required
ssh: # SSH is the shared connection identity used by every play. · required
user: <string> # User is the remote login user on the managed hosts. · required
credentials: <string> # Credentials is the env-prefix name the SSH key material is read from. · required
known_hosts: <string> # KnownHosts is the repo-relative known_hosts file holding the managed hosts' public keys. Host-key… · required
playbooks: # Playbooks is the play library: an order-preserving id → entry map. Entries with converge: true… · required
<id>: # entry key = the unique id
path: <string> # Path is the repo-relative playbook file. · required
groups: [<string>] # Groups are the inventory groups this play targets (rendered as --limit). · required
converge: false # Converge marks the play as desired-state: it runs on every perform reconcile. False declares a… · required
required: false # Required: failure is hard pipeline fail (default: true — a converge mutates hosts, so a partial…
opentofu¶
OpenTofu defines the OpenTofu/Terraform infrastructure-convergence subsystem. Presence-gated (any converge root activates it) and independent of lifecycle.mode.
opentofu:
preset: <string>
backend: <string> # Backend selects the binary that runs the roots: "opentofu" or "terraform". Default: "opentofu". Its… · required
credentials: <string> # Credentials, when set, is an env prefix: every <PREFIX>_<NAME> variable reaches the binary as…
roots: # Roots is the root-module library: an order-preserving id → entry map. Entries with converge: true… · required
<id>: # entry key = the unique id
path: <string> # Path is the repo-relative root-module directory. · required
converge: false # Converge marks the root as desired state: planned and applied on every perform reconcile. False… · required
required: false # Required: failure is hard pipeline fail (default: true — an apply mutates infrastructure, so a…
workspace: <string> # Workspace is the workspace the root runs in (selected, created when absent). Default: the binary's…
var_files: [<string>] # VarFiles are -var-file arguments, relative to Path, in declared order.
on_destroy: <string> # OnDestroy is what a converge does with a plan that destroys or replaces anything: refuse (default)…
Ansible host convergence¶
The ansible: subsystem converges hosts the way gitops converges clusters: a declared
playbook LIBRARY, executed in a pinned execution image, on every perform reconcile. Two
lanes, one backend:
- Converge plays (
converge: true) run in CI, in declared order, fail-loud — any failed or unreachable host fails the phase; no silent partial converge. Idempotency lives in the playbook (per-host "already at the pin → skip"), so every run is safe and steady-state is a fast no-op. - Runbooks (
converge: false) are declared but structurally unreachable from CI — they get lint, the pinned image, and--checkpreview, and only execute when a human runsstagefreight ansible run <id>(--planfor preview,-e key=valfor launch-time vars).
Execution image. Playbooks and ansible-lint run inside ansible.image — the image owns
the ansible runtime, collections, and connection deps (pywinrm for Windows nodes). Official
default: docker.io/hlhd/ansible; bring your own by
pointing image: elsewhere. Pin a version tag — updates ride the deps engine's docker-image
tag-line semantics.
The image needs a Docker daemon to run in. On a runner without one (a rootless Kubernetes
runner), the plays run with the job's own ansible-playbook instead, and the key is held by a
private ssh-agent rather than written to disk — so that job's image must ship ansible, its
collections, ssh-agent and ssh-add. The results box names which runtime ran (image or
native). With neither a daemon nor ansible in the job, reconcile refuses before it starts.
Trust posture. The SSH key resolves from <PREFIX>_SSH_KEY (raw PEM) or
<PREFIX>_SSH_KEY_B64 (base64 — the single-line form a masked variable can hold, mirroring
<NAME>_CA_B64); store it masked + protected so unprotected-ref pipelines never receive
it — they render "skipped — credentials not available", the signature of a correctly-protected
setup. Host-key verification is always strict against the repo-committed ssh.known_hosts
(ssh-keyscan the fleet once); host trust is auditable in git. The perform job carries a
serialization group (resource_group on GitLab) so two pipelines queue rather than race a
cordon/drain.
Audition lint. lint.modules.ansible runs ansible-lint where the plays run (the execution
image, or the job's own ansible-lint without a daemon) over exactly the declared plays —
undeclared ansible files stay quiet until they join the library. Severities are graduated
(blocker/critical → warning, rest informational): adopting the module never hard-fails an
audition on style rules. When ansible-lint can't run at all, the audition shows a warning
naming the unlinted plays and why.
Facts. Converge results record as the ansible subsystem: {ansible.converged},
{ansible.total}, {ansible.changed}, {ansible.unreachable} — and the shipped summary
carries Converged {ansible.converged}/{ansible.total} nodes · {ansible.changed} changed,
eliding on runs without ansible, exactly like the gitops reconcile line. Failures narrate via
the standard failure facts with no extra wiring.
Drift cadence. StageFreight converges when pipelines run; add a forge scheduled pipeline (e.g. weekly) as drift insurance — steady-state converge is a fast no-op.
Testing. Molecule needs no dedicated machinery — run it as a tool: script test suite
from the execution image. See examples/ansible.yml for the complete
annotated example.
OpenTofu infrastructure convergence¶
The opentofu: subsystem converges infrastructure: a declared library of root modules,
run by OpenTofu or Terraform (backend: opentofu | terraform), on every perform reconcile.
The binary resolves from toolchains.want.opentofu or toolchains.want.terraform and is
verified against the vendor's published SHA256SUMS.
- Converge roots (
converge: true) run in CI, in declared order, before ansible and gitops:init,workspace select -or-createwhenworkspace:is set,planto a saved file with eachvar_filesentry, thenapplyof exactly that saved plan. A plan with no changes skips the apply. Any failed step fails the root;required: falsemakes it advisory. - Destroys wait for a person. A converge plan that destroys or replaces anything fails the
root without applying;
opentofu run <id>applies it.on_destroy: applylets CI apply it. - Runbooks (
converge: false) only run fromstagefreight opentofu run <id>(--planfor a plan without apply). stagefreight reconcile --dry-runandopentofu run --planplan without applying.
Credentials. The binary reads the job's environment (TF_VAR_*, OCI_*, AWS_*, …) as it
is. With credentials: <prefix>, every <PREFIX>_<NAME> variable reaches it as <NAME>
(credentials: oracle-site turns ORACLE_SITE_TF_VAR_region into TF_VAR_region), and a
pipeline where none is set renders "skipped — credentials not available": store them masked
and protected.
Checkout stays clean. Each root's .terraform/ lives in a per-run directory, and init
runs with -lockfile=readonly: commit each root's .terraform.lock.hcl.
Audition lint. lint.modules.opentofu runs fmt -check over every .tf, .tfvars and
.tftest.hcl file and validate over each declared root (initialized without its state
backend). Validate errors are warnings, the rest informational, as with ansible.
Facts. Results record as the opentofu subsystem: {opentofu.total},
{opentofu.applied}, {opentofu.add}, {opentofu.change}, {opentofu.destroy},
{opentofu.failed}. See examples/opentofu.yml.