Pro
NetBox provisioning
Plan a guest in NetBox, and haypack 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.
flowchart LR nb["NetBox"] -- "webhook / every 5 min" --> prov["iac-provisioner"] prov -- "SSH, forced command" --> node["Proxmox node<br/>ct.sh / vm.sh"] node -. "status, Proxmox ID, MAC, journal" .-> nb
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; 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, haypack 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 – haypack 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 haypack (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.
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 |
| 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) – haypack 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, Lynis, SSH keys, Access, fail2ban | /var/lib/iac/security.json (module security-report) |
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.
Du beschreibst eine virtuelle Maschine in NetBox. Der optionale iac-provisioner erstellt daraus einen Container oder eine VM auf Proxmox mit denselben öffentlichen Einzeilern wie bei manueller Installation und schreibt das Ergebnis zurück.
flowchart LR nb["NetBox"] -- "Webhook / alle 5 Minuten" --> prov["iac-provisioner"] prov -- "SSH mit erzwungenem Befehl" --> node["Proxmox-Knoten<br/>ct.sh / vm.sh"] node -. "Status, Proxmox-ID, MAC, Journal" .-> nb
Der Provisioner ist optional. Gäste, Apps, Updates und Module funktionieren unabhängig davon gleich; manuell und zentral erstellte Gäste können nebeneinander bestehen. Pro ist weiterhin in Entwicklung.
NetBox ist der Sollzustand: Der Provisioner erstellt Gäste, meldet Status, gleicht CPU, RAM, Root-Datenträger und Module ab und entfernt als Decommissioning markierte Gäste nach 24 Stunden. Einstellungen und Firewall kommen aus Konfigurationskontexten; Paket- und Schwachstelleninformationen fließen zurück. Tags lösen gezielte Aktionen aus.
Einrichten
0. Netzwerk
Der Provisioner verwaltet Hypervisoren und gehört ins Managementnetz der Proxmox-Knoten, nicht ungetrennt neben die erstellten Server.
| Verbindung | Zweck |
|---|---|
| Provisioner → Knoten, TCP 22 | Gäste erstellen und Status lesen |
| Provisioner → NetBox, HTTPS | Planung lesen, Ergebnis schreiben |
Provisioner → https://iac.heyer.systems | App-/Modulkatalog und Updates |
| NetBox → Provisioner, TCP 8686 | Optionaler Webhook |
Ohne Webhook werden alle Verbindungen vom Provisioner aus aufgebaut; keine eingehende Verbindung ins Managementnetz ist nötig.
1. NetBox
NetBox benötigt Tag, Custom Fields und deren Auswahlwerte. iac-netbox liefert das Schema über sein app-internes Modul provisioner. Beim Erstellen var_modules=provisioner wählen oder im NetBox-Gast:
update --add-modules provisioner
Andere NetBox-Installationen benötigen dasselbe Schema aus iac-netbox/roles/provisioner/files/provisioner_schema.py.
2. Provisioner
Als Container im Managementnetz mit eigenem NetBox-API-Token erstellen:
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)"
Alternativ die Werte in /etc/iac/settings.env des Gasts ergänzen und update ausführen:
netbox_url=https://netbox.example.org
netbox_token=nbt_AbCdEf123456.0123456789abcdef0123456789abcdef01234567
Die URL enthält https://. Den Token ohne Bearer-Präfix eintragen; das Authentifizierungsschema ergänzt der Provisioner. V2-Token ab NetBox 4.5 vollständig als nbt_<key>.<token> verwenden. Benötigt wird Schreibzugriff auf virtuelle Maschinen, Interfaces, MAC-Adressen, Journaleinträge und Custom-Field-Auswahllisten. Einen eigenen Token für den Provisioner verwenden.
3. Jeden Proxmox-Knoten vorbereiten
Das erzeugte Setup-Skript einmal auf jedem Knoten und erneut nach Provisioner-Updates ausführen. Auf dem Host des Provisioners ist der Abruf auch ohne Netzwerkerreichbarkeit vom eigenen Rechner möglich; ID aus pct list bzw. 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
Für weitere Knoten am Ende | ssh root@<node> bash statt | bash verwenden. Bei SSH-Erreichbarkeit geht auch vom Rechner: ssh root@<provisioner> cat /var/lib/iac-provisioner/node-setup.sh | ssh root@<node> bash.
Installiert werden /usr/local/sbin/iac-provisioner-node und der Provisioner-Schlüssel mit restrict,command="/usr/local/sbin/iac-provisioner-node". Dieser Schlüssel öffnet keine Shell. Er darf öffentliche ct.sh/vm.sh mit var-Werten aufrufen. Für Gäste mit Proxmox-Tag iac darf er Status lesen, CPU/RAM und Root-Datenträger ändern – Datenträger nur vergrößern –, Module ändern, stoppen und frühestens 24 Stunden nach dem Stoppen löschen.
Der Knoten erzwingt die Löschfrist selbst. Ein kompromittierter Provisioner kann aber weiterhin als root neue Gäste mit übergebenen SSH-Schlüsseln anlegen; deshalb in einem vertrauenswürdigen Netz betreiben.
4. Webhook – optional
Ohne Webhook wird alle fünf Minuten abgefragt. Für unmittelbare Reaktionen in NetBox einen Webhook auf http://<provisioner>:8686/webhook einrichten. Das Secret steht unter provisioner_webhook_secret in settings.env. Ereignisregel für erstellte und geänderte Virtual Machines ergänzen. Webhooks sind signiert; verlorene Ereignisse werden durch das Polling aufgefangen.
5. Prüfen
journalctl -u iac-provisioner -n 20
Nach listening on 0.0.0.0:8686 sollen keine ERROR-Meldungen folgen. Innerhalb von 15 Minuten erscheinen bei aktiven VMs mit iac-managed die Felder unter iac status. Das bestätigt zugleich den SSH-Zugang zu den Knoten.
Proxmox in NetBox abbilden
| Element | Abbildung |
|---|---|
| Einzelknoten oder Proxmox-Cluster | NetBox-Cluster, etwa Typ proxmox; jeder Knoten als Device darin |
| SSH-Ziel des Knotens | Primäre IPv4 des Devices: Managementadresse, nicht Gateway. Alternativ Kontext iac.ssh_host, sonst Gerätename |
| Netzwerk-Gateway | Custom Field Gateway am Prefix; bei statischen Adressen erforderlich |
| VLAN | Untagged VLAN des Interfaces, sonst VLAN des Prefix |
| Bridge, Storage, DNS, Gast-Schlüssel | Konfigurationskontext unter dem Schlüssel iac |
Provisioning → Config Contexts, nicht Config Templates verwenden. Clusterkontext wird durch Device-Kontext, beide durch lokale Kontextdaten der VM überlagert:
{
"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"
}
}
Alle Schlüssel sind optional; ohne Wert gelten die Einzeiler-Standards:
| Schlüssel | Standard |
|---|---|
| bridge | vmbr0 |
| storage | Erster aktiver Storage für Container bzw. Images; bei mehreren Pools ausdrücklich setzen |
| template_storage | Erster Template-Storage |
| nameserver, searchdomain | Werte des Knotens |
| ssh_keys | /root/.ssh/authorized_keys des Knotens |
Gast erstellen
Eine Virtual Machine in NetBox anlegen:
| Feld | Wert |
|---|---|
| Name | Hostname; FQDN wird in Hostname und Suchdomäne aufgeteilt |
| Status | Planned |
| Cluster, Device | Zielcluster und Zielknoten |
| Tags | iac-managed; ohne Tag wird die VM ohne Journaleintrag ignoriert |
| App, Type, Modules | Etwa netbox und LXC; leere Module bedeuten App-Vorauswahl |
| vCPUs, Memory, Disk | Leer = App-Standard, anschließend zurückgeschrieben. RAM und Root-Datenträger in MB; Datenträger auf GB aufgerundet |
| Proxmox ID | Leer = nächste freie ID; wird zurückgeschrieben |
Dann ein Interface eth0, optional mit MAC, und eine IP samt Maske wie 192.168.40.10/24 anlegen. IP dem Interface zuordnen und als primäre IPv4 der VM setzen. Ohne IP, Gateway oder Knoten wird die VM Failed; der Grund steht im Journal.
Ablauf
Planned → Staged → Active mit Proxmox-ID und MAC oder Failed mit Fehler und letzten Ausgabezeilen im VM-Journal. Staged reserviert den Auftrag; eine Warteschlange pro Cluster verhindert doppelte IDs.
Nach Failed zuerst Ursache und mögliche Gastreste prüfen, erst danach wieder auf Planned setzen. Nach Provisioner-Neustart noch auf Staged stehende VMs werden Failed und nicht automatisch erneut erstellt. Nach erfolgreicher Erstellung werden leere Werte für CPU, RAM, Datenträger und Module ergänzt; zwingende App-Module werden nicht in die wählbare Modulliste geschrieben.
Gast ändern
Änderungen an der NetBox-VM werden beim nächsten Abgleich, alle 15 Minuten, übernommen und protokolliert:
| Feld | LXC | VM |
|---|---|---|
| vCPUs, RAM | Sofort | Nach nächstem Neustart; kein automatischer Reboot |
| Größerer Root-Datenträger | Sofort | Datenträger sofort, Dateisystem beim nächsten Start |
| Kleinerer Datenträger | Abgelehnt, einmaliger Journaleintrag | Ebenso |
| Module | Update mit add/remove-modules im Gast | Über QEMU Guest Agent |
Abgewählte Module werden entfernt, ihre Daten bleiben; Pflichtmodule werden nicht entfernt. NetBox gewinnt über manuelle CPU-/RAM-Änderungen in Proxmox. Leere NetBox-Felder übernehmen dagegen Istwerte des Gasts. Fehlgeschlagene Änderungen werden einmal gemeldet und erst nach weiterer Änderung in NetBox oder Provisioner-Neustart erneut versucht.
Gast löschen
NetBox-Status auf Decommissioning setzen:
- Innerhalb von fünf Minuten, per Webhook sofort, Gast stoppen und Autostart abschalten. Löschzeitpunkt im Journal.
- Nach 24 Stunden Gast ohne automatische Sicherung entfernen. NetBox-VM bleibt als Offline ohne Proxmox-ID erhalten.
Bei einem Irrtum innerhalb der Frist auf Active zurücksetzen; Gast und Autostart werden wieder aktiviert. Offline-Gäste können später über Planned neu erstellt werden.
Logs: journalctl -u iac-provisioner, Laufdateien in /var/log/iac-provisioner/. Lokale Einstellungen wie Intervall oder Listenadresse gehören nach /etc/iac-provisioner/config.local.json.
Bestehende Gäste
- Bestehende oder übernommene Gäste als Active, niemals Planned eintragen. Planned mit iac-managed würde einen neuen Gast erstellen.
- Bestehende Proxmox-ID und Type/App/Modules aus
/etc/iac/instance.jsonübernehmen. - CPU, RAM und Root-Datenträger entsprechend Proxmox setzen oder leer lassen. Eingetragene Werte sind der anzuwendende Sollzustand; Disk umfasst nur rootfs bzw. Boot-Disk, keine weiteren Mounts.
- Interface, MAC und primäre IPv4 wie oben.
iac-managednur bei tatsächlichen haypack-Gästen mit Proxmox-Tag iac und instance.json setzen. Andere Gäste bleiben ohne dieses Tag unangetastet.
Anschließend wird ihr Status wie bei anderen aktiven Gästen gemeldet.
Gäste konfigurieren
In der Gruppe iac der VM:
| Feld | Zeilenformat | Beispiel |
|---|---|---|
| Settings | name=value | piik_url=https://piik.example.org |
| Firewall | Port/Protokoll und erlaubter Zugriff | 8080/tcp private |
Zeilen mit # sind Kommentare. Beim Speichern prüft NetBox Namen, Geheimnisse und Portsyntax und nennt fehlerhafte Zeilen. Erst nach erfolgreichem Speichern wird etwas übertragen.
Einstellungen
Namen stehen auf App- und Modulseiten unter Settings. Ausgangspunkt ist das schreibgeschützte Feld Settings (active) mit den aktuell wirksamen Werten:
piik_url=https://piik.example.org
piik_open_site=false
mail_root_to=admin@example.org
NetBox-Werte haben Vorrang vor settings.env. Entfernte NetBox-Zeilen geben den Gastwert oder App-Standard wieder frei. Geheimnisse bleiben im Gast; NetBox lehnt Passwörter und Tokens ab. Diese in settings.env ändern, dann update ausführen.
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
| Zugriff | Erlaubte Quellen |
|---|---|
| public | Alle |
| private | 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, fc00::/7 und fe80::/10 |
| closed | Niemand, auch bei durch App oder Modul geöffnetem Port |
| Adressen/Netze | Nur genannte IPv4-/IPv6-Adressen und Netze, durch Leerzeichen oder Komma getrennt |
Die Regeln gelten für App-, Modul- und zusätzliche Ports und gewinnen vor App-Regeln. SSH auf 22/tcp darf eingeschränkt, nicht geschlossen werden. Bei Aussperrung über pct enter oder VM-Konsole auf dem Host eingreifen. Entfernte Zeilen geben wieder die App-Regel frei.
Wirksamkeit
- VM speichern. Binnen 15 Minuten liefert der Provisioner
/etc/iac/context.jsonaus; Journalmeldung „configuration delivered“. Der Gast kontaktiert NetBox oder Provisioner nicht selbst. - Wirksam beim nächsten update, nachts, manuell oder per Tag iac-update-now.
- Configuration wechselt von pending auf applied. Leer bedeutet keine gelieferte Konfiguration. Settings (active) zeigt wirksame Werte ohne Geheimnisse.
Ist NetBox nicht erreichbar, bleibt die zuletzt gelieferte Konfiguration im Gast.
Mehrere Gäste über Konfigurationskontexte
Für Regeln pro Mandant, Cluster, Rolle oder Tag einen Config Context mit Profil iac zuordnen:
{"iac": {"guest": {
"settings": {"mail_root_to": "admin@example.org"},
"firewall": {"445/tcp": "closed", "22/tcp": ["192.168.20.0/24"]}
}}}
NetBox führt Kontexte zusammen. Die VM-Felder Settings und Firewall überlagern gleichnamige Einstellungen bzw. Ports. Das Profil validiert JSON beim Speichern.
Pakete und Schwachstellen
| Feld | Inhalt / Quelle |
|---|---|
| Packages | Debian-Quellpakete mit Version, eine Zeile pro Paket; von jedem Gast |
| CVEs (fix available) | Debian-Schwachstellen mit verfügbarer Korrektur; update installiert sie |
| CVEs (no fix) | Bekannte Schwachstellen ohne Debian-Korrektur |
| Security report | Zeit und Zusammenfassung des letzten Berichts |
| Reboot needed | Kernel wartet auf Neustart; gezielte Aktion mit iac-reboot-now |
| Lynis index / findings | Härtungsindex 0–100, Warnungen und Vorschläge mit IDs |
| SSH keys | Benutzer, Typ, Bits, Fingerprint, Kommentar; Änderungen erzeugen Journaleintrag |
| Access | Wirksame sshd-Werte, Konten mit Login-Shell und Passwortstatus, sudo und App-Admins |
| fail2ban bans (7 days) | Sperren aller Jails der letzten sieben Tage, leer ohne fail2ban |
Außer Packages kommen diese Daten aus security-report. In der VM-Liste nach Paketen wie php8.4 oder einer CVE filtern und bei Bedarf CSV exportieren. Mitgebrachte GitHub-Binaries, pip- und Docker-Software sind nicht in der Debian-Paketliste enthalten; die App-Version steht separat.
Aktionen über Tags
| Tag | Aktion |
|---|---|
| iac-update-now | update im Gast |
| iac-security-report-now | Sicherheitsbericht, Modul security-report nötig |
| iac-reboot-now | Gast geordnet neu starten, höchstens fünf Minuten; niemals ohne explizites Tag automatisch |
Gäste auswählen, gegebenenfalls über Filter und Bulk Edit, dann Tag hinzufügen. Binnen fünf Minuten bzw. per Webhook sofort entfernt der Provisioner das Tag, führt die Aktion in einer Cluster-Warteschlange aus und protokolliert Ergebnis und Ausgabe. Danach werden Felder aufgefrischt; nach Reboot in der nächsten Runde, der Sicherheitsbericht zehn Minuten nach Start. Nur für Active-VMs.
Beispiel Schwachstelle: Nach CVE filtern, allen Treffern iac-update-now geben und danach denselben Filter prüfen. Ein leeres Ergebnis bedeutet, dass die zuvor gemeldete CVE dort nicht mehr aufgeführt wird; nach Updates läuft der Bericht erneut.
Fehlerbehebung
| Symptom | Ursache und Abhilfe |
|---|---|
| Planned ohne Journal | iac-managed fehlt |
| netbox_url must start with https:// | Schema ergänzen, danach update |
| HTTP 403 | Token ungültig, abgelaufen oder unzureichend berechtigt; Token ohne Bearer eintragen |
| Connection refused / timed out | Provisioner erreicht Knotenport 22 nicht; Managementnetz bzw. Firewall prüfen |
| Permission denied (publickey) | node-setup.sh auf dem Knoten ausführen |
| SSH zum falschen Gerät | Primäre Device-IPv4 korrigieren; kein Gateway eintragen |
| Failed ohne Gateway | Gateway am Prefix ergänzen |
| Falscher Storage | storage im Kontext ergänzen; bestehenden Gast gegebenenfalls mit pct move-volume verschieben |
| Leere Statusfelder | SSH, aktuelle NetBox-Felder und Knotenskript prüfen; NetBox aktualisieren und node-setup.sh erneut ausführen |
| iac-provisioner-node is too old | Knotenskript aktualisieren; vorher keine Änderung oder Löschung |
| Änderung wird nicht übertragen | Letzten Fehler im Journal beheben; Feld erneut ändern oder Dienst neu starten |
| VM-CPU/RAM unverändert | Wird erst nach VM-Neustart wirksam |
| the root disk only grows | NetBox-Wert mindestens auf gemeldete Größe setzen |
| Configuration bleibt pending | update im Gast oder iac-update-now auslösen |
| Einstellung wirkungslos / Ignored from NetBox | Namen prüfen; Geheimnisse gehören in settings.env |
| Paket-/CVE-Felder fehlen | iac-netbox aktualisieren |
| CVE-Felder bleiben leer | security-report in Modules auswählen |
Gaststatus in NetBox
Alle 15 Minuten werden aktive VMs mit iac-managed, Proxmox-ID und Typ abgefragt. Die UI-Gruppe iac status ist schreibgeschützt:
| Feld | Quelle |
|---|---|
| App version, iac-core, Active modules einschließlich Pflichtmodulen | /etc/iac/instance.json |
| Last update, Last update result | /var/lib/iac/update.json |
| Configuration, Settings (active) | instance.json und context.json |
| Packages | dpkg-query im Gast |
| CVEs, Security report, Reboot needed, Lynis, SSH keys, Access, fail2ban | /var/lib/iac/security.json aus security-report |
Fehlgeschlagene Updates erzeugen einen Journaleintrag; nach Last update result filtern, um betroffene Gäste zu finden. Gäste brauchen dafür keinen NetBox-Token und keinen zusätzlichen haypack-Agenten. Der Knoten liest Dateien über pct exec bzw. den QEMU Guest Agent; der Provisioner übernimmt nur Text für die zugehörige VM. Gestoppte Gäste behalten letzte Werte.
Aktuelle NetBox-Felder und node-setup.sh sind erforderlich. Fehlen sie, funktioniert Erstellung weiter, aber Warnungen erscheinen. Updatefelder bleiben leer, bis iac-core update.json geschrieben hat.
Zertifikate
Geplant: Zertifikate der internen CA ausschließlich für die in NetBox geführten Namen und IPs automatisch ausstellen und erneuern. Ohne Provisioner manuell ablegen; Apps funktionieren in beiden Fällen.
Ohne NetBox
Alle Installationen funktionieren auch manuell. IAC_RESULT liefert das Ergebnis als JSON für eigene Automatisierung.