sync
Synchronization commands for NDCLI. These commands help you monitor and trigger configuration synchronization to devices.
Overview
Section titled “Overview”Configuration sync ensures that devices receive and apply the latest configuration from their assigned templates. Sync status shows whether devices are up-to-date with their expected configuration.
Commands
Section titled “Commands”| Command | Description |
|---|---|
sync status |
Show sync status for devices |
sync apply |
Trigger sync for devices |
Choosing the organization
Section titled “Choosing the organization”sync status and sync apply work on one organization, like the other commands: the global -o/--org, or the default organization, the one saved with ndcli config set org <name> or the one in the NDCLI_ORGANIZATION_NAME environment variable, which takes precedence over the saved one. The filter flags select devices within it. With none of them, both commands fail with Organization is required.
Before ndcli 1.48.0, these two commands refused -o, and their --org was only a filter that didn’t stand in for a default organization.
On a machine with no default organization, such as a CI runner, pass -o <org> or set the variable for the command:
NDCLI_ORGANIZATION_NAME=my-org ndcli sync apply --yesAutomation & CI/CD has complete pipeline examples.
sync status
Section titled “sync status”Show synchronization status for devices.
ndcli sync status [flags]| Flag | Type | Default | Description |
|---|---|---|---|
--device |
string | Filter by device name (regex pattern) | |
--ou |
string | Filter by organizational unit (exact name) | |
--template |
string | Filter by template name (regex pattern) — devices whose effective OU→Template chain matches | |
--drift-status |
string | Filter by drift status: IN_SYNC, DRIFT, NEVER_SYNCED, UNKNOWN, ERROR |
--device and --template are regular expressions; --ou matches an exact name. The organization comes from the global -o/--org: see Choosing the organization.
Output
Section titled “Output”The table has one row per device, then a Total: N devices line:
| Column | Shows |
|---|---|
| Device | The device name. |
| OU | The device’s organizational units. |
| Auto-Sync | Yes or No. The flag has no effect yet: see Auto-Sync. |
| Synced At | How long ago the device last synced, or Never. |
| Status | SYNCED when the device has the current configuration, NOT SYNCED when it needs a sync, or ERROR. |
A device whose configuration can’t be built shows ERROR; with -f json the reason is in its error field. From ndcli 1.49.0 the error’s code shows too: the table’s status reads [UNDEFINED_VARIABLES] ERROR, -f detailed and -f simple give the code and the reason, and -f json has a code field beside error. When no device matches, -f json prints {"items": [], "total": 0} and the other formats print ℹ No devices found.
Examples
Section titled “Examples”ndcli sync status
ndcli sync status --device fw-prod-01
ndcli sync status --ou production
ndcli sync status --device "fw-.*-01"
ndcli sync status --drift-status DRIFT
ndcli sync status --drift-status DRIFT --ou productionsync apply
Section titled “sync apply”Trigger configuration sync for one or more devices.
ndcli sync apply [flags]| Flag | Type | Default | Description |
|---|---|---|---|
--device |
string | Sync devices matching pattern (regex) | |
--ou |
string | Sync all devices in the OU with this exact name | |
--template |
string | Sync devices whose effective OU→Template chain matches the template name (regex) | |
--drift-status |
string | Only sync devices with the given drift status: IN_SYNC, DRIFT, NEVER_SYNCED, UNKNOWN, ERROR |
|
--schedule |
string | Attach a named schedule — creates a recurring sync task instead of a one-time sync | |
--force |
bool | false |
Force sync even if already synced |
--yes |
-y |
false |
Skip confirmation prompt |
Examples
Section titled “Examples”ndcli sync apply --device fw-prod-01
ndcli sync apply --ou production
ndcli sync apply --ou branch-offices
ndcli sync apply --device "fw-datacenter-.*"
ndcli sync apply --template edge-firewall-v2
ndcli sync apply --template "^edge-.*" --yes
ndcli sync apply --device fw-prod-01 --force
ndcli sync apply --ou staging --yes
ndcli sync apply --drift-status DRIFT
ndcli sync apply --drift-status DRIFT --yesConfirmation
Section titled “Confirmation”By default, sync apply asks for confirmation before triggering syncs. Use --yes or -y to skip:
ndcli sync apply --ou production -yThe device list and the prompt go to standard error, so with -f json standard output carries only the result.
Devices that can’t be built
Section titled “Devices that can’t be built”A device whose configuration can’t be built gets no task. sync apply lists it under Errors with the reason, and with the error’s code in brackets when it has one; with -f json, each entry has a code field. When every device fails, the command exits 1. When some fail and the others get their task, it prints its result, then Error: 1 of 2 devices failed, and exits 3 from ndcli 1.49.0 (0 before). See Exit status.
Errors: • fw-hq-01: [SNIPPET_UUID_CONFLICT] More than one snippet on this device carries the same uuid: 221f3268-4ac9-4cb3-aad3-63a0f8c09585 (snippets: web-servers, web-servers-copy; templates: branch, edge). Keep one snippet per uuid: edit each extra snippet and give it a new managed uuid (221f3268-xxxx-4xxx-yxxx-xxxxxxxxxxxx in lowercase hex, y one of 8, 9, a or b); its templates and priority stay as they areWhen a configuration can’t be built lists the common causes. For a shared uuid, The managed uuid has the fix, and a caution for ALIAS snippets.
Force Sync
Section titled “Force Sync”Normally, a device whose last sync already delivered this configuration is skipped, unless its drift status is DRIFT or ERROR. Use --force to re-sync all matched devices:
ndcli sync apply --ou production --forceCombining Filters
Section titled “Combining Filters”You can combine --device, --ou, and --template to narrow the scope (filters compose via AND):
ndcli sync apply --ou production --device "fw-web-.*"
ndcli sync apply --template edge-firewall-v2 --ou productionTemplate-scoped sync
Section titled “Template-scoped sync”Templates can be attached to multiple OUs. --template selects every device whose effective Device → OU → Template chain includes a template matching the regex, so you can sync “everything affected by template X” without enumerating its OUs:
ndcli sync status --template '^edge-firewall-.*'
ndcli sync apply --template edge-firewall-v2 -yScheduling a recurring sync
Section titled “Scheduling a recurring sync”Pass --schedule <name> to create a scheduled task that runs the sync automatically on the named cadence:
ndcli sync apply --ou branch-offices --schedule nightly-maintenance
ndcli sync apply --drift-status DRIFT --schedule monday-rebootUse ndcli schedule tasks list to manage recurring syncs.
Typical Workflow
Section titled “Typical Workflow”ndcli sync status --ou production
ndcli sync apply --ou production
ndcli sync status --ou production
ndcli task list --type SYNC --created-after 5m