canonical / terraform-provider-maas

Terraform MAAS provider
Mozilla Public License 2.0
60 stars 43 forks source link

feat: maas_network_interface_physical should work for devices #170

Open danielsreichenbach opened 4 months ago

danielsreichenbach commented 4 months ago

When creating a maas_network_interface_physical resource from a maas-device I would expect the network interface to be created. The MAAS API allows this and it would be a very helpful thing to have since one could then actually assign addresses to machines not managed by MAAS itself.

resource "maas_device" "test_01" {
  description = "test_01"
  hostname    = "test_01"
  domain      = maas_dns_domain.default.name
  zone        = "default"

  network_interfaces {
    mac_address = "AA:BB:CC:DD:EE:FF"
  }
}

resource "maas_network_interface_physical" "test_01" {
  machine     = maas_device.test_01.id
  mac_address = "AA:BB:CC:DD:EE:FF"
  name        = "eth0"
}

resource "maas_network_interface_link" "test_01" {
  machine           = maas_device.test_01.id
  network_interface = maas_network_interface_physical.test_01.id
  subnet            = maas_subnet.default.id
  mode              = "STATIC"
  ip_address        = "192.168.13.37"
  default_gateway   = true
}

I would expect this to produce an interface.

As far as I can tell, this is caused by the resource relying on https://github.com/maas/terraform-provider-maas/blob/4a03d32a5a869a50868c32a26b6689c378ed877e/maas/resource_maas_machine.go#L282 when it should actually query machines and devices instead.

ednxzu commented 4 months ago

Yes, same issue here.

skatsaounis commented 3 months ago

Hi @danielsreichenbach, thank you for opening this issue. To me, this is more a feature rather than a bug. I will add the proper labels/title here and I will proceed with reviewing @ednxzu PR.