hashicorp / terraform-provider-vsphere

Terraform Provider for VMware vSphere
https://registry.terraform.io/providers/hashicorp/vsphere/
Mozilla Public License 2.0
612 stars 449 forks source link

LACP on Distributed Switches #2110

Open zejar opened 8 months ago

zejar commented 8 months ago

Community Guidelines

Terraform

v1.5.7

Terraform Provider

v2.6.1

VMware vSphere

v7.0.3

Description

When configuring a Distributed Switch with LACP on a vSphere environment with "enhanced" Distributed Switches (LACP API version "multipleLag") LACP is not being configured and an error is thrown in vSphere stating that the LACP config is not compatible with API version "multipleLag".

The output from Terraform pasted below doesn't display the entire error and neither does the debug option. In vSphere the entire error is printed however: "The configurations of the objects are in conflict. Link Aggregation Control Protocol group configured on DSwitch1 conflicts with the Link Aggregation Control Protocol API version multipleLag.".
The error makes sense if the "multipleLag" API version doesn't understand the LACP options Terraform tries to configure. The "singleLag" API version ("basic" switches instead of "enhanced" switches) is unfortunately not available when creating Distributed Switches in VMware 7.

Affected Resources or Data Sources

resource/vsphere_distributed_virtual_switch

Terraform Configuration

resource "vsphere_distributed_virtual_switch" "vds" {
  count                    = var.dswitch_create ? 1 : 0
  name                     = var.distributed_vswitch_name
  datacenter_id            = data.vsphere_datacenter.use_datacenter.id
  lacp_api_version         = var.distributed_vswitch_lacp_api_version
  version                  = var.distributed_vswitch_version

  uplinks = var.distributed_vswitch_uplinks

  dynamic "host" {
    for_each = var.distributed_vswitch_hosts
    content {
      host_system_id = host.value["host_system_id"]
      devices        = host.value["devices"]
    }
  }

  active_uplinks  = var.distributed_vswitch_active_uplinks
  standby_uplinks = var.distributed_vswitch_standby_uplinks
  check_beacon    = var.distributed_vswitch_check_beacon
  failback        = var.distributed_vswitch_failback
  notify_switches = var.distributed_vswitch_notify_switches
  teaming_policy  = var.distributed_vswitch_teaming_policy

  network_resource_control_enabled = var.distributed_vswitch_network_resource_control_enabled
  network_resource_control_version = var.distributed_vswitch_network_resource_control_version

  lacp_enabled = var.distributed_vswitch_lacp_enabled
  lacp_mode    = var.distributed_vswitch_lacp_mode
}

module "dswitch_1" {
  source                                               = "git::ssh://git@<redacted>"
  dswitch_create                                       = true
  obj_dc                                               = "<redacted>"
  distributed_vswitch_name                             = "DSwitch1"
  distributed_vswitch_description                      = "VM networks"
  distributed_vswitch_network_resource_control_enabled = true
  distributed_vswitch_network_resource_control_version = "version3"
  distributed_vswitch_uplinks                          = ["Uplink 1", "Uplink 2"]
  distributed_vswitch_active_uplinks                   = ["Uplink 1", "Uplink 2"]
  distributed_vswitch_hosts = [
    {
      host_system_id = "${module.vsphere_hosts_704.host_id_cluster}"
      devices        = ["vmnic0", "vmnic1"]
    },
    {
      host_system_id = "${module.vsphere_hosts_705.host_id_cluster}"
      devices        = ["vmnic0", "vmnic1"]
    },
    {
      host_system_id = "${module.vsphere_hosts_706.host_id_cluster}"
      devices        = ["vmnic0", "vmnic1"]
    }
  ]
  distributed_vswitch_teaming_policy = "loadbalance_srcid"
  distributed_vswitch_lacp_api_version = "multipleLag"
  distributed_vswitch_lacp_enabled     = true
  distributed_vswitch_lacp_mode        = "active"
  distributed_vswitch_check_beacon     = false
}

Debug Output

https://gist.github.com/zejar/542fc7feada8de2f90ef1bfc7f80aa66

Panic Output

No response

Expected Behavior

Terraform should be able to configure LACP on an "enhanced" Distributed Switch which is the only version available in VMware 7.

Actual Behavior

LACP isn't configured because the LACP config isn't compatible with the Distributed Switches in vSphere 7.

Output from vSphere: "The configurations of the objects are in conflict. Link Aggregation Control Protocol group configured on DSwitch1 conflicts with the Link Aggregation Control Protocol API version multipleLag."

Steps to Reproduce

Configuring a Distributed Switch in vsphere 7 environment with the following options:

  lacp_api_version = "multipleLag"
  lacp_enabled     = true
  lacp_mode        = "active"

Environment Details

No response

Screenshots

No response

References

No response

github-actions[bot] commented 8 months ago

Hello, zejar! πŸ–

Thank you for submitting an issue for this provider. The issue will now enter into the issue lifecycle.

If you want to contribute to this project, please review the contributing guidelines and information on submitting pull requests.