Skip to main content

Inventory

netsert works with your existing Ansible inventory. If you’re already using Ansible for network automation, you don’t need to maintain a separate inventory.

Ansible Inventory

Point netsert at your Ansible inventory directory:

netsert run assertions.yaml -i ./inventory/ -g spine

netsert reads standard Ansible inventory structure:

inventory/
├── hosts.yaml           # or hosts.ini
├── group_vars/
│   ├── all.yaml
│   ├── spine.yaml
│   └── leaf.yaml
└── host_vars/
    ├── spine1.yaml
    └── spine2.yaml

hosts.yaml

all:
  children:
    spine:
      hosts:
        spine1:
          ansible_host: 10.0.0.1
          gnmi_port: 6030
        spine2:
          ansible_host: 10.0.0.2
          gnmi_port: 6030
    leaf:
      hosts:
        leaf1:
          ansible_host: 10.0.1.1
        leaf2:
          ansible_host: 10.0.1.2

group_vars/all.yaml

# Shared gNMI settings
gnmi_port: 6030
gnmi_username: admin
gnmi_password: "{{ vault_gnmi_password }}"
gnmi_insecure: true

netsert maps these variables automatically:

  • ansible_host → target address
  • gnmi_port → target port (default: 6030)
  • gnmi_username / gnmi_password → credentials
  • gnmi_insecure → skip TLS verification

Simple Inventory (Standalone)

For standalone testing or CI, use netsert’s simple YAML format:

# inventory.yaml
groups:
  spine:
    - spine1:6030
    - spine2:6030
  leaf:
    - leaf1:6030
    - leaf2:6030
  all:
    - "@spine"
    - "@leaf"

defaults:
  username: admin
  password: admin
  insecure: true

Usage

# Run against a group
netsert run assertions.yaml -i inventory.yaml -g spine

# Run against all
netsert run assertions.yaml -i inventory.yaml -g all

# Generate from a group
netsert generate @spine -i inventory.yaml

Group References

Use @groupname to compose groups:

groups:
  dc1-spine:
    - dc1-spine1:6030
    - dc1-spine2:6030
  dc2-spine:
    - dc2-spine1:6030
    - dc2-spine2:6030
  all-spines:
    - "@dc1-spine"
    - "@dc2-spine"

Concurrency

Control parallel execution for large inventories:

netsert run -w 10 -p 5 assertions.yaml -i inventory.yaml
FlagDefaultDescription
-w, --workers10Concurrent targets (devices)
-p, --parallel5Concurrent assertions per target

Environment Variables

Reference environment variables in either format:

defaults:
  username: ${NETWORK_USER}
  password: ${NETWORK_PASS}
export NETWORK_USER=admin
export NETWORK_PASS=secret
netsert run assertions.yaml -i inventory.yaml

Which Format to Use?

Use CaseRecommended
Already using AnsibleUse your existing Ansible inventory
CI/CD pipelinesSimple YAML (self-contained, portable)
Quick testingSimple YAML or --target flag
Multi-tool workflowAnsible inventory (single source of truth)