From b309bed8fe56aad646f8750b437ba8118acbd78a Mon Sep 17 00:00:00 2001 From: Jared Burns Date: Fri, 6 Sep 2024 10:44:58 -0400 Subject: [PATCH] docs: network_interface update Updated network interface markdown file to try to better explain network interface order Closes #2101 Signed-off-by: Jared Burns --- CHANGELOG.md | 4 +++ website/docs/r/virtual_machine.html.markdown | 35 ++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b83bb946..9c4e52089 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ BUG FIX: * `resource/vsphere_resource_pool`: Removes the default setting for `scale_descendants_shares` to allows for inheritance from the parent resource pool. ([#2255]https://github.com/hashicorp/terraform-provider-vsphere/pull/2255) + +DOCUMENTATION: +* updated `virtual_machine.html.markdown` to include clarification of network_interface assignment. + ([#2256]https://github.com/hashicorp/terraform-provider-vsphere/pull/2256) ## 2.9.0 (September 3, 2024) diff --git a/website/docs/r/virtual_machine.html.markdown b/website/docs/r/virtual_machine.html.markdown index 05237aadf..9b1332e14 100644 --- a/website/docs/r/virtual_machine.html.markdown +++ b/website/docs/r/virtual_machine.html.markdown @@ -963,20 +963,49 @@ Interfaces are assigned to devices in the order declared in the configuration an **Example**: +data "vsphere_network" "routable" { + name = var.routable_network + datacenter_id = data.vsphere_datacenter.datacenter.id +} + +data "vsphere_network" "not_routable" { + name = "var.non_routable_network" + datacenter_id = data.vsphere_datacenter.datacenter.id +} + ```hcl resource "vsphere_virtual_machine" "vm" { # ... other configuration ... network_interface { - network_id = data.vsphere_network.public.id + network_id = data.vsphere_network.routable.id } network_interface { - network_id = data.vsphere_network.private.id + network_id = data.vsphere_network.non_routable.id } # ... other configuration ... } + + clone { + template_uuid = data.vsphere_virtual_machine.template.id + customize { + linux_options { + host_name = "foo" + domain = "example.com + } + network_interface { + ipv4_address = "10.0.0.10" + ipv4_netmask = 24 + } + network_interface { + ipv4_address = "172.16.0.10" + ipv4_netmask = 24 + } + ipv4_gateway = "10.0.0.1" + } + } ``` -In the above example, the first interface is assigned to the `public` network and will also appear first in the interface order. The second interface is assigned to the `private` network. On some Linux distributions, first interface may be presented as `eth0` and the second may be presented as `eth1`. +In the above example, the first interface is assigned to the `routable` based on order of sequential order which in this case the first network to be assigned a ip address would be the routable network i.e. `10.0.0.10`. The second interface is assigned to the `non_routeable` network i.e. `172.16.0.10`. On some Linux distributions, first interface may be presented as `eth0` and the second may be presented as `eth1`. The options are: