Skip to content

snippet

Snippet management commands for NDCLI. Snippets are reusable configuration blocks that define users, groups, aliases, and firewall rules. Snippets are combined into templates to create complete configurations.

Snippet content is JSON for every type. The NetDefense agent talks to OPNsense through its REST API for most of them, turning each snippet’s content into the request for the matching OPNsense endpoint; for RULE and ALIAS it builds the whole object from the device’s own model — see RULE and ALIAS fields. AUTH_SERVER and AUTH_ORDER are the one exception — OPNsense has no REST API for authentication servers or the login order at all, so a dedicated on-device helper edits the underlying configuration directly instead.

Type Description
USER User definition (OPNsense auth/user). password is the plaintext to set, never a hash — see USER snippets and passwords
GROUP Group definition (OPNsense auth/group)
ALIAS Network alias — host, network, or port set (OPNsense firewall/alias)
RULE Firewall rule (OPNsense firewall/filter)
UNBOUND_HOST_OVERRIDE Unbound DNS host override — A/AAAA/MX/TXT record
UNBOUND_DOMAIN_FORWARD Unbound DNS domain forwarding (incl. DoT)
UNBOUND_HOST_ALIAS Unbound DNS host alias (CNAME-style, references a host override)
UNBOUND_ACL Unbound DNS query ACL
ZABBIX_SETTINGS Zabbix Agent global settings — singleton; the agent owns the full local/main/tuning/features tree on every apply
ZABBIX_USERPARAMETER Zabbix UserParameter (custom check command). Key must start with nd-
ZABBIX_ALIAS Zabbix item-key alias. Key must start with nd-
AUTH_SERVER External LDAP or Active Directory authentication server. See Authentication Servers.
AUTH_ORDER Login-order policy for a facility (webadmin) — which authentication sources are tried, and in what sequence. See Authentication Servers.
TRUST_CA CA certificate, without its private key, synced into the device’s trust store (OPNsense trust/ca). See Certificates.
TRUST_CERT Certificate and its private key, which comes from a secret variable, synced into the device’s trust store (OPNsense trust/cert). See Certificates.
CROWDSEC_SETTINGS CrowdSec plugin settings — singleton; from agent 1.30.2, keys left out take the plugin’s default. Needs ndagent 1.29.0 or later and os-crowdsec installed. See CrowdSec.

Each type requires a few fields in its JSON content. Creating or updating a snippet without them is rejected, with a message naming the type and the missing field — so the problem surfaces when you author the snippet, not later when a device tries to apply it. A RULE’s action is required too, and must not be empty: OPNsense’s default action is pass, so a rule without one would let traffic through.

Type Required fields
ALIAS name, type
RULE action, non-empty
UNBOUND_HOST_OVERRIDE hostname, domain
UNBOUND_DOMAIN_FORWARD domain, server
UNBOUND_HOST_ALIAS hostname, domain
UNBOUND_ACL name, action
ZABBIX_ALIAS key
USER, GROUP, ZABBIX_USERPARAMETER, ZABBIX_SETTINGS as described for each type above
AUTH_SERVER name, type, host, ldap_port, ldap_urltype, ldap_protver, ldap_scope, ldap_basedn, ldap_authcn, ldap_attr_user
AUTH_ORDER facilities
TRUST_CA name, crt
TRUST_CERT name, crt, key
CROWDSEC_SETTINGS at least one of agent_enabled, lapi_enabled, firewall_bouncer_enabled, rules_enabled, rules_log, crowdsec_firewall_verbose, rules_tag, enroll_key

Everything else in a snippet’s content is optional. Beyond the required fields:

  • RULE and ALIAS content may set any field of the device’s OPNsense rule or alias, under its API name, and a field left out takes OPNsense’s default — except a rule’s action, which must be set and non-empty at save, because OPNsense’s default is pass. A field the device’s model doesn’t have is refused when the device syncs (RULE_FIELD_UNKNOWN, ALIAS_FIELD_UNKNOWN) — see RULE and ALIAS fields. This needs agent 1.23.0 or later; a device on an older agent fails its build with SNIPPET_AGENT_TOO_OLD when a snippet uses a field that agent would drop — see Agent and OPNsense versions.
  • RULE, ALIAS and UNBOUND_* values are JSON strings in OPNsense’s own form: "443", "1", "lan,wan". enabled, and a domain forward’s forward_tcp_upstream and forward_first, may also be true or false, and an alias’s content and an ACL’s networks a list of strings. Any other value, null included, is refused on create and update, naming the field and the form to write — see Field values.
  • USER and GROUP accept only a closed set of known keys (an unknown key is refused when you save).
  • AUTH_SERVER, AUTH_ORDER, TRUST_CA and TRUST_CERT accept only a closed set of known keys (an unknown key is rejected) and require strict JSON with no duplicate keys. AUTH_SERVER and AUTH_ORDER also reject a uuid or refid supplied by hand, and ignore --priority entirely. TRUST_CA and TRUST_CERT reject a uuid on create, and an update may leave it out or send back the one NetDefense assigned, never another.

ZABBIX_ALIAS has one quirk worth knowing: its enabled and accept_params fields must be real JSON booleans (true / false). A quoted "true" or a 1 is rejected at create, with the same message naming the type and the field.

A USER snippet’s password is the plaintext password to set on the account — never a hash. OPNsense hashes whatever password it receives, so a hash pasted here would be hashed a second time: the account’s password would become the hash text itself, and the password you meant to set would not work.

  • Keep it in a secret variable. Write "password": "${name}" and store the value in an organization-scope secret variable, so the password never sits in the snippet’s content. A literal password also works, but it is then stored and shown exactly as written, and lands in your shell history if you type it on the command line.
  • A new account needs a password. Applying a USER snippet for an account that doesn’t exist on the device yet fails without one.
  • Omit password to keep an existing account’s password. When the account is already on the device, a snippet without password leaves its current password alone.
  • A pulled snippet has no password. From ndagent 1.20.1, snippet pull doesn’t copy an account’s password off the device; an older agent copies the account’s stored password hash, which you must remove or replace with the plaintext. Add a password before you apply the snippet to a device where the account doesn’t exist yet.
  • A hash is refused. Saving a password with the shape of a password hash fails ('password' must be the plaintext to set, not a hash), and from ndagent 1.20.1 a device refuses one an older snippet still holds, with the code USER_PASSWORD_IS_HASH — see USER snippets and passwords.
  • Quote ${...} so your shell leaves it alone. Single-quote inline --content, or put the JSON in a file and use --file — otherwise most shells try to expand $name themselves before ndcli ever sees it.
Terminal window
# Store the password once, keeping it off the command line
ndcli variable org create svc_monitoring_password --secret --value-stdin < ./password.txt
# Reference it from the snippet
ndcli snippet create svc-monitoring --type USER \
--content '{"name": "svc-monitoring", "descr": "Monitoring service account", "password": "${svc_monitoring_password}"}'

Authentication servers and login order (AUTH_SERVER / AUTH_ORDER)

Section titled “Authentication servers and login order (AUTH_SERVER / AUTH_ORDER)”

The full guide is Authentication Servers. A few things specific to authoring these two types from the command line:

  • Prerequisites: ndagent 1.19.2 or later, OPNsense 26.1.6 or later, ndcli 1.35.0 or later, and the device’s Allow All Snippet Content setting turned on — it’s off by default (see Device-Side Protection).
  • Quote ${...} so your shell leaves it alone. ldap_bindpw’s value is a literal ${variable_name} string that NetDefense resolves later — most shells try to expand $variable_name themselves before ndcli ever sees it. Single-quote inline --content, or put the JSON in a file with --file instead.
  • Local Database must be first. Every AUTH_ORDER snippet defining the webadmin facility must list Local Database as order[0], or the create/update is refused outright.
  • The consistency rule — checked on the device during sync, not when you save the snippet: every name must be an auth server delivered to the same device by any of its templates, or already configured on the device; names match exactly (case-sensitive); Local Database is always valid.
  • Servers configured by hand on the device get none of NetDefense’s guardrails — no reserved-name exclusion, no Limit-groups requirement, no protected-group check, no cleartext acknowledgement. An AUTH_ORDER snippet may still name one; check it yourself first.
  • Cleartext ("ldap_urltype": "TCP - Standard") needs an explicit "nd_allow_cleartext_ldap": true in the content, or the create is refused.
  • Attaching authored content is a lower bar than authoring it. Creating or updating AUTH_SERVER/AUTH_ORDER content needs the Superuser role; adding an already-authored snippet to a template, a template to an OU, or a device to an OU only needs Read-Write. See Who can attach an authentication policy.

The full guide is CrowdSec. A few things specific to authoring this type from the command line:

  • Prerequisites: ndagent 1.29.0 or later, and the os-crowdsec plugin installed on the device.
  • Quote ${...} so your shell leaves it alone. Put the enrollment key in a secret variable and write "enroll_key": "${crowdsec_enrollment_key}"; single-quote inline --content, or use --file.
  • Keys left out take the plugin’s default from agent 1.30.2: the services and blocklist rules turn on, logging turns off, and rules_tag and enroll_key are cleared. Older agents kept the device’s value. Unknown keys are refused, with a suggestion when it looks like a typo.
  • One snippet applies per device. The lowest priority number wins; a tie fails the device’s sync with SNIPPET_SINGLETON_CONFLICT.

Certificates and CAs (TRUST_CA / TRUST_CERT)

Section titled “Certificates and CAs (TRUST_CA / TRUST_CERT)”

The full guide is Certificates. A few things specific to authoring these two types from the command line:

  • Prerequisites: agent 1.21.0 or later, OPNsense 26.1.11 or later, an unencrypted private key for each TRUST_CERT, ndcli 1.37.0 or later, and the device’s Allow All Snippet Content setting turned on — it’s off by default (see Device-Side Protection).

  • Superuser, interactively. Creating, updating, renaming, reprioritizing or deleting either type needs the Superuser role from ndcli auth login; it’s refused under NDCLI_TOKEN, because a personal access token is capped at Read-Write.

  • Wrap the PEM with jq. crt holds the certificate’s line breaks escaped as JSON. jq -Rs reads a PEM file raw, as one string; single-quote the program so your shell leaves ${...} alone:

    Terminal window
    jq -Rs '{name: "fw-wildcard", crt: ., key: "${fw_wildcard_key}"}' fw-wildcard.crt > fw-wildcard.json
    ndcli snippet create fw-wildcard --type TRUST_CERT --file fw-wildcard.json
  • Put the key in with --value-stdin. key names a secret organization variable. The no-echo prompt reads a single line, so it can’t take a PEM key — redirect the file instead:

    Terminal window
    ndcli variable org create fw_wildcard_key --secret --value-stdin < ./fw-wildcard.key
  • Renew with update-content. Rebuild the content with the same jq recipe and run snippet update-content. Leaving uuid out is fine; NetDefense keeps the one it assigned. When the key changes too, update its variable right before or after — see Renewing a certificate.

USER, GROUP, ZABBIX_USERPARAMETER, and ZABBIX_SETTINGS content that can give a firewall account administrator rights, or run commands on the device, needs a Superuser — see Snippets that grant administrator rights for exactly what counts, and for the errors a sync reports when it’s missing. From the command line:

  • Sign in interactively. Saving such content — snippet create, snippet update-content, snippet edit, or a snippet pull with --auto-create or --overwrite — needs a Superuser signed in with ndcli auth login. It’s refused under NDCLI_TOKEN, because a personal access token never carries Superuser clearance.
  • Re-save with update-content. To give an existing snippet Superuser clearance, save its current content again with snippet update-content. snippet edit sends nothing when the content is unchanged.
  • Pulls are checked too. See Superuser-level content for the codes a refused pull reports.
Command Description
snippet list List snippets
snippet describe Show snippet details
snippet create Create a new snippet
snippet delete Delete a snippet
snippet edit Edit snippet in external editor
snippet example List or print a type’s example content
snippet pull Pull snippet from a device
snippet rename Rename a snippet
snippet set-priority Set snippet priority
snippet update-content Update snippet content from file

List snippets in your organization.

Terminal window
ndcli snippet list [flags]
Flag Type Default Description
--name string Filter by name (regex pattern)
--type string Filter by type: USER, GROUP, ALIAS, RULE, UNBOUND_HOST_OVERRIDE, UNBOUND_DOMAIN_FORWARD, UNBOUND_HOST_ALIAS, UNBOUND_ACL, ZABBIX_SETTINGS, ZABBIX_USERPARAMETER, ZABBIX_ALIAS, AUTH_SERVER, AUTH_ORDER, TRUST_CA, TRUST_CERT, CROWDSEC_SETTINGS
--created-after string Filter by created date
--created-before string Filter by created date
--updated-after string Filter by updated date
--updated-before string Filter by updated date
--sort-by string priority:asc Sort field: priority, name, created_at, updated_at
--page int 1 Page number
--per-page int 50 Items per page (max 100)

--created-after, --created-before, --updated-after and --updated-before accept:

  • Relative: 30m, 2h, 7d, 2w (minutes, hours, days, weeks ago)
  • ISO 8601: 2024-01-15T10:30:00Z. A time with an offset, such as 2024-01-15T10:30:00-03:00, is converted. A time without an offset, or a date alone, is read as UTC

From ndcli 1.40.0, a relative time is counted from the current moment whatever timezone your computer is set to. Earlier releases moved the window by the computer’s offset from UTC.

Terminal window
ndcli snippet list
ndcli snippet list --type RULE
ndcli snippet list --type ALIAS
ndcli snippet list --name "admin.*"
ndcli snippet list --updated-after 24h
ndcli snippet list --sort-by name:asc

Show detailed information about a snippet including its content.

Terminal window
ndcli snippet describe <name>
Argument Required Description
name Yes Snippet name

Shows:

  • Snippet name and type
  • Priority
  • Full content
  • Creation and update timestamps

With -f json, describe prints one JSON document: the snippet object, with its content as the content string.

Terminal window
ndcli snippet describe admin-users
ndcli snippet describe firewall-rules -f json

Create a new snippet.

Terminal window
ndcli snippet create <name> [flags]
Argument Required Description
name Yes Snippet name
Flag Type Default Description
--type string Required Snippet type: USER, GROUP, ALIAS, RULE, UNBOUND_HOST_OVERRIDE, UNBOUND_DOMAIN_FORWARD, UNBOUND_HOST_ALIAS, UNBOUND_ACL, ZABBIX_SETTINGS, ZABBIX_USERPARAMETER, ZABBIX_ALIAS, AUTH_SERVER, AUTH_ORDER, TRUST_CA, TRUST_CERT, CROWDSEC_SETTINGS
--content string Snippet content (inline)
--file string Read content from file
--priority int 1000 Priority (1-60000, lower = higher priority)
--example string Start from this example id of the type (see snippet example). Cannot be combined with --content or --file
--edit bool false Open the example’s content in $EDITOR before creating. Needs --example

--example and --edit need ndcli 1.46.0 or later. With --example, --type still names the type and the example is looked up in it. The content is the example as the control plane lists it. When the example needs a variable or another snippet, Needs: is printed on standard error after the snippet is created.

Terminal window
ndcli snippet create web-servers \
--type ALIAS \
--content '{"name": "web_servers", "type": "host", "content": ["192.168.1.10", "192.168.1.11"]}'
ndcli snippet create firewall-rules \
--type RULE \
--file ./rules.conf
ndcli snippet create critical-rules \
--type RULE \
--file ./critical.conf \
--priority 100
# Start from an example, and edit it before creating
ndcli snippet create lan-to-web --type RULE --example rule-pass-lan-to-host --edit

Priority orders firewall rules inside each OPNsense rule section: PREPEND rules before APPEND rules, each with lower numbers first — see Policy Chain. Suggested ranges:

Range Suggested Use
1-500 Critical/foundational rules
500-1000 Core infrastructure
1000-2000 Standard configurations
2000-5000 Application-specific rules
5000+ Optional/override rules

Delete a snippet.

Terminal window
ndcli snippet delete <name>
Argument Required Description
name Yes Snippet name to delete
Flag Type Default Description
-y, --yes bool false Skip confirmation prompt
Terminal window
ndcli snippet delete deprecated-rules

Open a snippet’s content in your system’s default text editor for editing.

Terminal window
ndcli snippet edit <name>
Argument Required Description
name Yes Snippet name
  1. Downloads current snippet content to a temporary file
  2. Opens the file in your default editor ($EDITOR or system default)
  3. After you save and close, uploads the modified content
  4. If no changes were made, no update occurs

Because nothing is sent when the content is unchanged, snippet edit can’t re-save a snippet to give it Superuser clearance — use snippet update-content for that.

Variable Description
EDITOR Preferred text editor (e.g., vim, nano, code)
VISUAL Alternative editor variable
Terminal window
ndcli snippet edit firewall-rules
EDITOR=nano ndcli snippet edit firewall-rules

List a type’s examples, or print one example’s content.

Terminal window
ndcli snippet example <type> [id]

This needs ndcli 1.46.0 or later. The examples come from the control plane, so they match the formats it accepts. They are the same ones the web app offers beside the snippet’s editor, and the snippet format reference shows them with the rules for each type.

Argument Required Description
type Yes Snippet type, such as RULE. Case does not matter
id No Example id. Without it, the command lists the type’s examples

Without an id, the command lists the type’s examples, then a Docs: line with the type’s page in the format reference. With -f table each example is a row of ID, Name and Subtype; with -f simple, one line; the default, -f detailed, also shows what each example needs.

With an id, standard output carries the example’s JSON content and nothing else, so it can be redirected into a file and given to snippet create --file. Two lines go to standard error instead: Needs:, when the example needs variables or other examples, and Docs:.

Terminal window
ndcli snippet example RULE
ndcli snippet example RULE rule-pass-lan-to-host > rule.json
ndcli snippet create lan-to-web --type RULE --file rule.json

With -f json, the command prints one JSON document: for a list, the type, its docs path and the examples; for one example, the type and docs with the example’s id, name, subtype, content and requires. Docs: is not printed.

An unknown type or example id is an error that lists the valid ones. A control plane that doesn’t offer examples yet answers SERVER_TOO_OLD.

The read-only tool ndcli.snippet.example takes type and an optional id, and returns a JSON document. For a list it holds type, docs and examples, where each item has id, name, subtype and, when present, requires, but no content. For one example it holds type and docs plus an example object with id, name, subtype, content and requires. Call it before ndcli.snippet.create to get the shape of the content.


Pull configuration content from a device and optionally save it as a snippet.

Terminal window
ndcli snippet pull <device> <match-key> [flags]

Pull copies an existing object’s configuration so you can base a new snippet on it. It does not place the object it read under NetDefense management, and the resulting snippet keeps no link back to it — see Portable Snippets and the PULL Workflow for the full workflow, including what happens if you later sync the snippet to the same device you pulled from.

From agent 1.23.0, a pulled RULE or ALIAS is portable snippet content: the fields that say what it does and every other field that differs from OPNsense’s default, as strings, with categories and overload tables named and NetDefense’s template tags removed from the description — see RULE and ALIAS fields. A rule OPNsense generates itself can’t be pulled, and neither can a legacy rule until it’s migrated in OPNsense.

Review what comes back before reusing it — a pulled snippet carries whatever the source device’s configuration held, secrets included. (From ndagent 1.20.1, a USER account’s password is the exception: pull doesn’t copy it — see USER snippets and passwords.) Move anything sensitive into a secret variable before assigning the snippet to a template or sharing it.

Argument Required Description
device Yes Device name to pull from
match-key Yes What identifies the object on the device — see match semantics. May contain any characters, spaces included
Flag Type Default Description
--type string ALIAS Config type to pull (see match semantics below): USER, GROUP, ALIAS, RULE, UNBOUND_HOST_OVERRIDE, UNBOUND_DOMAIN_FORWARD, UNBOUND_HOST_ALIAS, UNBOUND_ACL, ZABBIX_SETTINGS, ZABBIX_USERPARAMETER, ZABBIX_ALIAS, CROWDSEC_SETTINGS
--name string derived Name for the created snippet: letters, digits, dot, underscore and hyphen, up to 255 characters
--auto-create bool false Create snippet in DB if it doesn’t exist
--overwrite bool false Update snippet if it already exists
--wait -w false Wait for task to complete

AUTH_SERVER and AUTH_ORDER are deliberately absent from --type here — they can’t be pulled. OPNsense has no read API for authentication servers or the login order for the agent to read back from, and pulling a server would mean copying its bind password off the device. Author these two types by hand instead — see Authentication Servers. TRUST_CA and TRUST_CERT are absent too: pulling a certificate would copy its private key off the device in the clear. See Certificates.

The positional argument matches the object on the device; --name names the snippet made from it. The two have different rules, which is why they are separate: a match key may contain anything — rule descriptions almost always contain spaces — while a snippet name may only contain letters, digits, dot, underscore and hyphen.

Without --name, the snippet name is derived from the match key: lowercased, with every run of characters outside that set collapsed to a single hyphen, and any leading or trailing hyphens trimmed. So a rule matched by Allow HTTPS from LAN to DMZ becomes the snippet allow-https-from-lan-to-dmz.

Pass --name when the derived name is not what you want:

Terminal window
ndcli snippet pull fw-prod-01 "Allow HTTPS from LAN to DMZ" \
--type RULE --name allow-https-lan-dmz --auto-create --wait

A match key with nothing to derive from — punctuation only — fails and asks for --name, rather than creating a snippet with an empty or meaningless name.

Name collisions behave as they always have: with --auto-create alone an existing snippet name is refused, and with --overwrite it is updated in place.

Terminal window
ndcli snippet pull fw-prod-01 production-aliases --type ALIAS
ndcli snippet pull fw-prod-01 production-aliases --type ALIAS --wait
ndcli snippet pull fw-prod-01 new-rules \
--type RULE \
--auto-create \
--wait
ndcli snippet pull fw-prod-01 existing-aliases \
--type ALIAS \
--overwrite \
--wait

The snippet-name argument doubles as the lookup key on the device. How it’s interpreted depends on --type:

Type Lookup
USER exact username. From ndagent 1.20.1, the account’s password is not copied — see USER snippets and passwords
GROUP exact group name
ALIAS exact alias name
RULE partial description match (case-insensitive); fails if multiple match, or if the match is a legacy rule or one OPNsense generates
UNBOUND_HOST_OVERRIDE hostname.domain (e.g. server1.local)
UNBOUND_DOMAIN_FORWARD domain name (e.g. internal.corp)
UNBOUND_HOST_ALIAS hostname.domain (e.g. www.local)
UNBOUND_ACL ACL name (e.g. lan-clients)
ZABBIX_SETTINGS singleton — there is nothing to match on the device, so the match key only feeds the derived snippet name; the agent returns the full Zabbix Agent settings tree
ZABBIX_USERPARAMETER exact UserParameter key (e.g. nd-cpu-temp)
ZABBIX_ALIAS exact item-alias key (e.g. nd-uname)
CROWDSEC_SETTINGS singleton — nothing to match on the device, so the match key only feeds the derived snippet name; the agent returns the plugin’s eight managed settings, including enroll_key in the clear. Needs os-crowdsec on the device; without it the pull fails with crowdsec_settings '<name>' not found

A pull that saves a snippet (--auto-create or --overwrite) is held to the same rules as saving the snippet yourself — see Snippets that grant administrator rights. When one is refused, the pull task fails, nothing is saved, and the task message starts with one of these codes:

Code Refused when Applies to
PULL_SUPERUSER_REQUIRED The content is elevated — for example a USER or GROUP with an administrator-equivalent privilege, an account or group the device reports as administrator-equivalent, or a Zabbix command, remote commands, or sudo Read-Write members and every personal access token
PULL_GROUPS_UNVERIFIED A USER that belongs to any group, pulled from a device whose agent is older than 1.20.1 and doesn’t report whether those groups grant administrator rights Read-Write members and every personal access token
PULL_OVERWRITE_SUPERUSER_REQUIRED --overwrite would replace a snippet that holds elevated content, or a USER or GROUP snippet a Superuser last saved Read-Write members and every personal access token
PULL_PROTECTED_USER The account is root, netdefense-agent, or netdefense-readonly Everyone
PULL_PROTECTED_GROUP The group is admins or netdefense-readonly Everyone
PULL_CONTENT_UNCLASSIFIABLE The content can’t be classified or has no usable name, so no device could apply it Everyone

A pull without --auto-create or --overwrite only previews the content, and none of these apply. A saving pull run by a Superuser stores the snippet with Superuser clearance.

By default, snippet pull creates an asynchronous task and returns immediately with a task ID. Use --wait to block until completion, or check task status with:

Terminal window
ndcli task describe <task-id>

With -f json, snippet pull prints one JSON document on standard output: the task (task, status, config_type, snippet) and, once --wait sees it complete, the pulled content. The --wait progress lines go to standard error.

{
"task": "abc12345",
"status": "COMPLETED",
"config_type": "ALIAS",
"snippet": "corp",
"content": "{\"content\": \"10.0.0.1\", \"description\": \"\", \"enabled\": \"1\", \"name\": \"corp\", \"type\": \"host\", \"uuid\": \"221f3268-4ac9-4cb3-aad3-63a0f8c09585\"}"
}

Rename a snippet.

Terminal window
ndcli snippet rename <name> <new-name>
Argument Required Description
name Yes Current snippet name
new-name Yes New snippet name
Terminal window
ndcli snippet rename old-rules new-rules

Change a snippet’s priority.

Terminal window
ndcli snippet set-priority <name> <priority>
Argument Required Description
name Yes Snippet name
priority Yes New priority (1-60000)
Terminal window
ndcli snippet set-priority critical-rules 100
ndcli snippet set-priority optional-rules 5000

Update a snippet’s content from a file.

Terminal window
ndcli snippet update-content <name> <file>
Argument Required Description
name Yes Snippet name
file Yes Path to file containing new content

The file’s content is saved even when it matches what’s already stored. That makes update-content the way for a Superuser to give an existing snippet Superuser clearance: save the content snippet describe prints under Content to a file, and pass that file back.

Terminal window
ndcli snippet update-content firewall-rules ./updated-rules.conf
cat new-content.conf | ndcli snippet update-content my-snippet /dev/stdin
# Re-save unchanged content, signed in as a Superuser, to record Superuser clearance
ndcli snippet update-content svc-backup ./svc-backup.json