BETA

Infrastructure-as-code: Terraform provider and Ansible collection

Reference4 min readUpdated July 2026

Labs can be infrastructure-as-code, not just clicks. netplex. ships a Terraform provider and an Ansible collection, both beta and driving the exact same public REST API the Studio UI uses - no separate server-side runner, no special back door. Neither is on the public Terraform Registry or Ansible Galaxy yet, so both install from a local build for now.

Both need an Architect+ API key with labs:write (+ topology:write for nodes) - create one under Settings → API tokens.

Terraform

Build and install into a local filesystem mirror Terraform can resolve without a registry:

cd tools/terraform-provider-netplex
go mod tidy
go build -o terraform-provider-netplex .

PLUGDIR=~/.terraform.d/plugins/registry.terraform.io/ikhal3d/netplex/1.0.0/$(go env GOOS)_$(go env GOARCH)
mkdir -p "$PLUGDIR"
cp terraform-provider-netplex "$PLUGDIR/"

Point Terraform at the mirror (~/.terraformrc):

provider_installation {
  filesystem_mirror { path = "$HOME/.terraform.d/plugins" }
  direct { exclude = ["registry.terraform.io/ikhal3d/netplex"] }
}

Then a real topology as code:

terraform {
  required_providers {
    netplex = { source = "ikhal3d/netplex", version = "~> 1.0" }
  }
}

provider "netplex" {
  endpoint = "http://netplex.example.com"
  token    = var.npx_token
}

resource "netplex_lab" "staging" {
  name        = "Staging Network"
  template    = "enterprise"
  description = "3-tier staging topology"
}

resource "netplex_node" "core_router" {
  lab_id     = netplex_lab.staging.id
  name       = "CORE-R1"
  type       = "docker"
  vendor     = "frr"
  image      = "frrouting/frr:latest"
  cpu        = 2
  ram        = 1024
  interfaces = 4
}

netplex_lab, netplex_node, netplex_link and the netplex_labs data source are wired and verified end-to-end (apply / idempotent plan / destroy against a live instance).

Ansible

Build and install from the collection source:

cd tools/netplex-ansible
ansible-galaxy collection build --output-path /tmp
ansible-galaxy collection install /tmp/netplex-netplex-1.0.0.tar.gz

Three modules: netplex_lab (create/start/stop/delete a lab), netplex_node (add/start/stop/delete a node), netplex_config (push a startup config). A playbook:

- hosts: localhost
  vars:
    netplex_url: "http://your-netplex-host:8088"
    netplex_token: "{{ lookup('env', 'NETPLEX_TOKEN') }}"
  tasks:
    - name: Create and start a lab
      netplex.netplex.netplex_lab:
        name: bgp-lab
        template: custom
        state: started
        netplex_url: "{{ netplex_url }}"
        netplex_token: "{{ netplex_token }}"
      register: result

    - name: Add a router
      netplex.netplex.netplex_node:
        lab_id: "{{ result.lab.id }}"
        name: R1
        type: docker
        vendor: frr
        netplex_url: "{{ netplex_url }}"
        netplex_token: "{{ netplex_token }}"

The collection also ships a dynamic inventory plugin - pull a live inventory of a running lab's nodes and run ordinary playbooks against them from CI.

Both tools are beta by design: the resources/modules above are real and tested, but expect the interface to still move before a 1.0 registry release. See "REST API quickstart" for the raw HTTP these both sit on top of, and "Lab as code" for netplex.'s own native .npx text format (a different, simpler kind of "lab as code" - no Terraform/Ansible required).