mkuzmin / terraform-provider-vmware Goto Github PK
View Code? Open in Web Editor NEWTerraform Provider for VMware vSphere
License: Mozilla Public License 2.0
Terraform Provider for VMware vSphere
License: Mozilla Public License 2.0
Not sure if Govmomi supports it, but we would like to be able to set some additional properties. For example, have a look at an example piece of a .vmx file on the ESX host in te /vmfs/volumes directory:
/vmfs/volumes/5486bf8c-adb425de-a078-6c3be5bda200/shd-lgc-proxy-001 # grep "machine\.id" shd-lgc-proxy-001.vmx
Result:
machine.id = "shd-lgc-proxy-001#shddmzams5-rhel64-template#shd-esx-005.bolcom.net"
As you can see the key "machine.id" is filled with some value. We use this value for PXE boot purposes. Do you think it's possible for terraform-vsphere to fill up these custom attributes?
Not sure if this is something I'm doing wrong getting "not enough arguments in call to govmomi.NewClient"
possibly using the wrong version of govmomi?
I'm using windows to build the package if that helps
# github.com/mkuzmin/terraform-vsphere
GO\src\github.com\mkuzmin\terraform-vsphere\config.go:22: not enough arguments in call to govmomi.NewClient
GO\src\github.com\mkuzmin\terraform-vsphere\resource_virtual_machine.go:105: cannot use client (type *govmomi.Client) as type *vim25.Client in argument to find.
NewFinder
GO\src\github.com\mkuzmin\terraform-vsphere\resource_virtual_machine.go:106: not enough arguments in call to finder.DefaultDatacenter
GO\src\github.com\mkuzmin\terraform-vsphere\resource_virtual_machine.go:111: client.Properties undefined (type *govmomi.Client has no field or method Properties
)
GO\src\github.com\mkuzmin\terraform-vsphere\resource_virtual_machine.go:120: client.SearchIndex undefined (type *govmomi.Client has no field or method SearchInd
ex)
GO\src\github.com\mkuzmin\terraform-vsphere\resource_virtual_machine.go:130: client.Properties undefined (type *govmomi.Client has no field or method Properties
)
GO\src\github.com\mkuzmin\terraform-vsphere\resource_virtual_machine.go:135: undefined: govmomi.Reference
GO\src\github.com\mkuzmin\terraform-vsphere\resource_virtual_machine.go:136: undefined: govmomi.Folder
GO\src\github.com\mkuzmin\terraform-vsphere\resource_virtual_machine.go:138: client.SearchIndex undefined (type *govmomi.Client has no field or method SearchInd
ex)
GO\src\github.com\mkuzmin\terraform-vsphere\resource_virtual_machine.go:148: undefined: govmomi.NewFolder
GO\src\github.com\mkuzmin\terraform-vsphere\resource_virtual_machine.go:148: too many errors
D:\Provisioning>go get github.com/mkuzmin/terraform-vsphere
Hi,
is your plugin the base for the one shipped with terraform or are they different ?
regards
Hi,
Here my stack trace from terraform:
vsphere_virtual_machine.jenkins: Creating...
cpus: "" => "1"
datacenter: "" => ""
folder: "" => ""
host: "" => ""
image: "" => "bastion"
ip_address: "" => ""
linked_clone: "" => "0"
memory: "" => "1"
name: "" => "jenkins"
power_on: "" => "1"
resource_pool: "" => "respool1"
vsphere_virtual_machine.jenkins: Error: 1 error(s) occurred:
1 error(s) occurred:
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
I use this simple config:
provider "vsphere" {
vcenter_server = "192.168.31.62:443"
user = "root"
password = "redacted"
insecure_connection = true
}
resource "vsphere_virtual_machine" "jenkins" {
name = "jenkins"
image = "bastion"
resource_pool = "respool1"
}
Any idea about this error message?
Thx
Terraform creates the machine all the way to the ethernet interface correctly, but doesn't poweron the box and instead fails with the error in the title. I'm not sure what I'm doing wrong. The template I'm cloning from is Windows. There doesn't seem to be any log beyond this generic message. What can I do to troubleshoot this. Here's my terraform.tf:
provider "vsphere" {
user = ""
password = ""
vcenter_server = ""
}
resource "vsphere_virtual_machine" "inttstsqlv04" {
name = "inttstsqlv04"
domain = "nt.local"
time_zone = "America/Denver"
datacenter = "DC AF"
cluster = "BL460V2"
vcpu = 2
memory = 4096
disk {
datastore = "VNXLun122_R6NLSAS"
template = "TEMPLATES/Windows Server 2012 R2 Terraform Template"
}
network_interface {
label = "BO 10.122.12.x"
ip_address = "10.122.12.42"
subnet_mask = "255.255.255.0"
}
}
For some reason I cannot clone an existing VM. I have created a very simple virtual machine which I want to clone to another VM. My .tf file looks like this:
provider "vsphere" {
# Variables VSPHERE_USER and VSPHERE_PASSWORD can also be environment variables.
server = "vmware-hostnamet"
user = "root"
password = "bla"
}
resource "vsphere_virtual_machine" "machine" {
name = "dummy-vm"
source = "dummy-vm"
datacenter = "datacenter-poc"
### optional parameters
# if true, create a linked clone from a latest snapshot
# if false (default), create a full clone from a current state
linked_clone = false
power_on = false
}
The output of the terraform apply
command is this:
vsphere_virtual_machine.machine: Creating...
cpus: "" => "<computed>"
datacenter: "" => "datacenter-poc"
folder: "" => "<computed>"
host: "" => "<computed>"
ip_address: "" => "<computed>"
linked_clone: "" => "0"
memory: "" => "<computed>"
name: "" => "dummy-vm"
pool: "" => "<computed>"
power_on: "" => "0"
source: "" => "dummy-vm"
vsphere_virtual_machine.machine: Error: Error clonning vm: The operation is not supported on the object.
What am I doing wrong? Please see below a screenshot of the task which is generated inside the vCenter web interface.
Add an option to create a machine, add a snapshot, and convert it to a template (required for further linked clones)
It would be very useful is we could (optional) alter hard disk size. For example:
resource "vsphere_virtual_machine" "web" {
name = "bla"
folder = "/linux"
image = "/linux/dummy-vm"
linked_clone = false
cpus = 2
memory = 4096
power_on = false
disk_size = 20480
}
Hi,
first of all kudos for your great vsphere provider. I'm using it in my Cloud self service portal.
Works really good so far.
At the moment I'm working on this issue:
Is it possible to specify additional disks for a VM? I have seen some lines in the GO code.
Could you please provide a terraform example?
That would be great.
Thx.
At the moment a machine s cloned from latest snapshot.
Add a option to clone from a current state (not valid for linked clones)
Add options to change RAM size and number of CPUs of cloned machines.
Hi,
I want to modify "terraform-provider-vsphere" provider to include 2 more fields while creating vms.
These 2 parameters will be calculated at run time.(may be when we say terraform plan/ apply)
Please suggest the pointers for the same.
Thank you.
At the moment only Linux guests are supported.
(related issue: #2)
At the moment nodes are powered off instantly.
Need to shut down OS, and let application be safely closed.
Is it possible to set a static IP address? It looks like the ip_address config setting is only computed, which will work fine for DHCP type situations, but not for those needing to have static IPs assigned.
I'm trying to use the plugin, but I'm having a hard time finding out what parameters I should use. F.e. "source". Is it the existing VM / template which I want to clone? How do I obtain the full value? What is a "pool" and how to find it's value. So a little more docs/info about what to use as parameters would be highly appreciated.
name = "machine1"
source = "datacenter-poc/vm/dummy-vm"
datacenter = "datacenter-poc"
folder = "rogier-cloned-vm"
host = "rogier-hostname"
pool = "Resource/Pool"
add optional insecure
parameter
After VM is started, save its IP address to Terraform's state file, so other resources can reference it.
source
parameter requires a full path to VM in form of Full/Path/to/VM
.
VM name is an unique property, and can be resolved without a path.
At the moment the provider can create new VMs, but if Terraform state parameters are changed (i.e. machine is renamed), it cannot update properties of already running vm.
vsphere_virtual_machine.machine: Error: doesn't support update
At the moment terraform refresh
updates VM name only.
Other properties like VM folder, host, and resource pool should be also updated.
At the moment guest customization is performed with a set of hard-coded parameters:
Provide a setting to use external customization specs stored in vCenter.
(related issue: #2)
Commit bbb3f2e introduced a bug.
If VM is powered off, then terraform destroy
fails, because WaitForResult()
returns an error legitimately.
>terraform destroy -force test\1-empty
vmware_virtual_machine.vm: Refreshing state... (ID: vm-23)
vmware_virtual_machine.vm: Destroying... (ID: vm-23)
Error applying plan:
1 error(s) occurred:
* vmware_virtual_machine.vm (destroy): 1 error(s) occurred:
* vmware_virtual_machine.vm: Error powering vm off: The attempted operation cannot be performed in the current state (Powered off).
Something was changed in Terraform 0.5.
Configuration
configuration_parameters = {
isolation.tools.copy.disable = "false"
isolation.tools.paste.disable = "false"
}
produces this output:
vsphere_virtual_machine.vm: Creating...
configuration_parameters.#: "" => "2"
configuration_parameters.isolation.tools.copy.disable: "" => ""
configuration_parameters.isolation.tools.paste.disable: "" => ""
And parameters are not added.
But parameters without dot-sign are added correctly.
Recent change e90ad49 introduced a bug:
>terraform apply test\1-empty
vmware_virtual_machine.vm: Creating...
1 error(s) occurred:
* vmware_virtual_machine.vm: unexpected EOF
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
anypanic: interface conversion: interface {} is main.providerMeta, not *main.providerMeta
2017/04/08 15:12:33 [DEBUG] plugin: terraform-provider-vmware.exe:
2017/04/08 15:12:33 [DEBUG] plugin: terraform-provider-vmware.exe: goroutine 81 [running]:
2017/04/08 15:12:33 [DEBUG] plugin: terraform-provider-vmware.exe: main.resourceVirtualMachineCreate(0xc0423cebd0, 0xf9d660, 0xc042441f40, 0x0, 0x0)
2017/04/08 15:12:33 [DEBUG] plugin: terraform-provider-vmware.exe: C:/Users/michael.kuzmin/Projects/go/src/github.com/mkuzmin/terraform-provider-vmware/resource_virt
ual_machine.go:112 +0x4115
Full log at https://gist.github.com/mkuzmin/d95d79c149d99674e892d0b665dfdccc
I'm trying to clone from a template, but it results in the error below. However I don't see the parameter "spec.location.pool" in the lost of possible params. What parameter is missing? And what value should it be set to? By the way: cloning from a virtual machine (instead of template) is working fine! Great work.
Error applying plan:
1 error(s) occurred:
* Error clonning vm: A specified parameter was not correct.
spec.location.pool
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
I just opened an issue in the main Terraform project that suggests the terrarform-vsphere provider is not providing the default Host/IP when using SSH as the provisioner (at least in my case.)
Here's the other issue: hashicorp/terraform#2237
Am I right in thinking terraform-vsphere should be providing this default value?
Hi,
I get following error while running plan.
terraform plan
There are warnings and/or errors related to your configuration. Please
fix these before continuing.
Errors:
vsphere_virtual_machine: No Update defined, must set ForceNew on: []string{"domain", "gateway", "power_on", "subnet_mask"}
Please have a look at it.
Thank you.
Regards,
Kanhaiya
Update VM hostname and network settings
what do if your ESX Data Centre has no pools
it is clustered but no resource pools
not sure which value to use for resource_pool if no pool exists
thanks
When target host does not have access to a datastore where source image is placed, Terraform fails with error like Unable to access the virtual machine configuration: Unable to access file [vm-Vagrant] ubuntu-SNAPSHOT/ubuntu-SNAPSHOT.vmtx
.
Need to detect target datastore automatically, or specify it explicitly.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.