josenk / terraform-provider-esxi

Terraform-provider-esxi plugin
GNU General Public License v3.0
538 stars 154 forks source link

Terraform Provider

Requirements

Building The Provider

In general, you don't normally need to build the provider unless you are planning to make changes to it. A release can be downloaded from github, or can automatically be downloaded with terraform 0.13+.

You first must set your GOPATH. If you are unsure, please review the documentation at.

https://github.com/golang/go/wiki/SettingGOPATH

Clone repository to: $GOPATH/src/github.com/josenk/terraform-provider-esxi


mkdir $HOME/go
export GOPATH="$HOME/go"

go get -u -v golang.org/x/crypto/ssh
go get -u -v github.com/hashicorp/terraform
go get -u -v github.com/josenk/terraform-provider-esxi

cd $GOPATH/src/github.com/josenk/terraform-provider-esxi
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags '-w -extldflags "-static"' -o terraform-provider-esxi_`cat version`

sudo cp terraform-provider-esxi_`cat version` /usr/local/bin

Terraform-provider-esxi plugin

What's New:

Features and Compatibility

This is a provider! NOT a provisioner.

Vagrant vs Terraform.

If you are using vagrant as a deployment tool (infa as code), you may want to consider a better tool. Terraform. Vagrant is better for development environments, while Terraform is better at managing infrastructure. Please give my terraform plugin a try and give me some feedback. What you're trying to do, what's missing, what works, what doesn't work, etc...

https://www.vagrantup.com/intro/vs/terraform.html https://github.com/josenk/terraform-provider-esxi https://github.com/josenk/vagrant-vmware-esxi

Why this plugin?

Not everyone has vCenter, vSphere, expensive APIs... These cost $$$. ESXi is free!

How to install

How to use and configure a main.tf file

  1. cd SOMEDIR
  2. vi main.tf # Use the contents of this example main.tf as a template. Specify provider parameters to access your ESXi host. Modify the resources for resource pools and guest vm.
terraform {
  required_version = ">= 0.12"
}

provider "esxi" {
  esxi_hostname      = "esxi"
  esxi_hostport      = "22"
  esxi_hostssl       = "443"
  esxi_username      = "root"
  esxi_password      = "MyPassword"
}

resource "esxi_guest" "vmtest" {
  guest_name         = "vmtest"
  disk_store         = "MyDiskStore"

  #
  #  Specify an existing guest to clone, an ovf source, or neither to build a bare-metal guest vm.
  #
  #clone_from_vm      = "Templates/centos7"
  #ovf_source        = "/local_path/centos-7.vmx"

  network_interfaces {
    virtual_network = "VM Network"
  }
}

Basic usage

  1. terraform init
  2. terraform plan
  3. terraform apply
  4. terraform show
  5. terraform destroy

Configuration reference

Using ovf_source & clone_from_vm

Known issues with vmware_esxi

Donations

I work very hard to produce a stable, well documented product. I appreciate any payments or donations for my efforts.

Version History