Skip to main content

Declarative apply

onmsctl apply -f <file|dir|glob> is the single declarative mutation entrypoint. It peeks each YAML document's kind and routes it to the registered handler. There is no per-capability apply verb. Recognized kinds:

kindapiVersionReconciles
Useronmsctl.no42.org/v1alpha1Horizon users + roles
EventSourceeventconf.opennms.org/v1event configuration sources
EventSourceOrdereventconf.opennms.org/v1event-source evaluation order (singleton)
ThresholdGroupthresholding.opennms.org/v1threshold groups (thresholds and expressions)
ThreshdPackagethresholding.opennms.org/v1threshd packages (what is thresholded, with which group)
SnmpConfigsnmp.opennms.org/v1SNMP agent + trap-daemon config (singleton)
Requisitionprovisioning.opennms.org/v1provisioning requisitions
Maintenancemaintenance.opennms.org/v1scheduled-outage maintenance windows
DataCollectionSourcedatacollection.opennms.org/v1SNMP data-collection sources
BusinessServicebsm.opennms.org/v1Business Service Monitoring (BSM) services + edges
Graphgraphml.opennms.org/v1GraphML topologies (layers, vertices, edges)

A single file may hold many ----separated documents, and a directory can mix all kinds.

Order of execution​

Every document is planned first. If any fails to plan (unknown kind, duplicate metadata.name, parse error), the whole apply aborts before any mutation. Once the gate passes, documents execute in a static precedence order so dependencies settle first:

User (100) → EventSource (200) → EventSourceOrder (210) → ThresholdGroup (220) → ThreshdPackage (230) → SnmpConfig (250) → Requisition (300) → Maintenance (350) → DataCollectionSource (375) → Graph (390) → BusinessService (400)

Run apply​

Pass a file, a directory, or a quoted glob:

onmsctl apply -f users.yaml # single file
onmsctl apply -f ./desired-state/ # directory (mixed kinds)
onmsctl apply -f ./desired-state/ -R # recurse into subdirs
onmsctl apply -f 'sources/cisco-*.yaml' # glob (quote it)

Each document yields one ApplyOutcome row, rendered through -o table|yaml|json. A dry run of one new requisition:

onmsctl apply -f acme-prod.yaml --dry-run

Expected output:

+-------------+-----------+--------+---------+-----------------------+
| kind | name | action | status | message |
+====================================================================+
| Requisition | acme-prod | create | Skipped | dry-run: would create |
+-------------+-----------+--------+---------+-----------------------+

The apply flags (--dry-run, --diff, --continue-on-error, -R, --force) are listed under apply flags.

Exit codes​

0 means every document applied or was unchanged. 1 means a document failed or the plan gate refused the input. Other failures keep their own codes: 2 for a usage or config error (including empty input), 4-9 for connection errors, 12 for a read-only refusal, 13-15 for the IAM safety gates. The full table is under Exit codes.

See also: Replace removed imperative verbs in the migration guide.