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
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

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

Plan → gate → execute. 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) → SnmpConfig (250) → Requisition (300) → Maintenance (350) → DataCollectionSource (375) → BusinessService (400)

Each document yields one ApplyOutcome row, rendered through -o table|yaml|json:

kind name action status message
Requisition acme-prod create Skipped dry-run: would create
Requisition site-b none Unchanged in sync
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)
FlagBehavior
--dry-runPlan only; zero mutating HTTP. Classifies as a Read, so --read-only contexts may run it.
--diffRender each kind-bucket's diff to stderr (stdout stays clean for -o json/yaml).
--continue-on-error (alias --keep-going)Keep applying after a failing document. Default is stop-on-error.
-R / --recursiveRecurse into subdirectories (off by default).

Exit codes: 0 all applied/unchanged; 1 any document failed (incl. a plan-gate failure); 2 usage error. The full table is under Exit codes. The imperative mutators that predated this model are gone: see the migration guide.