terraform-provider-unifi icon indicating copy to clipboard operation
terraform-provider-unifi copied to clipboard

Bug unifi_network -> subnet always assume 1 as ip address

Open daco-tech opened this issue 2 years ago • 3 comments

unifi_network->subnet always assume .1 ip address for the VLAN ip address.

Example configuration:

' resource "unifi_network" "vlan_devices" { name = "99_Devices" purpose = "corporate" vlan_id = var.vlan_id_devices subnet = "10.16.99.254/24" dhcp_start = "10.16.99.6" dhcp_stop = "10.16.99.253" dhcp_enabled = true wan_gateway = "0.0.0.0" igmp_snooping = true intra_network_access_enabled = false

lifecycle { ignore_changes = [ wan_gateway, ] } } '

This configuration ends always with the network IP Address 10.16.99.1 instead of applying 10.16.99.254.

When I re-run changing to .1 the state assumes no changes. When I get back to .254, it assumes again no changes.

daco-tech avatar Dec 30 '22 10:12 daco-tech

I might be misunderstanding, but 10.16.99.254/24 isn't a valid cidr block?

ednxzu avatar Mar 23 '23 20:03 ednxzu

subnet maps to the ip_network field in unifi which is an interface spec, so subnet = "10.16.99.254/24" means the network is 10.16.99.0/24 with the gateway listening on .254. I ran in to this exact same issue, with these settings in the UI: Screenshot 2024-02-11 at 17 01 08

I ran terraform import and modified the resource to match my live config, terraform plan showed no changes, and then it changed the gateway IP for the network to 10.254.0.1. The json response from the API has "ip_subnet": "10.254.128.1/16".

linuxdaemon avatar Feb 11 '24 22:02 linuxdaemon

My PR fixes this issue:

https://github.com/paultyng/terraform-provider-unifi/pull/454

DevOpsFu avatar May 05 '24 09:05 DevOpsFu