jameso
jameso

Reputation: 11

Why is my vsphere templates network disabled when deployed with Terraform

I have a vsphere template created using Packer for Ubuntu 22.04. The template creation works fine and generates the template. If I use vsphere to manually create a VM from the template the instance boots up and the network is working fine getting an IP address from the DHCP server.

If I use Terraform and the vSphere provider the instance is deployed successfully but the networking is not working. vSphere shows the network as connected and set to connect at power on. Yet if I look at the VM I can see that the interface is down and disabled.

Network Disabled

The only difference that I can see between the manually cloned instance and the Terraform instance is that the network interface names are different, on the manual clone it is ens32 (altname enp2s0) on the terraform instance it is ens192 (altname enp11s0). Although, both instances have been deployed to the same network.

What is interesting is that if I reboot the Terraform instance without making any changes the network will come up and start working.

I am using and older vSphere 6.5, Terraform v1.5.7 and ver 1.15.0 of the vSphere provider.

I have tried tweaking the Packer configuration for the template creation, although there is nothing unusual in the configuration for the autoinstall and the user-data section simply runs a cloud-init clean ---logs --seed --machine-id to reset the instance for the next deployment.

Any suggestions on what is taking place welcome

Upvotes: -2

Views: 692

Answers (1)

jameso
jameso

Reputation: 11

In typical fashion after asking a question I was able to find the problem.

It looks like packer defaults to using an e1000 network card and terraform vsphere provider defaults to using a vmxnet3 network card and the latter was failing to load a driver when it came up. Switching terraform to use and e1000 and the instance networking came up. I'm guessing that the reboot caused the instance to rescan update the necessary drivers. Need to see if I can get them working for those times I want to deploy with a vmxnet3 adapter.

Upvotes: 1

Related Questions