amcbarnett / PNC

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terraform & vSphere Demo

For Virtual Machine Provisioning using the vSphere Provider.

There are 3 different examples, one in each folder.

Pre-Requisites and Tips

  1. Set the vSphere Environment Variables:
export VSPHERE_USER="<Username>@vsphere.local"
export VSPHERE_PASSWORD="<Password>"
export VSPHERE_SERVER="<IP Address>"
export VSPHERE_ALLOW_UNVERIFIED_SSL=true
  1. All examples tested using Terraform v11.11. If using a different version, you may experience issues.

  2. All examples tested using the vSphere Provider v1.9.1_x4. If using a different version, you may experience issues.

  3. Clone this repo to your local directory.

git clone git@github.com:Arslan-SE/PNC.git
  1. Destroy the changes and provision resources (if any).
terraform destroy

1_getVsphereData

  • This example is very simple. It pulls some data from the vCenter environment.
  1. Navigate to the example:
cd 3_getVsphereData/
  1. Save the terraform.tfvars.example file as terraform.tfvars and update the values.
cp terraform.tfvars.example terraform.tfvars
vi terraform.tfvars
  1. Initialize Terraform to pull the providers.
terraform init
  1. Make a dry run to see what will actually happen.
terraform plan
  1. Apply the changes and provision resources (if any).
terraform apply

2_createSomeResources

  • This example will provision a folder and then apply tags and attributes to that folder.
  1. Navigate to the example:
cd 3_create_SomeResources/
  1. Save the terraform.tfvars.example file as terraform.tfvars and update the values.
cp terraform.tfvars.example terraform.tfvars
vi terraform.tfvars
  1. Initialize Terraform to pull the providers.
terraform init
  1. Make a dry run to see what will actually happen.
terraform plan
  1. Apply the changes and provision resources (if any).
terraform apply
  1. Destroy the changes and provision resources (if any).
terraform destroy

3_create_VmResource

  • This example brings the other two examples together along with provisioning a VM using a cloned template.
  1. Navigate to the example:
cd 3_create_VmResource/
  1. Save the terraform.tfvars.example file as terraform.tfvars and update the values.
cp terraform.tfvars.example terraform.tfvars
vi terraform.tfvars
  1. Initialize Terraform to pull the providers.
terraform init
  1. Make a dry run to see what will actually happen.
terraform plan
  1. Apply the changes and provision resources (if any).
terraform apply
  1. Destroy the changes and provision resources (if any).
terraform destroy

Authors

Edited by Arslan Saeed

License

MIT

About


Languages

Language:HCL 100.0%