Use
NetBox provisioning
Plan a guest in NetBox, and iac creates it on the Proxmox node and reports back – optional, the one-liners keep working without it.
You describe a virtual machine in NetBox; the optional
iac-provisioner creates it as a container or VM on the Proxmox node – with
the same public ct.sh and vm.sh you would run by hand – and writes the result back to NetBox.
NetBox ──webhook / every 5 min──▶ iac-provisioner ──SSH (forced command)──▶ Proxmox node: ct.sh / vm.sh
▲ │
└──────────── status, Proxmox ID, MAC, journal ◀──────────────────────────────┘
Optional. The provisioner is just one more caller of the one-liners. Guests, apps, update and
modules behave identically with or without it, and guests from NetBox can live alongside ones
created by hand.
NetBox is the target. The provisioner creates guests, reports their status, applies later
changes to CPU, RAM, disk and modules, and deletes guests set to Decommissioning after
24 hours. Every setting and the whole firewall of a guest come from the config context;
packages and vulnerabilities come back to NetBox; tags run update or the security report.
Set it up
0. Network
The provisioner manages hypervisors, so it belongs in the network your Proxmox nodes are managed from – not next to the servers it creates. It needs:
| Connection | For |
|---|---|
| provisioner → every node, TCP 22 | creating guests, reading their status |
| provisioner → NetBox, HTTPS | reading the plan, writing the result |
provisioner → https://iac.heyer.systems | the list of apps and modules, update |
| NetBox → provisioner, TCP 8686 | only for the webhook (optional) |
Everything it needs starts from the provisioner; without the webhook nothing has to reach into the management network.
1. NetBox
NetBox needs a tag, a few custom fields and their choices. iac-netbox brings them
with the module provisioner – choose it when creating NetBox (var_modules=provisioner) or add
it in the NetBox guest:
update --add-modules provisioner
A NetBox installed some other way needs the same schema; you’ll find the template in
iac-netbox/roles/provisioner/files/provisioner_schema.py.
2. The provisioner
Create it as a container on a node, in the network from step 0, with a NetBox API token:
IAC_NONINTERACTIVE=1 var_netbox_url=https://netbox.example.org var_netbox_token=<token> \
bash -c "$(curl -fsSL https://iac.heyer.systems/provisioner/ct.sh)"
Skipped the variables? Set them later in /etc/iac/settings.env of the guest and run update:
netbox_url=https://netbox.example.org
netbox_token=nbt_AbCdEf123456.0123456789abcdef0123456789abcdef01234567
The URL with https://; the token alone, without Bearer in front – the provisioner adds
the scheme itself. A v2 token (NetBox 4.5+) goes in completely as nbt_<key>.<token>. It needs
write access to virtual machines, interfaces, MAC addresses, journal entries and custom field
choice sets, and read access to platforms (dcim.view_platform); give the provisioner a token of
its own.
3. Every Proxmox node
The provisioner generates a setup script. Run it once on each node, and again whenever the
provisioner was updated. The easiest place is the node the provisioner runs on – it always reaches
its guests, even when the provisioner’s network is closed to your computer (<ID> from pct list
or qm list):
# provisioner as a container
pct exec <ID> -- cat /var/lib/iac-provisioner/node-setup.sh | bash
# provisioner as a VM (qemu-guest-agent)
qm guest exec <ID> -- cat /var/lib/iac-provisioner/node-setup.sh \
| perl -CO -MJSON::PP -0ne 'print decode_json($_)->{"out-data"}' | bash
For every further node end with | ssh root@<node> bash instead of | bash. If you can reach the
provisioner by SSH, this works from your computer too:
ssh root@<provisioner> cat /var/lib/iac-provisioner/node-setup.sh | ssh root@<node> bash.
It installs /usr/local/sbin/iac-provisioner-node and adds the provisioner’s key with
restrict,command="/usr/local/sbin/iac-provisioner-node". The key opens no shell: it can only
start ct.sh/vm.sh from the public address with var_* values – and, only for guests with the
Proxmox tag iac on that node, read two status files (guest status),
set CPU, RAM and the root disk (larger only), change modules, stop them and delete them no sooner
than 24 hours after stopping. The node enforces that deadline itself, so not even a compromised
provisioner can delete a guest right away. Bear in mind it still creates guests as root with
whatever SSH keys you hand it – keep the provisioner on a trusted network.
4. Webhook (optional)
Without a webhook the provisioner polls every five minutes. For quicker reactions, add a webhook in
NetBox to
http://<provisioner>:8686/webhook with the secret from
grep provisioner_webhook_secret /etc/iac/settings.env, plus an event rule (object type Virtual
Machine, created and updated). The webhook is signed; a lost one does no harm.
5. Check
journalctl -u iac-provisioner -n 20
No ERROR should follow listening on 0.0.0.0:8686. Within 15 minutes every active VM with
iac-managed shows the fields of the group iac status – then SSH to the nodes works, too.
Model your Proxmox in NetBox
| What | Where in NetBox |
|---|---|
| Proxmox (single node or cluster) | a cluster (type e.g. proxmox), every node a device in it |
| SSH target of a node | the primary IPv4 of the device – its management address, not the gateway of its network (or config context iac.ssh_host, else its name) |
| Gateway of a network | custom field Gateway on the prefix – without it every guest with a static IP fails |
| VLAN | untagged VLAN on the interface, else the VLAN of the prefix |
| Bridge, storage, DNS, SSH keys of the guests | config context, key iac |
The config context (Provisioning → Config Contexts; not the config templates, iac doesn’t use them) can sit on the cluster; the device’s (node’s) context overrides it, and the local context data of a VM override both:
{
"iac": {
"bridge": "vmbr0",
"storage": "local-zfs",
"template_storage": "local",
"nameserver": ["192.168.40.1"],
"searchdomain": "intra.example.org",
"ssh_keys": "https://git.example.org/admin.keys"
}
}
Every key is optional; without one, the default of ct.sh/vm.sh applies:
| Key | Without a value |
|---|---|
bridge | vmbr0 |
storage | the first active storage of the node for containers or images – with several pools rarely the one you want, so set it |
template_storage | the first storage for container templates |
nameserver, searchdomain | those of the node |
ssh_keys | /root/.ssh/authorized_keys of the node |
Create a guest
A virtual machine in NetBox:
| Field | Value |
|---|---|
| Name | hostname (an FQDN becomes hostname + search domain) |
| Status | Planned |
| Cluster, Device | the cluster and the node the guest is created on |
| Tags | iac-managed – without it the provisioner ignores the VM, without a journal entry |
| App, Type, Modules | e.g. netbox, LXC; Modules empty = the app’s preselection |
| vCPUs, Memory, Disk | empty = the app’s values, filled in afterwards; memory in MB, disk (the root disk) in MB (rounded up to GB) |
| Proxmox ID | empty = the next free one, written back afterwards |
Then, on the VM:
- an interface
eth0(optionally with a MAC), - an IP address with mask (e.g.
192.168.40.10/24), assigned to that interface and set as the VM’s primary IPv4.
The provisioner doesn’t guess: if the IP, gateway or node is missing, the VM becomes Failed with a journal entry.
What happens
Planned → Staged (queued; prevents a second run) → Active with Proxmox ID and MAC, or Failed with the error and the last lines of the output in the journal of the VM. One queue per cluster, so two guests never get the same ID.
After Failed: fix the cause, check or delete a leftover guest on the node, set the VM back to Planned. A VM still on Staged after a restart of the provisioner becomes Failed and is never retried automatically.
Right after creating it, the provisioner fills in what was empty – vCPUs, memory, disk and modules (without those the app requires anyway) – so NetBox shows what the guest really has.
Change a guest
Change the VM in NetBox; at the next check (every 15 minutes) the provisioner applies it and notes it in the journal:
| Field | Container (LXC) | VM |
|---|---|---|
| vCPUs, memory | right away | after the next reboot – iac never reboots on its own |
| disk larger | right away (root disk) | the disk right away, the file system grows at the next boot |
| disk smaller | refused, one journal entry | refused, one journal entry |
| modules | update --add-modules … / --remove-modules … in the guest | the same, via the QEMU guest agent |
- Deselected modules are removed; their data stays (a database, for example). Modules the app requires are never removed.
- NetBox wins: change CPU or RAM by hand in Proxmox and the next check sets it back to the value in NetBox. Empty fields in NetBox, on the other hand, get the guest’s values.
- A change that fails is reported once and not retried every 15 minutes – only after you change something in NetBox or restart the provisioner.
Delete a guest
Set the VM in NetBox to Decommissioning:
- Within five minutes (right away with the webhook) the provisioner stops the guest and turns off its start at boot. The journal names the time it will be deleted.
- After 24 hours it deletes the guest without a backup (
pct/qm destroy --purge). The VM stays in NetBox as Offline, without a Proxmox ID.
A mistake? Set it back to Active within the 24 hours – the guest starts again, and so does its start at boot. An Offline VM can be created anew later by setting it to Planned.
Logs: journalctl -u iac-provisioner and one file per run in /var/log/iac-provisioner/ of the
provisioner. Local settings (interval, listen address, …) go into
/etc/iac-provisioner/config.local.json.
Existing guests
Guests that already exist – created by hand or adopted – go into NetBox like this:
- status Active – never Planned: a VM with
iac-managedon Planned gets created anew; - Proxmox ID = the existing ID; type, app and modules as in the guest’s
/etc/iac/instance.json; - vCPUs, memory and disk as in Proxmox, or empty and the provisioner fills them in. Careful:
whatever you enter is the target and gets applied to the guest. Disk means the root disk only
(
rootfsor the boot disk), without further mount points; - interface, MAC and primary IPv4 as above;
- the tag iac-managed only on guests with iac (Proxmox tag
iac,/etc/iac/instance.jsonpresent). Others go in without it, and the provisioner leaves them alone.
From then on their status is reported like that of any other active guest.
Configure guests
Each guest has two fields in the group iac – edit the VM, change a line, save:
| Field | One line per | Example |
|---|---|---|
| Settings | setting: name=value | piik_url=https://piik.example.org |
| Firewall | port: <port>/<tcp|udp> and who may connect | 8080/tcp private |
Lines starting with # are comments. NetBox checks both fields when you save and names the line
that is wrong – an unknown setting, a secret, a typo in a port. Nothing reaches the guest until
the save went through.
Settings
The names are those of the app – its page lists them under Settings – and of its
modules (e.g. disk_space_warn_gb, mail_root_to). Easiest start: the read-only
field Settings (active) shows what the guest uses now – copy the line you want to change.
piik_url=https://piik.example.org
piik_open_site=false
mail_root_to=admin@example.org
- A setting in NetBox wins over
/etc/iac/settings.envin the guest. Remove the line and the value fromsettings.envapplies again – or the app’s default. - Secrets stay in the guest (passwords, tokens): NetBox refuses them. Change them in
/etc/iac/settings.env, thenupdate.
Firewall
8080/tcp private
445/tcp closed
22/tcp 192.168.20.0/24, 192.168.80.0/24
3000/tcp 192.168.32.10
| Access | Who may connect |
|---|---|
public | everyone |
private | private networks (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, fc00::/7, fe80::/10) |
closed | nobody – also a port the app or a module opens |
| addresses or networks | only these, IPv4 and IPv6, separated by spaces or commas |
It works for the app’s ports, a module’s and new ones, and wins over what the app opens. SSH
(22/tcp) can be restricted, never closed – otherwise nobody gets in again. If you lock
yourself out anyway: pct enter <ID> or the console of the VM on the Proxmox host. Remove the line
and the port is as the app opens it again.
When it takes effect
- Save the VM. Within 15 minutes the provisioner puts the configuration into the guest
(
/etc/iac/context.json) – journal: “configuration delivered”. The guest never contacts NetBox or the provisioner. - It takes effect at the next
update: at night withauto-update, by hand, or right away with the tagiac-update-now. - The field Configuration shows
appliedonce the guest runs it (pendinguntil then).
If NetBox is away, the last configuration stays in the guest.
| Field (group iac status) | Meaning |
|---|---|
| Configuration | applied: the guest runs NetBox’s configuration; pending: delivered, waits for update; empty: none |
| Settings (active) | the settings in effect in the guest, without secrets |
Many guests at once: config contexts
For rules that apply to many guests – “SSH only from the management network” for a tenant,
“445 closed” everywhere – use a config context (Provisioning → Config Contexts) with the
profile iac, assigned to tenants, clusters, roles or tags. The same content as JSON:
{"iac": {"guest": {
"settings": {"mail_root_to": "admin@example.org"},
"firewall": {"445/tcp": "closed", "22/tcp": ["192.168.20.0/24"]}
}}}
NetBox merges all config contexts of a guest. The fields Settings and Firewall of the VM come on top: a line there wins over the same setting or port of a config context. The profile checks the JSON when you save.
Two settings belong to iac itself, not to an app – roll them out with a config context (e.g. on
the tag iac-managed):
{"iac": {"guest": {"settings": {"ntp_servers": "192.168.40.12", "timezone": "Europe/Berlin"}}}}
ntp_servers– host names or IPs, separated by spaces: chrony of a VM uses only these (e.g. an iac-chrony in your network). Without it, the Debian pool.timezone– a name from/usr/share/zoneinfo(Europe/Berlin, the default, orUTC). A service that is already running uses a new time zone after its restart.
Both apply to VMs only: a container has the clock and time zone of its Proxmox node. The field
Settings of a single VM does not take them – set them in its /etc/iac/settings.env instead.
Packages and vulnerabilities
| Field | Content | From |
|---|---|---|
| Packages | Debian source packages with version, one per line (php8.4 8.4.27-1~deb13u1) | every guest |
| CVEs (fix available) | vulnerabilities Debian has fixed – update installs the fix | module security-report |
| CVEs (no fix) | known vulnerabilities without a fix in Debian yet | module security-report |
| Security report | time and summary of the last report | module security-report |
| Reboot needed | a new kernel waits for a reboot – tag iac-reboot-now | module security-report |
| Services to restart | services still running with replaced libraries (needrestart), one per line – the next nightly update restarts them | module security-report |
| Lynis index, Lynis findings | hardening index (0–100), warnings and suggestions with their ID (warning PKGS-7392 …) | module security-report |
| SSH keys | keys that can log in: user, type, bits, fingerprint, comment – a change gets a journal entry | module security-report |
| Access | sshd settings in effect, accounts with a login shell (password yes/no), sudo, admin accounts of the app | module security-report |
| fail2ban bans (7 days) | bans of the last 7 days over all jails; empty without the module fail2ban | module security-report |
Search in the list of virtual machines with a filter, e.g. Packages contains php8.4 or CVEs
(fix available) contains CVE-2026-109618, and export it as CSV. Software an app brings along
itself (a GitHub binary, pip, Docker) isn’t listed – App version covers the app.
Actions with tags
| Tag | The provisioner … |
|---|---|
iac-update-now | runs update in the guest |
iac-security-report-now | runs the security report (module security-report) |
iac-reboot-now | reboots the guest cleanly (at most 5 minutes) – iac never reboots on its own, only on this tag |
Pick the guests – many at once with a filter and bulk edit – and add the tag. Within five minutes (right away with the webhook) the provisioner removes the tag, runs the action – one queue per cluster – and writes the result and output to the journal, the whole report for the security report. Then it refreshes the fields – after a reboot at the next round, the security report runs again 10 minutes after boot. Only for Active VMs.
Fixing a vulnerability: filter on the CVE → add iac-update-now to every match → the same
filter afterwards: empty means fixed (the report runs again after every update).
Troubleshooting
| Message / symptom | Cause | Fix |
|---|---|---|
| VM stays Planned, no journal | tag iac-managed missing | set the tag |
log: netbox_url must start with https:// | URL without scheme | netbox_url=https://…, then update |
log: HTTP 403 from NetBox | token wrong, expired or without rights | new token, the token alone |
journal: Connection refused / timed out to the node | port 22 of the node not reachable from the provisioner – usually a firewall between the networks | move the provisioner into the management network, or allow provisioner → node TCP 22 |
journal: Permission denied (publickey) | node not set up | node-setup.sh on the node (step 3) |
| SSH goes to the wrong machine | primary IP of the device isn’t the node’s (e.g. the gateway) | fix the device’s primary IPv4 |
| Failed: no gateway | custom field Gateway on the prefix empty | set it on the prefix |
| guest on the wrong storage | storage missing in the config context | add it; move the guest with pct move-volume |
| status fields stay empty | SSH to the node fails, or old fields/node script | as above; update in the iac-netbox guest, node-setup.sh again |
log: iac-provisioner-node is too old | node script older than the provisioner – no changes, no deletion | node-setup.sh on the node again |
| a change in NetBox doesn’t reach the guest | the last attempt failed (journal) | fix the cause, change the field again or systemctl restart iac-provisioner |
| VM: CPU/RAM unchanged | they take effect after a reboot | reboot the VM |
journal: the root disk only grows | disk in NetBox smaller than in the guest | set disk in NetBox to at least the value named |
Configuration stays pending | no update in the guest yet | update – or the tag iac-update-now |
| a setting from NetBox has no effect | unknown name or a secret – update says “Ignored from NetBox” | check the name; secrets go into /etc/iac/settings.env in the guest |
| fields for packages/CVEs missing | iac-netbox older | update in the iac-netbox guest |
| CVE fields stay empty | module security-report missing | choose it in NetBox (Modules) |
Guest status in NetBox
Every 15 minutes the provisioner checks what’s actually running on each active VM with
iac-managed,
a Proxmox ID and a type, and writes it to custom fields of the group iac status (read-only in
the UI):
| Field | Source in the guest |
|---|---|
| App version, iac-core | /etc/iac/instance.json |
| Active modules | /etc/iac/instance.json – including the modules the app requires |
Last update, Last update result (ok/failed) | /var/lib/iac/update.json |
| Configuration, Settings (active) | /etc/iac/instance.json and /etc/iac/context.json |
| Packages | dpkg-query in the guest |
| CVEs, Security report, Reboot needed, Services to restart, Lynis, SSH keys, Access, fail2ban | /var/lib/iac/security.json (module security-report) |
The standard field Platform shows the operating system of the guest: the provisioner sets it
from the app (os in /apps.json, name from /os.json), e.g.
“Debian 13” or “Home Assistant OS”. It is for display only – a different platform is replaced at the
next round, with a journal entry. iac-netbox creates the platforms; without read access to them the
field stays empty.
A failed update – e.g. the nightly one – gets one journal entry. Filter the VM list by Last update result to see every guest whose
last update failed.
The guest doesn’t need anything for this – no agent, no NetBox token. The provisioner asks the node,
the
node reads the two files from the guest (container: pct exec, VM: the QEMU guest agent) and
passes them on unchanged; the provisioner only takes text for the fields of that one VM. Stopped
guests keep their last values.
This relies on the new fields in NetBox (update in the iac-netbox guest) and the current
node-setup.sh on each node. Without them, guest creation carries on and the provisioner logs a
warning. The update fields stay empty on a guest until its iac-core writes update.json.
Certificates
Work in progress – planned, not available yet
Planned: the provisioner hands out certificates of your internal CA – only the names and IPs NetBox has for that VM, renewed automatically. Without the provisioner you place certificates by hand; apps work the same either way.
Without NetBox
All of this works by hand, too – see Install. IAC_RESULT gives the same
result as JSON for your own automation.