Skip to main content
On this page

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

FieldNotes
nameHuman-readable identifier (required)
descriptionOptional free text
weightInteger -1000..1000; higher weight wins on conflicting keys
dataArbitrary JSON object — the payload that gets merged
is_activeWhen 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 100 and 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:

Precedencescope_type
0tenant_group
1tenant
2site
3cluster
4role
5device
6vm
7connection_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:

  1. Weight first — a context with a higher weight overrides a lower one regardless of scope.
  2. Scope specificity second — at equal weight, the more specific scope wins (connection_target beats site).
  3. 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:

  1. A built-in runtime context with the target's primary_ip4 / primary_ip6 (always the lowest precedence — any user context overrides it).
  2. All matching config contexts, merged by the rules above.
  3. The device's or VM's own local_context_data field, 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 data contains piping.connections is validated against the connection-parameter schema on create and update; violations are rejected with a 422 listing 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

MethodPathPurpose
GET/api/v1/config-contextsList contexts (name, is_active, scope_type+scope_id, include_hierarchy, limit, offset)
POST/api/v1/config-contextsCreate 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-bindingsBind 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.