vsphere_host_port_group
The vsphere_host_port_group
resource can be used to manage vSphere standard port groups on an ESXi host. These port groups are connected to standard virtual switches, which can be managed by the vsphere_host_virtual_switch
resource.
For an overview on vSphere networking concepts, see this page.
Example Usages
Create a virtual switch and bind a port group to it:
data "vsphere_datacenter" "datacenter" { name = "dc1" } data "vsphere_host" "esxi_host" { name = "esxi1" datacenter_id = "${data.vsphere_datacenter.datacenter.id}" } resource "vsphere_host_virtual_switch" "switch" { name = "vSwitchTerraformTest" host_system_id = "${data.vsphere_host.esxi_host.id}" network_adapters = ["vmnic0", "vmnic1"] active_nics = ["vmnic0"] standby_nics = ["vmnic1"] } resource "vsphere_host_port_group" "pg" { name = "PGTerraformTest" host_system_id = "${data.vsphere_host.esxi_host.id}" virtual_switch_name = "${vsphere_host_virtual_switch.switch.name}" }
Create a port group with VLAN set and some overrides:
This example sets the trunk mode VLAN (4095
, which passes through all tags) and sets allow_promiscuous
to ensure that all traffic is seen on the port. The latter setting overrides the implicit default of false
set on the virtual switch.
data "vsphere_datacenter" "datacenter" { name = "dc1" } data "vsphere_host" "esxi_host" { name = "esxi1" datacenter_id = "${data.vsphere_datacenter.datacenter.id}" } resource "vsphere_host_virtual_switch" "switch" { name = "vSwitchTerraformTest" host_system_id = "${data.vsphere_host.esxi_host.id}" network_adapters = ["vmnic0", "vmnic1"] active_nics = ["vmnic0"] standby_nics = ["vmnic1"] } resource "vsphere_host_port_group" "pg" { name = "PGTerraformTest" host_system_id = "${data.vsphere_host.esxi_host.id}" virtual_switch_name = "${vsphere_host_virtual_switch.switch.name}" vlan_id = 4095 allow_promiscuous = true }
Argument Reference
The following arguments are supported:
-
name
- (Required) The name of the port group. Forces a new resource if changed. -
host_system_id
- (Required) The managed object ID of the host to set the port group up on. Forces a new resource if changed. -
virtual_switch_name
- (Required) The name of the virtual switch to bind this port group to. Forces a new resource if changed. -
vlan_id
- (Optional) The VLAN ID/trunk mode for this port group. An ID of0
denotes no tagging, an ID of1
-4094
tags with the specific ID, and an ID of4095
enables trunk mode, allowing the guest to manage its own tagging. Default:0
.
Policy Options
In addition to the above options, you can configure any policy option that is available under the vsphere_host_virtual_switch
policy options section. Any policy option that is not set is inherited from the virtual switch, its options propagating to the port group.
See the link for a full list of options that can be set.
Attribute Reference
The following attributes are exported:
-
id
- An ID unique to Terraform for this port group. The convention is a prefix, the host system ID, and the port group name. An example would betf-HostPortGroup:host-10:PGTerraformTest
. -
computed_policy
- A map with a full set of the policy options computed from defaults and overrides, explaining the effective policy for this port group. -
key
- The key for this port group as returned from the vSphere API. -
ports
- A list of ports that currently exist and are used on this port group.
© 2018 HashiCorpLicensed under the MPL 2.0 License.
https://www.terraform.io/docs/providers/vsphere/r/host_port_group.html