Orc Commands
The stategraph orc commands run the Orchestration plan and apply workflows on a checkout, from a terminal or a script: no server, no git operations, and no API calls. Every artefact of a run lands in the directory that --out names.
orc plan and orc apply are for local runs and CI scripts. orc indexer and orc run are the entry points that the Stategraph Orchestration runner calls. See Runs without a server for when to use them instead of the pull request flow.
stategraph plan and stategraph apply are aliases for stategraph tf plan and stategraph tf apply. In a pull request comment, the same words start a Stategraph Orchestration run. See Pull request commands.
Commands
| Command | Description |
|---|---|
stategraph orc plan |
Plan the dirspaces of the checkout, without a VCS or API |
stategraph orc apply |
Apply the dirspaces that have a plan, without a VCS or API |
stategraph orc indexer |
Index the local Terraform modules and the symlinks in each path as JSON |
stategraph orc run |
Run the Orchestration runner for a work manifest |
# From the root of your checkout
stategraph orc plan --out .sgc-out
stategraph orc apply --out .sgc-out
stategraph orc plan
Run it from the root of your checkout, or pass the configuration file with --config.
stategraph orc plan --out <dir> [--config <file>] [TAG_QUERY]
Arguments
| Argument | Required | Description |
|---|---|---|
TAG_QUERY |
No | Tag query selecting the dirspaces to plan. Default: all. |
Options
| Option | Required | Description |
|---|---|---|
--out |
Yes | Directory holding the state of the run: the state and plan files of every dirspace, and the text of every step that ran. |
--config |
No | Path to the repository configuration file. Default: the first of .stategraph/config.yml, .stategraph/config.yaml, .terrateam/config.yml, .terrateam/config.yaml in the working directory. |
--silent |
No | Suppress notice output. On plan, this hides the Nothing to plan. line. |
--loggers |
No | Logging subsystems to enable, comma separated |
-q, --quiet |
No | Be quiet. Takes over -v and --verbosity. |
-v, --verbose |
No | Increase verbosity. Repeatable. |
--verbosity |
No | Log level: quiet, error, warning, info, or debug. Takes over -v. |
The configuration file is required. Without --config and without one of the standard names, the command fails rather than plan with the default configuration:
Error: no repository configuration file found in <working dir>.
To fix: pass --config with the path of the configuration file, or create one of:
.stategraph/config.yml, .stategraph/config.yaml, .terrateam/config.yml,
.terrateam/config.yaml
A tag query filters by dir:<path> and workspace:<name>. branch: and dest_branch: queries never match a local run, because a checkout on disk has no branch.
How planning works
plan walks the checkout, skips .git, symlinks, and the --out directory, and derives a dirspace from every directory that when_modified.file_patterns matches. It then plans the dirspaces that have changes and are not applied yet.
Planning runs the head layer of the dependency order. A dirspace that depends_on points at plans first; a dirspace that depends on it plans after that one applies. So the cycle for layered infrastructure is plan, apply, plan: each plan picks up the layer that the last apply unlocked. See Layered runs.
Example
stategraph orc plan --out .sgc-out
Output (trimmed):
cwd=app: stdout: OpenTofu has been successfully initialized!
cwd=app: stdout: Plan: 1 to add, 0 to change, 0 to destroy.
The command echoes the output of each step as cwd=<dir>: stdout: and cwd=<dir>: stderr: lines. When nothing is left to plan, it prints Nothing to plan. There is no summary line at the end of a run.
The --out directory holds the plan files and the state of every dirspace:
.sgc-out
└── app
└── default
├── plan
│ ├── 0_init
│ │ ├── stderr.txt
│ │ └── stdout.txt
│ └── 1_plan
│ ├── stderr.txt
│ └── stdout.txt
├── plan.tfplan
└── state.json
Each dirspace gets <out>/<directory>/<workspace>/. The workspace name is percent-encoded, and the repository root directory maps to the reserved <root> segment. The text of every step that ran is under plan/<index>_<step>/.
stategraph orc apply
apply applies the plan files that the --out directory holds.
stategraph orc apply --out <dir> [--config <file>] [options]
Options
| Option | Required | Description |
|---|---|---|
--out |
Yes | Directory holding the state of the run. Pass the same directory that plan used. |
--config |
No | Path to the repository configuration file. Default: the first of the standard names in the working directory. |
--tag-query |
No | Tag query selecting the dirspaces to apply. Default: all. |
--auto-approve |
No | Skip the approval prompt before the apply of a fresh plan |
-y |
No | Auto-confirm interactive prompts |
--silent |
No | Suppress prompt output. Only effective with -y. |
--iter |
No | Keep running passes until no dirspace is left |
--loggers |
No | Logging subsystems to enable, comma separated |
-q, --quiet |
No | Be quiet. Takes over -v and --verbosity. |
-v, --verbose |
No | Increase verbosity. Repeatable. |
--verbosity |
No | Log level: quiet, error, warning, info, or debug. Takes over -v. |
On apply, the tag query is an option, --tag-query=TAG_QUERY, not a positional argument as on plan.
Approvals
A plan file that the --out directory already holds applies without a prompt. The approval prompt guards only a fresh plan: with --iter, a pass that plans a new layer asks before it applies. The prompt needs an interactive terminal and accepts only the exact word yes.
When stdin is not a tty, or --silent is set, the run stops and names --auto-approve in its error. In CI, pass --auto-approve, or -y, which approves as well.
The prompt guards the apply of a fresh plan, and nothing else. The plan phase runs the commands the checkout supplies before any prompt: the run steps of the workflow, the gates workflow and hook steps, and the plans.cmd storage commands (delete, fetch, store). Run orc plan and orc apply only on a checkout you trust.
What apply does with plans
apply deletes the plan file of every dirspace that it executes, and records the outcome in state.json. A dirspace whose apply failed is recorded as not applied, and the next plan plans it again. Plans live only in the --out tree while they stand: there is no other store.
The apply takes no lock on your tree, so two concurrent orc apply runs on one checkout can race. Run one at a time.
Passing with --iter
Without --iter, apply applies the plan files in scope and stops. With --iter, it keeps running passes until no dirspace is left: each pass applies the plan files in scope and, when that applied nothing, plans the next layer, asks for approval, and applies it. A pass that applies nothing and plans nothing ends the run.
Example
stategraph orc apply --out .sgc-out
Output (trimmed):
cwd=app: stdout: terraform_data.stamp: Creating...
cwd=app: stdout: terraform_data.stamp: Creation complete after 0s [id=5c80d9e7-b42c-5370-7d6e-0d2616119791]
cwd=app: stdout: Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
After the apply, the plan file is gone and the steps of the apply are stored next to the ones of the plan:
.sgc-out
└── app
└── default
├── apply
│ ├── 0_init
│ │ ├── stderr.txt
│ │ └── stdout.txt
│ └── 1_apply
│ ├── stderr.txt
│ └── stdout.txt
├── plan
│ ├── 0_init
│ │ ├── stderr.txt
│ │ └── stdout.txt
│ └── 1_plan
│ ├── stderr.txt
│ └── stdout.txt
└── state.json
stategraph orc indexer
indexer indexes the local Terraform modules and the symlinks of each path that you name, as JSON:
stategraph orc indexer [options] <path>...
The Orchestration runner calls it to resolve module sources on a runner.
stategraph orc run
run runs the Orchestration runner for a work manifest. The Orchestration GitHub Actions and GitLab CI workflows call it; you call it only when you drive a runner by hand. See Runs without a server.
Configuration
| Environment Variable | Description |
|---|---|
STATEGRAPH_SILENT |
Same as --silent |
STATEGRAPH_NON_INTERACTIVE |
Same as -y: auto-confirm interactive prompts |
STATEGRAPH_LOGGERS |
Default for --loggers |
STATEGRAPH_LOG_LEVEL |
Default for --verbosity |
Next steps
- Runs without a server: when to run
orc planandorc applyinstead of the pull request flow
- [orc plan and orc apply]a worked local run, with layers and limitations - Layered runs: order plan and apply across dependent layers
- Stacks:
plan_afterandapply_afterrules across directories - Pull request commands: the
planandapplycomments of the pull request flow