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

vlan_id is ignored with opennebula_virtual_network and ovswitch #515

Open kepi opened 5 months ago

kepi commented 5 months ago

Description

When I set vlan_id, it is ignored. Terraform acts as everything is well, but there is no VLAN set in OpenNebula.

There is nothing relevant in oned log. I'm using CE version, same problem on 6.4 and 6.6 (I upgraded to 6.6. when it didn't work).

It was working on some of previous versions, but unfortunately I'm not sure which was it. I didn't need it in couple months and memory is fuzzy.

Terraform and Provider version

❯ terraform -v
Terraform v1.6.6
on linux_amd64
+ provider registry.terraform.io/hashicorp/dns v3.4.0
+ provider registry.terraform.io/nbering/ansible v1.0.4
+ provider registry.terraform.io/opennebula/opennebula v1.3.1

Affected resources and data sources

Terraform configuration

terraform {
  required_version = "1.6.6"
  required_providers {
    opennebula = {
      source  = "opennebula/opennebula",
      version = "1.3.1"
    }
  }
}

variable "one_endpoint" {}
variable "one_username" {}
variable "one_password" {}
variable "one_flow_endpoint" {}

provider "opennebula" {
  endpoint      = var.one_endpoint
  flow_endpoint = var.one_flow_endpoint
  username      = var.one_username
  password      = var.one_password
}

resource "opennebula_virtual_network" "reproduce" {
  name        = "reproduce-public"
  permissions = "660"
  group       = "oneadmin"
  type        = "ovswitch"
  bridge      = "ovs-pub"
  vlan_id     = 1458

  dns     = "10.128.2.1"
  gateway = "10.128.2.1"

  cluster_ids = [0]
}

Expected behavior

VLAN should be set in OpenNebula as instructed in configuration.

Actual behavior

VLAN is empty.

Steps to Reproduce

  1. create main.tf witch content fo terraform configuration (setup your variables ofc)
  2. terraform init
  3. terraform apply
  4. check created network in opennebula

Here is output of terraform apply:

❯ terraform apply

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # opennebula_virtual_network.reproduce will be created
  + resource "opennebula_virtual_network" "reproduce" {
      + automatic_vlan_id = (known after apply)
      + bridge            = "ovs-pub"
      + cluster_ids       = [
          + 0,
        ]
      + default_tags      = (known after apply)
      + dns               = "10.128.2.1"
      + gateway           = "10.128.2.1"
      + gid               = (known after apply)
      + gname             = (known after apply)
      + group             = "oneadmin"
      + guest_mtu         = 1500
      + id                = (known after apply)
      + mtu               = 1500
      + name              = "reproduce-public"
      + permissions       = "660"
      + physical_device   = (known after apply)
      + reservation_ar_id = -1
      + reservation_vnet  = -1
      + security_groups   = (known after apply)
      + tags_all          = (known after apply)
      + type              = "ovswitch"
      + uid               = (known after apply)
      + uname             = (known after apply)
      + vlan_id           = "1458"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

opennebula_virtual_network.reproduce: Creating...
opennebula_virtual_network.reproduce: Creation complete after 5s [id=77]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

and here is network in ONE:

❯ onevnet show reproduce-public
VIRTUAL NETWORK 77 INFORMATION
ID                       : 77
NAME                     : reproduce-public
USER                     : oneadmin
GROUP                    : oneadmin
LOCK                     : None
CLUSTERS                 : 0
BRIDGE                   : ovs-pub
STATE                    : READY
VN_MAD                   : ovswitch
AUTOMATIC VLAN ID        : NO
AUTOMATIC OUTER VLAN ID  : NO
USED LEASES              : 0

PERMISSIONS
OWNER                    : um-
GROUP                    : um-
OTHER                    : ---

VIRTUAL NETWORK TEMPLATE
BRIDGE="ovs-pub"
BRIDGE_TYPE="openvswitch"
DNS="10.128.2.1"
GATEWAY="10.128.2.1"
GUEST_MTU="1500"
MTU="1500"
OUTER_VLAN_ID=""
PHYDEV=""
SECURITY_GROUPS="0"
VLAN_ID=""
VN_MAD="ovswitch"

ADDRESS RANGE POOL

LEASES
AR  OWNER        MAC    IP PORT_FORWARD   IP6

VIRTUAL ROUTERS

VIRTUAL MACHINES
UPDATED                  :
OUTDATED                 :
ERROR                    :

Debug output

https://gist.github.com/kepi/c8d8a8af6fe09cb05ec5bf9cafe01e0a

Panic output

No response

Important factoids

I'm using oneadmin account for network definition, so ACL shouldn't be issue.

References

No response