Skip to main content

Inventory

netmodel works with your existing Ansible inventory. Export config from the same devices you manage with Ansible — no duplicate inventory to maintain.

Ansible Inventory

Point netmodel at your Ansible inventory directory:

netmodel export @spine -i ./inventory/ -o ./host_vars/ --structure ansible

This reads your Ansible inventory and exports directly to host_vars/ — ready for Ansible to use.

Supported Structure

inventory/
├── hosts.yaml           # or hosts.ini
├── group_vars/
│   ├── all.yaml
│   └── spine.yaml
└── host_vars/
    ├── spine1.yaml      # netmodel adds files here
    └── 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

netmodel maps these variables automatically:

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

Workflow: Ansible + netmodel

  1. Export current state from live devices:

    netmodel export @all -i ./inventory/ -o ./host_vars/ --structure ansible
  2. Review the YAML — this is your network as code

  3. Modify as needed — change configs in YAML

  4. Apply with Ansible:

    ansible-playbook -i inventory/ deploy.yaml
  5. Validate with netsert:

    netsert run assertions.yaml -i ./inventory/

Simple Inventory (Standalone)

For standalone use or quick exports, use netmodel’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

# Export a group
netmodel export @spine -i inventory.yaml -o ./network-model/

# Export all devices
netmodel export @all -i inventory.yaml -o ./network-model/

Group References

Compose groups with @groupname:

groups:
  dc1:
    - dc1-spine1:6030
    - dc1-spine2:6030
    - dc1-leaf1:6030
  dc2:
    - dc2-spine1:6030
    - dc2-spine2:6030
  all:
    - "@dc1"
    - "@dc2"

Environment Variables

Reference environment variables in either format:

defaults:
  username: ${NETWORK_USER}
  password: ${NETWORK_PASS}
export NETWORK_USER=admin
export NETWORK_PASS=secret
netmodel export @all -i inventory.yaml -o ./output/

Which Format to Use?

Use CaseRecommended
Already using AnsibleUse your existing Ansible inventory
Bootstrapping new automationExport with --structure ansible, then use that
Quick one-off exportsSimple YAML or single target
Multi-tool workflowAnsible inventory (single source of truth)