-
Notifications
You must be signed in to change notification settings - Fork 16
Getting Started Guide
Note: NSX security tag resource requires vsphere provider to implement moid parameter which is not yet push to upstream terraform.
You can use the latest docker image of built for latest tag. This image includes vsphere-provider binary with moid code implemented, so security tag resource works with it.
s1drg01-v01.paas.int.ovp.bskyb.com/paas/gonsx-demo:0.2.10
docker run -it --name nsx_test -v <path to terraform templates>:/paas/demo s1drg01-v01.paas.int.ovp.bskyb.com/paas/gonsx-demo:0.2.10 /bin/bash
root@e09f2447b363:~# which terraform
/usr/local/terraform/terraform
root@e09f2447b363:~#
root@e09f2447b363:/usr/local/terraform# ls -la
total 165304
drwxr-xr-x 1 root root 4096 May 5 12:27 .
drwxr-xr-x 1 root root 4096 Apr 6 12:35 ..
-rwxrwxr-x 1 root root 98199616 Mar 2 18:48 terraform
-rwxr-xr-x 1 root root 9425712 May 17 14:41 terraform-provider-nsx
-rwxr-xr-x 1 root root 37579678 May 5 12:27 terraform-provider-vsphere
-rw-r--r-- 1 root root 24049614 Mar 2 18:49 terraform_0.8.8_linux_amd64.zip
root@e09f2447b363:/usr/local/terraform#
As you can see in above output, you will have two binaries terraform-provider-nsx
and terraform-provider-vsphere
root@e09f2447b363:/usr/local/terraform# cd /paas/demo/
root@e09f2447b363:/paas/demo# ls -la
total 604
drwxr-xr-x 12 root root 408 May 19 12:06 .
drwxr-xr-x 1 root root 4096 May 17 12:43 ..
-rw-r--r-- 1 root root 5775 May 19 12:06 demo-nsx.tf
-rw-r--r-- 1 root root 1538 May 17 12:48 demo-vm.tf
-rw-r--r-- 1 root root 428 May 5 14:10 vars.tf
root@e09f2447b363:/paas/demo#
You should see your mounted terraform template, and should be able to run terraform plan
and/or terraform apply
commands with your templates. Read further down in this file on how to write your terraform templates.
These instructions were tested against version 1.8 of Go and Terraform version 0.8.8.
Assuming that you have already got GOPATH setup (see https://golang.org/doc/code.html for details). Do the following:
go get github.com/sky-uk/terraform-provider-nsx
This will also build the binary and add the terraform-provider-nsx
plugin into the $GOPATH/bin
.
Note: you will need to build vsphere-provider with moid functionality as well, from https://github.com/sky-uk/terraform/tree/OREP-176 branch to work with above binary.
# Configure the VMware NSX Provider
provider "nsx" {
nsxusername = "username"
nsxpassword = "password"
nsxserver = "nsx_server_address"
}
# Create a logical switch
resource "nsx_logic_switch" "OVP_1" {
...
}
create a terraform template file named 'demo-nsx.tf' with above content, and update the nsx_server and username, and password variables with actual values for your environment.
Run the terraform plan command to see it can communicate with VSphere NSX and produce a plan output.
terraform plan
if the above command worked properly, it should output a terraform plan outlining the NSX resources it's going to create, you can execute the apply command to implement the plan.
terraform apply