Skip to content

provision_homelab_service

Stand up a homelab service: DHCP lease + firewall allow + (optional) port forwards.

Side effects:

  • Step 1: creates a static DHCP reservation pinning mac to ip on the named network.
  • Step 2 (when ports is non-empty): creates a LAN_LOCAL accept firewall rule for ip on the requested TCP ports.
  • Step 3 (when wan_expose=True and ports is non-empty): creates one port-forward rule per port, exposing the service to the WAN.
  • Mutates controller state. Use dry_run=True to preview the change without applying.
  • Rollback: if any sub-step fails, all prior sub-steps are reverted in reverse order (port_forwards → firewall_rule → lease) and the response includes rolled_back and partial keys.
provision_homelab_service(name="plex", mac="aa:bb:cc:00:00:01", ip="10.50.0.10", network_id="65f...", ports=[32400], wan_expose=False)
ParameterTypeRequiredDefaultDescription
namestringyesDisplay name (used for both the lease and the firewall rule, e.g. "plex").
macstringyesClient MAC address (e.g. "aa:bb:cc:00:00:01").
ipstringyesIPv4 address to reserve (must fall inside the network’s subnet).
network_idstringyes_id of the network/VLAN this service lives on.
ports`arraynull`nonull
wan_exposebooleannofalseTrue also creates port-forward rules so the service is reachable from the WAN. Default False (LAN-only).
controllerstringno”default”Name of the UniFi controller to target. Defaults to "default".
dry_runbooleannofalsePreview the change without applying it. Returns the predicted change set.