Config contexts
A config context is a named, weighted JSON document bound to inventory scopes. At session launch, Piping collects active contexts that cover the host in the inventory hierarchy and deep-merges them into one configuration tree.
The context model
| Field | Notes |
|---|---|
name | Human-readable identifier (required) |
description | Optional free text |
weight | Integer -1000..1000; higher weight wins on conflicting keys |
data | Arbitrary JSON object — the payload that gets merged |
is_active | When false, the context is skipped during resolution |
A context's data can hold anything: feature flags, paths, tunables, or connection parameters under piping.connections.* (see below).
Managing contexts in the UI
Open Inventory → Resources, switch to the Provisioning category, and open Config Contexts. The page shows a context list (sorted by weight, searchable by name and description) next to an editor:
- Toggle active / inactive on the status chip.
- Edit the name, description, and weight inline.
- Edit Context Data (JSON) in the raw editor — invalid JSON is flagged immediately, and the Format button pretty-prints valid input.
- New contexts start with weight
100and an empty{}object.
Bindings and scope hierarchy
A context does not apply anywhere by itself — a binding attaches it to one scope:
POST /api/v1/config-context-bindings
{
"context_id": "<context-uuid>",
"scope_type": "site",
"scope_id": "<site-uuid>"
}
A context can have any number of bindings. The scope types that participate in precedence, least to most specific:
| Precedence | scope_type |
|---|---|
| 0 | tenant_group |
| 1 | tenant |
| 2 | site |
| 3 | cluster |
| 4 | role |
| 5 | device |
| 6 | vm |
| 7 | connection_target |
When resolving for a target, Piping walks its inventory ancestry automatically: a device pulls in its site, tenant, and role (plus the site's tenant and the tenant's tenant group); a VM pulls in its cluster, tenant, role, and site (plus the cluster's site and tenant). Every active context bound to any of those scopes becomes a merge candidate.
Merge order and precedence
Candidates are sorted by (weight, scope precedence, id) ascending and deep-merged in that order, so the last write wins:
- Weight first — a context with a higher weight overrides a lower one regardless of scope.
- Scope specificity second — at equal weight, the more specific scope wins (
connection_targetbeatssite). - Creation order last — at a full tie, the newer context wins (ids are time-ordered UUIDv7).
Merge semantics: objects merge recursively key by key; arrays and scalars are replaced wholesale by the later context, never concatenated.
// weight 0, bound to tenant // weight 100, bound to device
{ "ntp": ["10.0.0.1"], { "ntp": ["192.168.1.1"],
"syslog": { "host": "log.corp", "syslog": { "port": 6514 } }
"port": 514 } }
// rendered result for that device
{ "ntp": ["192.168.1.1"],
"syslog": { "host": "log.corp", "port": 6514 } }
How rendered config reaches connections
At session launch the backend materializes the target's configuration in three layers, least to most specific:
- A built-in runtime context with the target's
primary_ip4/primary_ip6(always the lowest precedence — any user context overrides it). - All matching config contexts, merged by the rules above.
- The device's or VM's own
local_context_datafield, merged last — it always wins.
Keys under piping.connections.{ssh,rdp,vnc} in the rendered tree supply connection parameters (host, port, credentials) for sessions. Two guardrails apply:
- Any context whose
datacontainspiping.connectionsis validated against the connection-parameter schema on create and update; violations are rejected with a422listing each violation. - A credential field may hold the UUID of a stored secret instead of a literal value; the backend resolves it from the secret store at launch time, subject to secret-visibility policy.
Protocol-typed launch defaults and accounts come from connection-config records; config contexts provide free-form JSON overlays. See Connections.
Viewing the rendered context in an inspector
Device and VM inspectors show the rendered config context in a collapsible block. Choose JSON, YAML, or TOML (default JSON) through an instance default or a per-user override.
Access control
Config-context endpoints are gated per action on the config_context resource: reading requires Read, and create/update/delete require the matching action. See Access control.
REST API reference
| Method | Path | Purpose |
|---|---|---|
GET | /api/v1/config-contexts | List contexts (name, is_active, scope_type+scope_id, include_hierarchy, limit, offset) |
POST | /api/v1/config-contexts | Create context |
GET | /api/v1/config-contexts/{id} | Get context |
PUT | /api/v1/config-contexts/{id} | Update context (full payload) |
DELETE | /api/v1/config-contexts/{id} | Delete context |
GET | /api/v1/config-context-bindings?context_id= | List bindings of a context |
POST | /api/v1/config-context-bindings | Bind a context to a scope |
DELETE | /api/v1/config-context-bindings/{id} | Remove a binding |
Scope filtering on the list endpoint requires both scope_type and scope_id; add include_hierarchy=true to also return contexts inherited from ancestor scopes. The authoritative route list is in the API reference.