OpenNebula / terraform-provider-opennebula

Terraform provider for OpenNebula
https://www.terraform.io/docs/providers/opennebula/
Mozilla Public License 2.0
61 stars 53 forks source link

Extend `nic` section, add missing arguments like METHOD, GATEWAY or DNS.. #548

Open sk4zuzu opened 1 month ago

sk4zuzu commented 1 month ago

Description

This section in documentation seems to be misleading/incomplete. It's actually possible to override the METHOD, GATEWAY, DNS arguments, like so:

NIC = [ DNS = "1.1.1.1", GATEWAY = "10.11.12.13, NETWORK_ID = "0" ]

There is a workaround, the template_section can be used like this:

resource "opennebula_virtual_machine" "vm2" {
  name = "vm2"
  template_id = opennebula_template.vm.id

  template_section {
    name = "NIC"
    elements = {
      NETWORK_ID = data.opennebula_virtual_network.vnets[local.instances.vm.vm2.network].id
      GATEWAY = local.instances.vm.vm2.gateway
    }
  }
}

But it would be great to have those things supported natively (so people could learn about them). We'll review and try to update the OpenNebula documentation as well. :slightly_smiling_face:

New or affected resources and data sources

Potential terraform configuration

resource "opennebula_virtual_machine" "vm2" {
  name = "vm2"
  template_id = opennebula_template.vm.id

  nic {
    network_id = "0"
    method     = "dhcp"
    gateway    = "10.11.12.13"
    dns        = "1.1.1.1"
  }
}

References

https://docs.opennebula.io/6.8/management_and_operations/references/template.html