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
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.
user
- (Required) This is the user name to access to vCenter server.
password
- (Required) This is the password to access to vCenter server.
vcenter_server
- (Required) This is a target vCenter server, such as "vcenter.my.domain.com"
Resource Configuration
vsphere_virtual_machine
resource "vsphere_virtual_machine" "default" {
name = "VM name"
datacenter = "Datacenter name"
cluster = "Cluster name"
datastore = "Datastore name"
template = "centos-6.6-x86_64" # Template name
vcpu = 2
memory = 4096
gateway = "Gateway ip address"
network_interface {
device_name = "NIC name" # e.g. eth0
label = "Network label name"
ip_address = "IP address"
subnet_mask = "Subnet mask"
}
}
Argument Reference
The following arguments are supported.
name
- (Required) Hostname of the virtual machine
template
- (Required) VM template name
vcpu
- (Required) A number of vCPUs
memory
- (Required) Memory size in MB.
network_interface
- (Required) Network configuration.
datacenter
- (Optional) Datacenter name
cluster
- (Optional) Cluster name, a cluster is a group of hosts.
resource_pool
- (Optional) Resource pool name.
datastore
- (Optional) Datastore name
gateway
- (Optional) Gateway IP address. If you use the static IP address, it's required.
domain
- (Optional) Domain configuration. By default, it's "vsphere.local".
dns_suffix
- (Optional) List of DNS suffix. By default, it's ["vsphere.local"]
.
dns_server
- (Optional) List of DNS server. By default, it's ["8.8.8.8", "8.8.4.4"]
.
Each network_interface
supports the following:
device_name
- (Required) Network interface device name.
label
- (Required) Network label name.
ip_address
- (Optional) IP address. DHCP configuration in default. If you use the static IP address, it's required.
subnet_mask
- (Optional) Subnet mask. If you use the static IP address, it's required.
For example
resource "vsphere_virtual_machine" "default" {
name = "foo-1"
template = "centos-6.6-x86_64" # Template name
vcpu = 2
memory = 4096
network_interface {
device_name = "eth0" # e.g. eth0
label = "VM Network"
}
}
Contribution
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
)
- Commit your changes (
git commit -am 'Add some feature'
)
- Push to the branch (
git push origin my-new-feature
)
- Create new Pull Request
Licence
Mozilla Public License, version 2.0
Author
tkak