Closed mmanjos closed 2 years ago
Here is terraform.state after the failed apply (note the uplink
map is empty):
{
"version": 4,
"terraform_version": "1.1.0",
"serial": 1,
"lineage": "e3363f99-0ca4-70a7-b933-e5531ee85c07",
"outputs": {},
"resources": [
{
"mode": "managed",
"type": "esxi_vswitch",
"name": "vSwitch1",
"provider": "provider[\"registry.terraform.io/josenk/esxi\"]",
"instances": [
{
"status": "tainted",
"schema_version": 0,
"attributes": {
"forged_transmits": false,
"id": "vSwitch1",
"link_discovery_mode": "listen",
"mac_changes": false,
"mtu": 1500,
"name": "vSwitch1",
"ports": 128,
"promiscuous_mode": false,
"uplink": []
},
"sensitive_attributes": [],
"private": "bnVsbA=="
}
]
}
]
}
And even outside of terraform, if I run this command directly on the esxi host itself, I get the same error:
[root@lab:~] esxcli network vswitch standard uplink add -u "vmnic2" -v "vSwitch1"
Unable to Set: Busy
Ah - darn; found my problem. I really thought vmnic2 was the one I wanted to target, but I was using the wrong interface that was already tied up.
Fixed my typo and now the apply is working great - thanks!
Thanks for the update.... Glad it was an easy fix.
Actually, just ran into another issue after it was done; my setup has a vswitch and 5 port groups created by terraform from a completely clean state, followed by a VM that's connected to one of the port groups.
The vswitch, uplink and first port group provisioned fine but for some reason, the following 4 port groups failed to create. The VM that was created at the end was supposed to be attached to one of the 4 port groups that didn't get created, so it was created in a disconnected state.
Re-running terraform apply
noticed the missing portgroups needed to be created, and once they were it seemed like they were working but the VM that was created earlier was still disconnected and wasn't automatically re-joined to the right network.
Am I using terraform the right way (and is this a bug?) or should I have two tf files, one for the network environment setup and then one for VMs only after the network is ready?
Ah, that works much better :) I just added the appropriate depends_on
statements and now everything's nice and happy. Thanks again for your work on developing this module!
If you are properly referring the resources, you should not need to use depends_on...
You can use Terraform however you like. If you layer in two separate Terraform files, you will want to load the first layer (network in your case) using the data resource.
https://www.terraform.io/docs/language/data-sources/index.html
Ah - thanks. That makes more sense, and I think also explains some issues I had before as well. I've been referencing the resources by name/string not specific terraform reference. Fixing that will probably help a lot.
Description I'm trying to create a basic vswitch with one uplink:
The ESXi server is running 7.0 Update 2
After the failed apply, vSwitch1 does get created and remains as a network resource in my ESXi server, but it has no uplinks assigned to it. Re-running the
terraform apply
afterwards gets the same results (no change)To Reproduce If I clear any "vSwitch1" configs on the actual esxi server and then
terraform apply
, I get the following error:Desktop (please complete the following information):
Apologies in advance if I'm using the esxi_vswitch resource incorrectly - I'm just getting started with terraform. I can create esxi_guests just fine with my setup, but this vswitch config doesn't work.