This year marks a focused support for HashiCorp Terraform in VMware vCloud Director (vCD). The refreshed Terraform vCloud Director provider enables administrators and DevOps engineers to define vCD infrastructure as code inside Terraform configuration files. This makes it an efficient automation and integration tool.
We already released two new provider versions this year (v2.0.0 and v2.1.0). More releases are on the way. Most importantly, with the latest version you can automate creation of the following resources:
- Catalog with ability to upload OVA and ISO items to it
- Org VDC networks (routed, direct and isolated)
- vApp and vApp level networks
- VMs, which can use the uploaded OVA, networks and mount an ISO when needed
- Firewall rules and DNAT/SNAT rules that can enable access to the VMs
- Independent disks and ability to attach them to the VMs
- Various VM configuration parameters: CPU and cores, custom boot script, etc.
Please see the official documentation at the HashiCorp portal below for all currently available features and details. Note, that current release supports all vCD versions from v8.20 to the latest v9.7.
https://www.terraform.io/docs/providers/vcd/index.html
Open-Source and 100% written in Go
The project itself is fully open-source and available on GitHub. HashiCorp is hosting it in the “terraform-providers” namespace together with all the other official Terraform providers. If you’d like to contribute with a feature request, report an issue or propose a code improvement please visit the project’s site below. There you can also see current activity and what’s in the works.
https://github.com/terraform-providers/terraform-provider-vcd
To make it trivial to setup and use, Terraform vCloud Director Provider v2 is using Go programming language exclusively (just like the overall Terraform platform). This means we are also able to fully integrate it with HashiCorp build and download system. As a result for a user, all it takes to get the new provider is to prepare a .tf configuration file, define the “vcd” provider there and execute terraform init from the console. Terraform will take care of downloading and enabling the provider for you.
It’s worth noting that for making calls to vCloud Director API the provider is using a Go library (SDK). This library is also open-source and available on GitHub below. Please take a look if you are developing applications written in Go and need an easy way of calling vCloud Director.
https://github.com/vmware/go-vcloud-director
Example Configuration
Here’s a small .tf configuration file that illustrates how you could automate creation of a catalog, upload an OVA to it, and also create an independent disk. You can similarly extend this example to create a vApp with VM that would use all these items.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# Configure the VMware vCloud Director Provider provider “vcd” { url = “https://${var.vcd_host}/api” org = “myorg” vdc = “myorgvdc” user = “orgadmin” password = “${var.org_pass}” allow_unverified_ssl = “true” } # Catalog for OVAs and ISOs (v2.0.0+) resource “vcd_catalog” “OperatingSystems” { name = “OperatingSystems” description = “OS templates” delete_force = “true” delete_recursive = “true” } # OVA for catalog (v2.0.0+) resource “vcd_catalog_item” “OVA” { catalog = “OperatingSystems” name = “photon” description = “Linux VM” ova_path = “/home/images/ova/photon-hw11-3.0-26156e2.ova” show_upload_progress = true depends_on = [“vcd_catalog.OperatingSystems”] } # Independent disk (v2.1.0+) resource “vcd_independent_disk” “TerraformDisk” { name = “tf-disk” size = “1024” bus_type = “SCSI” bus_sub_type = “VirtualSCSI” } |
Next Steps
All in all, we are actively working on further extending and enhancing functionality of the Terraform vCD provider. Likewise, we are also supporting community efforts around it and doing our best to (a) listen to feedback and (b) help merge the code from contributors in an efficient, safe and high quality way. Hence, if you’re a Terraform user or have questions, please join us on GitHub or come by to our Slack channel for a chat!
Here are the take-away links from this post.
Hope to see you there!