provision_homelab_service
provision_homelab_service
Section titled “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
mactoipon the named network. - Step 2 (when
portsis non-empty): creates a LAN_LOCAL accept firewall rule foripon the requested TCP ports. - Step 3 (when
wan_expose=Trueandportsis 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_backandpartialkeys.
Example
Section titled “Example”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)Parameters
Section titled “Parameters”| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | yes | — | Display name (used for both the lease and the firewall rule, e.g. "plex"). |
mac | string | yes | — | Client MAC address (e.g. "aa:bb:cc:00:00:01"). |
ip | string | yes | — | IPv4 address to reserve (must fall inside the network’s subnet). |
network_id | string | yes | — | _id of the network/VLAN this service lives on. |
ports | `array | null` | no | null |
wan_expose | boolean | no | false | True also creates port-forward rules so the service is reachable from the WAN. Default False (LAN-only). |
controller | string | no | ”default” | Name of the UniFi controller to target. Defaults to "default". |
dry_run | boolean | no | false | Preview the change without applying it. Returns the predicted change set. |