rakutentech / terraform-provider-vsphere

[DEPRECATED] Terraform Custom Provider for VMware vSphere
Mozilla Public License 2.0
82 stars 30 forks source link

terraform-provider-vsphere

WARNING: This repository has been deprecated. Please use the official provider at terraform-providers/terraform-provider-vsphere.

GitHub release Wercker Go Documentation

Terraform Custom Provider for VMware vSphere

Description

This project is a terraform custom provider for VMware vSphere. This is work in progress. This current version only supports creation and deletion of virtual machine with VM template.

Requirement

VM template specification

In this use case, please don't include network adapters in VM template. When deploying a new virtual machine, this provider adds new network adapters to the new virtual machine. Supported network adapter type in the current version is VMXNET 3 only.

Usage

Provider Configuration

vsphere

provider "vsphere" {
    user = "${var.vsphere_user}"
    password = "${var.vsphere_password}"
    vcenter_server = "${var.vsphere_vcenter}"
}
Argument Reference

The following arguments are supported.

Resource Configuration

vsphere_virtual_machine

resource "vsphere_virtual_machine" "default" {
    name = "VM name"
    datacenter = "Datacenter name"
    cluster = "Cluster name"
    vcpu = 2
    memory = 4096
    disk {
        datastore = "Datastore name"
        template = "templates/centos-6.6-x86_64"
    }
    gateway = "Gateway ip address"
    network_interface {
        label = "Network label name"
        ip_address = "IP address"
        subnet_mask = "Subnet mask"
    }
}
Argument Reference

The following arguments are supported.

Each network_interface supports the following:

The disk block supports the following:

For the first disk,

For the second and following disks,

For example

Example 1:

resource "vsphere_virtual_machine" "default" {
    name = "newvm-1"
    vcpu = 2
    memory = 4096
    disk {
        template = "centos-6.6-x86_64"
    }
    network_interface {
        label = "label-1"
    }
}

Example 2:

resource "vsphere_virtual_machine" "default" {
    name = "newvm-1"
    domain = "foo"
    datacenter = "datacenter-1"
    cluster = "cluster-1"
    vcpu = 2
    memory = 4096
    disk {
        datastore = "datastore-1"
        template = "centos-6.6-x86_64"
        iops = 500
    }
    disk {
        size = 20
        iops = 500
    }
    gateway = "192.168.0.254"
    network_interface {
        label = "label-1"
        ip_address = "192.168.0.1"
        subnet_mask = "255.255.255.0"
    }
    network_interface {
        label = "label-2"
    }
}

Example 3:

resource "vsphere_virtual_machine" "default" {
    name = "newvm-1"
    domain = "foo"
    datacenter = "datacenter-1"
    cluster = "cluster-1"
    vcpu = 2
    memory = 4096
    disk {
        datastore = "datastore-1"
        size = 10
        iops = 500
    }
    disk {
        size = 20
        iops = 500
    }
    network_interface {
        label = "label-1"
    }
    network_interface {
        label = "label-2"
    }
    time_zone = "Asia/Tokyo"
}

Contribution

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Licence

Mozilla Public License, version 2.0

Author

tkak