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. NDAgent talks to OPNsense through
its REST API for all of them; each snippet’s content is the JSON payload
the agent will hand to the matching OPNsense endpoint.
Type Description USERUser definition (OPNsense auth/user) GROUPGroup definition (OPNsense auth/group) ALIASNetwork alias — host, network, or port set (OPNsense firewall/alias) RULEFirewall rule (OPNsense firewall/filter) UNBOUND_HOST_OVERRIDEUnbound DNS host override — A/AAAA/MX/TXT record UNBOUND_DOMAIN_FORWARDUnbound DNS domain forwarding (incl. DoT) UNBOUND_HOST_ALIASUnbound DNS host alias (CNAME-style, references a host override) UNBOUND_ACLUnbound DNS query ACL ZABBIX_SETTINGSZabbix Agent global settings — singleton; NDAgent owns the full local/main/tuning/features tree on every apply ZABBIX_USERPARAMETERZabbix UserParameter (custom check command). Key must start with nd- ZABBIX_ALIASZabbix item-key alias. Key must start with nd-
List snippets in your organization.
ndcli snippet list [flags]
Flag Type Default Description --namestring Filter by name (regex pattern) --typestring Filter by type: USER, GROUP, ALIAS, RULE, UNBOUND_HOST_OVERRIDE, UNBOUND_DOMAIN_FORWARD, UNBOUND_HOST_ALIAS, UNBOUND_ACL, ZABBIX_SETTINGS, ZABBIX_USERPARAMETER, ZABBIX_ALIAS --created-afterstring Filter by created date --created-beforestring Filter by created date --updated-afterstring Filter by updated date --updated-beforestring Filter by updated date --sort-bystring priority:ascSort field: priority, name, created_at, updated_at --pageint 1Page number --per-pageint 50Items per page (max 100)
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.
ndcli snippet describe [name]
Argument Required Description nameYes Snippet name
Shows:
Snippet name and type
Priority
Full content
Creation and update timestamps
Templates using this snippet
ndcli snippet describe admin-users
ndcli snippet describe firewall-rules -f json
Create a new snippet.
ndcli snippet create [name] [flags]
Argument Required Description nameYes Snippet name
Flag Type Default Description --typestring Required Snippet type: USER, GROUP, ALIAS, RULE, UNBOUND_HOST_OVERRIDE, UNBOUND_DOMAIN_FORWARD, UNBOUND_HOST_ALIAS, UNBOUND_ACL, ZABBIX_SETTINGS, ZABBIX_USERPARAMETER, ZABBIX_ALIAS --contentstring Snippet content (inline) --filestring Read content from file --priorityint 1000Priority (1-60000, lower = higher priority)
ndcli snippet create web-servers \
--content " host web1 { 192.168.1.10 }
host web2 { 192.168.1.11 } "
ndcli snippet create firewall-rules \
ndcli snippet create critical-rules \
Priority determines the order snippets are applied (lower numbers = higher priority):
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.
ndcli snippet delete [name]
Argument Required Description nameYes Snippet name to delete
ndcli snippet delete deprecated-rules
Open a snippet’s content in your system’s default text editor for editing.
ndcli snippet edit [name]
Argument Required Description nameYes Snippet name
Downloads current snippet content to a temporary file
Opens the file in your default editor ($EDITOR or system default)
After you save and close, uploads the modified content
If no changes were made, no update occurs
Variable Description EDITORPreferred text editor (e.g., vim, nano, code) VISUALAlternative editor variable
ndcli snippet edit firewall-rules
EDITOR = nano ndcli snippet edit firewall-rules
Pull configuration content from a device and optionally save it as a snippet.
ndcli snippet pull [device] [snippet-name] [flags]
Argument Required Description deviceYes Device name to pull from snippet-nameYes Name for the pulled content
Flag Type Default Description --typestring ALIASConfig 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 --auto-createbool falseCreate snippet in DB if it doesn’t exist --overwritebool falseUpdate snippet if it already exists --wait-wfalseWait for task to complete
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 \
ndcli snippet pull fw-prod-01 existing-aliases \
The snippet-name argument doubles as the lookup key on the device. How it’s
interpreted depends on --type:
Type Lookup USERexact username GROUPexact group name ALIASexact alias name RULEpartial description match (case-insensitive); fails if multiple match UNBOUND_HOST_OVERRIDEhostname.domain (e.g. server1.local)UNBOUND_DOMAIN_FORWARDdomain name (e.g. internal.corp) UNBOUND_HOST_ALIAShostname.domain (e.g. www.local)UNBOUND_ACLACL name (e.g. lan-clients) ZABBIX_SETTINGSsingleton — name is the destination snippet name only; the agent returns the full Zabbix Agent settings tree ZABBIX_USERPARAMETERexact UserParameter key (e.g. nd-cpu-temp) ZABBIX_ALIASexact item-alias key (e.g. nd-uname)
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:
ndcli task describe <task-id>
Rename a snippet.
ndcli snippet rename [name] [new-name]
Argument Required Description nameYes Current snippet name new-nameYes New snippet name
ndcli snippet rename old-rules new-rules
Change a snippet’s priority.
ndcli snippet set-priority [name] [priority]
Argument Required Description nameYes Snippet name priorityYes New priority (1-60000)
ndcli snippet set-priority critical-rules 100
ndcli snippet set-priority optional-rules 5000
Update a snippet’s content from a file.
ndcli snippet update-content [name] [file]
Argument Required Description nameYes Snippet name fileYes Path to file containing new content
ndcli snippet update-content firewall-rules ./updated-rules.conf
cat new-content.conf | ndcli snippet update-content my-snippet /dev/stdin