/ Tools

Terraform

Quickstart

Installation is just download bin & unzip

mkdir terraform
cd terraform
wget https://releases.hashicorp.com/terraform/0.9.11/terraform_0.9.11_linux_amd64.zip
unzip terraform_0.9.11_linux_amd64.zip

Write down a main.tf file. This one will create a test folder, and create and boot a new VM from a template there.

# Configure the VMware vSphere Provider
provider "vsphere" {
  user           = "vsphere.admin@company.com"
  password       = "XXXXXXXXXXXXXXX"
  vsphere_server = "vcenter.prod.company.com"
  allow_unverified_ssl = true
}

# Create a folder
resource "vsphere_folder" "test_folder" {
  path = "terraform_test"
  datacenter = "DC-COMPANY"
}

# Create a virtual machine within the folder
resource "vsphere_virtual_machine" "terraform_vm" {
 name   = "terraform01"
 folder = "${vsphere_folder.test_folder.path}"
 vcpu   = 1
 memory = 1024
 datacenter = "DC-COMPANY"
 cluster = "Cluster1"
 # resource_pool = "Cluster1/Test"
 disk {
   template = "_TEMPLATES/Template_CentOS7_x86-64"
   datastore = "TESTNAS01"
 }
 domain = "company.com"
 network_interface {
   label = "VLAN89"
   ipv4_address       = "10.200.89.123"
   ipv4_prefix_length = "24"
   ipv4_gateway       = "10.200.89.254"
 }
}

Run

./terraform apply
Terraform
Share this