diff --git a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go index e2fc3cb6f..62fa85e4e 100644 --- a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go +++ b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go @@ -84,6 +84,7 @@ type virtualMachine struct { dnsServers []string bootableVmdk bool linkedClone bool + skipCustomization bool windowsOptionalConfig windowsOptConfig customConfigurations map[string](types.AnyType) } @@ -196,6 +197,13 @@ func resourceVSphereVirtualMachine() *schema.Resource { ForceNew: true, }, + "skip_customization": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Default: false, + }, + "custom_configuration_parameters": &schema.Schema{ Type: schema.TypeMap, Optional: true, @@ -437,6 +445,10 @@ func resourceVSphereVirtualMachineCreate(d *schema.ResourceData, meta interface{ vm.linkedClone = v.(bool) } + if v, ok := d.GetOk("skip_customization"); ok { + vm.skipCustomization = v.(bool) + } + if raw, ok := d.GetOk("dns_suffixes"); ok { for _, v := range raw.([]interface{}) { vm.dnsSuffixes = append(vm.dnsSuffixes, v.(string)) @@ -1575,17 +1587,21 @@ func (vm *virtualMachine) deployVirtualMachine(c *govmomi.Client) error { return err } - taskb, err := newVM.Customize(context.TODO(), customSpec) - if err != nil { - return err + if vm.skipCustomization { + log.Printf("[DEBUG] VM customization skipped") + } else { + log.Printf("[DEBUG] VM customization starting") + taskb, err := newVM.Customize(context.TODO(), customSpec) + if err != nil { + return err + } + _, err = taskb.WaitForResult(context.TODO(), nil) + if err != nil { + return err + } + log.Printf("[DEBUG] VM customization finished") } - _, err = taskb.WaitForResult(context.TODO(), nil) - if err != nil { - return err - } - log.Printf("[DEBUG] VM customization finished") - for i := 1; i < len(vm.hardDisks); i++ { err = addHardDisk(newVM, vm.hardDisks[i].size, vm.hardDisks[i].iops, vm.hardDisks[i].initType, datastore, vm.hardDisks[i].vmdkPath) if err != nil { diff --git a/website/source/docs/providers/vsphere/r/virtual_machine.html.markdown b/website/source/docs/providers/vsphere/r/virtual_machine.html.markdown index 9027bbc36..1de12ddcd 100644 --- a/website/source/docs/providers/vsphere/r/virtual_machine.html.markdown +++ b/website/source/docs/providers/vsphere/r/virtual_machine.html.markdown @@ -80,6 +80,7 @@ The following arguments are supported: * `windows_opt_config` - (Optional) Extra options for clones of Windows machines. * `linked_clone` - (Optional) Specifies if the new machine is a [linked clone](https://www.vmware.com/support/ws5/doc/ws_clone_overview.html#wp1036396) of another machine or not. * `custom_configuration_parameters` - (Optional) Map of values that is set as virtual machine custom configurations. +* `skip_customization` - (Optional) skip virtual machine customization (useful if OS is not in the guest OS support matrix of VMware like "other3xLinux64Guest"). The `network_interface` block supports: