Terraform vSphere provider is alive again – hostname variable

Yes, I have been waiting for it for a long time! When Hashicorp decided to separate Terraform Core from Providers, vSphere Provider died. It lasted two months – no merging, no new releases. But it has changed at the end of the August – Chris Marchesi (better known as vancluever) took the matter into his own hands and he’s now taking care of re the repository. It’s great news, especially for those of us who use Terraform in the daily work with the vSphere.

Terraform vSphere provider allows to use different hostname and name

Chris has made a lot of work since August and for now, two releases were published. In one of them, you can find my small improvement. In my work, we use underscores in the virtual machines’ names, what is forbidden in hostnames (look at this post for more details). It was a little bit annoying when we had to change the VM name and then run Storage vMotion (without this .vmkd files wouldn’t be able to change their names). So I “repaired” it and created the pull request to the vSphere Provider repository. It has been merged and since the v0.2.1 there is a possibility to use hostname variable!

As you can see, it’s very simple to use. You can define a new variable “hostname” and assign a value which will be used during the customization. If you don’t want to use a different hostname, you don’t need to define this variable! Omitting “hostname” will cause that an old behavior will be used – the name and the hostname will be the same. I’ve just updated my example Terraform configuration for vSphere which you can find on Github.

Of course, there are more changes! For example, four new resources and two new data sources were added.

Resources:

  • vsphere_datacenter
  • vsphere_license
  • vsphere_host_virtual_switch
  • vsphere_host_port_group

Data Sources:

  • vsphere_datacenter
  • vsphere_host

You can also find some bug fixes and other improvements. In other words – Terraform vSphere Provider is alive again!

Leave a Reply

Your email address will not be published. Required fields are marked *