The Terraform Provider is a tool which enables operations such as create, update, and delete to manage infrastructure on vCloud Director.

Overview


Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions. Terraform Provider is a tool which is based on Terraform and works with configuration files. These configuration files contain all the information which is relevant enough to perform create/update/read/delete operations on the resources available on vCloud Director.

The current document covers the following Terraform Provider topics:

  1. Why New Terraform Provider Plugin?
  2. Architecure
  3. Installation and Configuration
    • Centos 7 Setup
      • Install Python 3.6
      • Install GO
      • Install Terraform
      • Configure Terraform Provider Binary
    • MacOS Setup
      • Install Python 3.6
      • Install GO
      • Install Terraform
      • Configure Terraform Provider Binary
  4. Run Setup using Scripts
  5. Use Cases
  6. Required Package Versions
  7. References
  8. Report Issues

Why New Terraform Provider Plugin?


VMware has a constant support to Terraform. To align with this support, VMware released a Terraform Provider Plugin for vCloud Director. But this new Terraform Provider Plugin has few advantages over the earlier released plugin such as,

  • The earlier plugin supports a limited scope in terms of resources to manage through vCloud Director. This new plugin in its this release provides support for resources such as Catalog, Catalog Item OVA, Catalog Item Media, Vapp, Vapp_VM, Independent Disk, ORG, ORG VDC and User to manage through vCloud Director. We at VMware, are actively contributing to this new provider plugin and we will keep including more resources in the upcoming releases as well.

  • The earlier plugin supports less number of parameters to perform various actions on the resources. This new plugin supports many parameters which eventually gives the ability to manage and customize resources based on the requirements. For example, this new plugin gives the ability to manage memory, CPU, virtual sockets, storage profiles and network over the resources on the fly.

  • The essential advantage of this new plugin is support from Pyvcloud API. This new plugin is entirely based on Pyvcloud API. Pyvcloud is a Python SDK from VMware which is an abstraction to vCloud Director. This API is actively contributed by VMware and open to contribution for the community as well. This API provides an extensive ability to automate the resource management through vCloud Director.

Terraform Provider Architecture


Terraform Provider has been developed using Python and GO. It uses Client-Server model inside the hood where the client has been written using GO and the server has been written using Python language. The core reason to use two different languages is to make a bridge between Terraform and Pyvcloud API. Pyvcloud is the SDK developed by VMware and provides a medium to talk to vCloud Director. Terraform uses GO to communicate where Pyvcloud has been written in Python3.

We are using GRPC Protocol to handle the communication between GO client and Python server.

Installaton and Configuration


CentOS 7 Setup

  • Install Python3.6
 
 yum group install "Development Tools" -y
 yum install wget zlib-devel sqlite-devel openssl openssl-devel -y
 wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
 tar -xvf Python*
 cd Python-3.6.4
 ./configure
 make
 make install


 python3 --version // output --> Python 3.6.4
 pip3.6 --version // output --> pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
 
 
  • Install GO
 
 cd /opt
 wget https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz
 tar -xvf go*
 export PATH=/opt/go/bin:$PATH
 export GOROOT=/opt/go


 go version // output --> go version go1.9.4
 
 
  • Install Terraform
 
 wget https://releases.hashicorp.com/terraform/0.11.4/terraform_0.11.4_linux_amd64.zip
 unzip terraform_0.11.4_linux_amd64.zip
 sudo mv terraform /usr/local/bin/


 terraform --version // output --> Terraform version: 0.11.4
 
 
  • Configure Terraform Provider Binary

It is a binary code written in GO and managed by VMware. This binary will be consumed by Terraform CLI. Terraform CLI uses this binary to maintain the infrastructure through vCloud Director. This GO binary is a pure abstraction to Terraform CLI for all the subsequent parts of the architecture. Internally, this binary sends GRPC requests as per the operation (create/update/read/delete) to the server and notify the user about the response received from the server.

To get the GO Binary, use the following command and put the binary in '/usr/local/bin/'

 
 cd /usr/local/bin/
 wget https://github.com/vmware/terraform-provider-vcloud-director/raw/master/builds/linux/terraform-provider-vcloud-director
 chmod +x terraform-provider-vcloud-director
 
 

MacOS 7 Setup

  • Install Python3.6
 
 wget https://www.python.org/ftp/python/3.6.4/python-3.6.4-macosx10.6.pkg

Above command will download the Python 3.6 installer. Run the installer and follow the instructions to install Python 3.6. To check the current version of python, run the following command in terminal.

 
 python3.6 --version // output --> 3.6.4
 pip3.6 --version // output --> pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

 
 
  • Install GO
 
 wget https://dl.google.com/go/go1.10.darwin-amd64.pkg

Above command will download the Go installer. Run the installer and follow the instructions to install Go. To check the current version of go, run the following command in terminal.


 go version // output --> go version go1.9.4 darwin/amd64
 
 
  • Install Terraform
 
 wget https://releases.hashicorp.com/terraform/0.11.4/terraform_0.11.4_darwin_amd64.zip
 unzip terraform_0.11.4_darwin_amd64.zip
 sudo mv terraform /usr/local/bin/


 terraform --version // output --> Terraform version: 0.11.4
 
 
  • Configure Terraform Provider Binary

It is a binary code written in GO and managed by VMware. This binary will be consumed by Terraform CLI. Terraform CLI uses this binary to maintain the infrastructure through vCloud Director. This GO binary is a pure abstraction to Terraform CLI for all the subsequent parts of the architecture. Internally, this binary sends GRPC requests as per the operation (create/update/read/delete) to the server and notify the user about the response received from the server.

To get the GO Binary, use the following command and put the binary in '/usr/local/bin/'

 
 cd /usr/local/bin/
 wget https://github.com/vmware/terraform-provider-vcloud-director/raw/master/builds/mac/terraform-provider-vcloud-director
 chmod +x terraform-provider-vcloud-director
 
 

Required Package Versions


Terraform Provider Plugin requires minimal versions of following packages,

  • vcd_cli >= 20.2.0
  • pyvcloud >= 19.2.0

Report Issues


Please refer to this to report issues and know more details about the project.