vSpehere VM Customization Failure with Network not being connected.

1,913 views
Skip to first unread message

willia...@gmail.com

unread,
May 22, 2018, 12:55:19 PM5/22/18
to Terraform
Version
Terraform = v0.11.7
vSphere Version = 6.7.0, 8169922
Machine clone of Windows 2012 R2

Description of the Issue;
When trying to customize the network interface post provision terraform errors, VM is left running with no network configuration.

Investigation so far;
Within vCenter and the VM settings the "Network Adapter 1" is not marked to start on power up. It's as if during the customization that this setting is lost which is resulting in lack of comms to the VM. If i power the server off then check the box to connect NIC on start up then when the server comes back online it has its network configuration correct as defined in the customization section. I have also stripped back the customization to bare minimum and still get the same fault.

Error dumps below.

Terraform Error;
Error: Error applying plan:


1 error(s) occurred:


* vsphere_virtual_machine.Clone: 1 error(s) occurred:


* vsphere_virtual_machine.Clone:
Virtual machine customization failed on "/Data Center/vm/AIS1EM-SAMSON":


An error occurred while customizing VM AIS1EM-SAMSON. For details reference the log file C:/Windows/TEMP/vmware-imc/guestcust.log in the guest OS.

guestcust.log;
 
[2018-05-22T17:35:13:                              :   INFO] GuestCustUtil invoked.
[2018-05-22T17:35:13:                              :   INFO] Params: customize -sealparam "/quiet /generalize /oobe /reboot" -nics 4000 -schedulenativeunobfusc
[2018-05-22T17:35:13:                              :  DEBUG] Registry value 'CustomRescheduleFlags' is not set. Returning default value: 0
[2018-05-22T17:35:13:                              :   INFO] Checking for Windows Sysprep Respecialize operation.
[2018-05-22T17:35:13:                              :  DEBUG] Sysprep process is not running.
[2018-05-22T17:35:13:                              :   INFO] Windows Sysprep Respecialize operation was not detected.
[2018-05-22T17:35:13:                 GuestCustUtil:  DEBUG] Deleting status marker file C:/Windows/.post-gc-status
[2018-05-22T17:35:13:                 GuestCustUtil:  DEBUG] Status marker file C:/Windows/.post-gc-status doesn't exist
[2018-05-22T17:35:13:                              :   INFO] Extended customization is not enabled!
[2018-05-22T17:35:13:                              :  DEBUG] HandleCustomizationStarted
[2018-05-22T17:35:13:                              :  DEBUG] Customization in progress set to 1 at 2018-May-22 17:35:13
[2018-05-22T17:35:13:                              :  DEBUG] GOScPostRebootStatus feature is enabled
[2018-05-22T17:35:13:                 GuestCustUtil:  DEBUG] SetVmxProperty: key-'guestinfo.gc.notification', value-'Started'
[2018-05-22T17:35:13:     WindowsOsAbstractionLayer:   INFO] VMware tools installation path=C:\Program Files\VMware\VMware Tools\
[2018-05-22T17:35:13:     WindowsOsAbstractionLayer:   INFO] Executing command: '"C:\Program Files\VMware\VMware Tools\vmtoolsd.exe" --cmd "info-set guestinfo.gc.notification Started"'
[2018-05-22T17:35:13:     WindowsOsAbstractionLayer:   INFO] Command execution succeeded, output: '

'
[2018-05-22T17:35:13:                              :  DEBUG] Rpci: Sending request='deployPkg.update.state 4 0 C:/Windows/TEMP/vmware-imc/guestcust.log'

[2018-05-22T17:35:13:                              :  DEBUG] Rpci: Sent request='deployPkg.update.state 4 0 C:/Windows/TEMP/vmware-imc/guestcust.log', reply='', len=0, status=1

[2018-05-22T17:35:13:                              :  DEBUG] Temporary sysprep dir path: C:\sysprep
[2018-05-22T17:35:13:                              :  DEBUG] Copying file/directory from 'sysprep' to 'C:\sysprep'
[2018-05-22T17:35:13:                              :   INFO] Sysprep File is C:\Windows\Panther\unattend.xml
[2018-05-22T17:35:13:                              :   INFO] Password unobfuscation in progress
[2018-05-22T17:35:13:                              :  DEBUG] Decrypting passwords
[2018-05-22T17:35:13:                              :  DEBUG] Password found and decrypted for <AdministratorPassword><EncryptedValue>
[2018-05-22T17:35:13:                              :  DEBUG] preTag <Credentials> not found
[2018-05-22T17:35:13:                              :  DEBUG] preTag <Password> not found
[2018-05-22T17:35:13:                              :  DEBUG] Tag  -de  not found after <RunSynchronousCommand
[2018-05-22T17:35:13:                              :   INFO] Password unobfuscation successful
[2018-05-22T17:35:14:                              :  DEBUG] select * from win32_networkadapter where Manufacturer != 'Microsoft' and ServiceName != 'VMnetAdapter' and  manufacturer is not null and MACAddress is not null
[2018-05-22T17:35:14:                              :  DEBUG] Found 0 objects. Pointer 0. return code -2147217398(0x8004100a)
[2018-05-22T17:35:14:                              :  ERROR] WinMgmt : 
[2018-05-22T17:35:14:                              :  DEBUG] HandleCustomizationFailed
[2018-05-22T17:35:14:                              :  DEBUG] Customization in progress set to 0 at 2018-May-22 17:35:14
[2018-05-22T17:35:14:                              :   INFO] Cleaning up obfuscation details from registry
[2018-05-22T17:35:14:                 GuestCustUtil:  DEBUG] Status marker file C:/Windows/.post-gc-status doesn't exist
[2018-05-22T17:35:14:                              :  DEBUG] GOScPostRebootStatus feature is enabled
[2018-05-22T17:35:14:                 GuestCustUtil:  DEBUG] SetVmxProperty: key-'guestinfo.gc.notification', value-'WinMgmt : '
[2018-05-22T17:35:14:     WindowsOsAbstractionLayer:   INFO] VMware tools installation path=C:\Program Files\VMware\VMware Tools\
[2018-05-22T17:35:14:     WindowsOsAbstractionLayer:   INFO] Executing command: '"C:\Program Files\VMware\VMware Tools\vmtoolsd.exe" --cmd "info-set guestinfo.gc.notification WinMgmt : "'
[2018-05-22T17:35:14:     WindowsOsAbstractionLayer:   INFO] Command execution succeeded, output: '

'
[2018-05-22T17:35:14:                              :  DEBUG] Rpci: Sending request='deployPkg.update.state 4 100 C:/Windows/TEMP/vmware-imc/guestcust.log@WinMgmt : '

[2018-05-22T17:35:14:                              :  DEBUG] Rpci: Sent request='deployPkg.update.state 4 100 C:/Windows/TEMP/vmware-imc/guestcust.log@WinMgmt : ', reply='', len=0, status=1

[2018-05-22T17:35:14:                              :   INFO] GuestCustUtil exiting.

[2018-05-22T17:35:23:                              :   INFO] GuestCustUtil invoked.
[2018-05-22T17:35:23:                              :   INFO] Params: restoreMountedDevices 
[2018-05-22T17:35:23:                              :  DEBUG] Registry value 'CustomRescheduleFlags' is not set. Returning default value: 0
[2018-05-22T17:35:23:                              :   INFO] Checking for Windows Sysprep Respecialize operation.
[2018-05-22T17:35:23:                              :  DEBUG] Sysprep process is not running.
[2018-05-22T17:35:23:                              :   INFO] Windows Sysprep Respecialize operation was not detected.
[2018-05-22T17:35:23: SysprepDriveLettersWorkaround:  DEBUG] Restoring HKLM MountedDevices to fix sysprep issue
[2018-05-22T17:35:23:                              :  DEBUG] Enabling SE_RESTORE_NAME privilege
[2018-05-22T17:35:23:                              :  DEBUG] Retrieving process access token for SeRestorePrivilege
[2018-05-22T17:35:23:                              :  DEBUG] Getting LUID
[2018-05-22T17:35:23:                              :  DEBUG] Adjusting privileges
[2018-05-22T17:35:23:                              :  DEBUG] Restoring SYSTEM\MountedDevices from C:\sysprep\MountedDevicesBackup
[2018-05-22T17:35:23: SysprepDriveLettersWorkaround:   WARN] Failed to restore MountedDevices: The system cannot find the file specified.

. Ignoring
[2018-05-22T17:35:23:                              :   INFO] GuestCustUtil exiting.

[2018-05-22T17:35:23:                              :   INFO] GuestCustUtil invoked.
[2018-05-22T17:35:23:                              :   INFO] Params: flagComplete 
[2018-05-22T17:35:23:                              :  DEBUG] Registry value 'CustomRescheduleFlags' is not set. Returning default value: 0
[2018-05-22T17:35:23:                              :   INFO] Checking for Windows Sysprep Respecialize operation.
[2018-05-22T17:35:23:                              :  DEBUG] Sysprep process is not running.
[2018-05-22T17:35:23:                              :   INFO] Windows Sysprep Respecialize operation was not detected.
[2018-05-22T17:35:23:                 GuestCustUtil:  DEBUG] Status marker file C:/Windows/.post-gc-status doesn't exist
[2018-05-22T17:35:23:     WindowsOsAbstractionLayer:   INFO] Executing command: 'C:\Windows\system32\schtasks.exe /query /tn "VMware Guest OS Customization Task"'
[2018-05-22T17:35:23:     WindowsOsAbstractionLayer:   WARN] Command execution failed with exit code: 1, output: 'ERROR: The system cannot find the file specified.


'
[2018-05-22T17:35:23:                 GuestCustUtil:  DEBUG] SchedulePostCustomizationActivity: Run Command-'HandleCustomizationCompleted<\|/>'
[2018-05-22T17:35:23:                 GuestCustUtil:   INFO] Scheduling post-customization activity to run after reboot...
[2018-05-22T17:35:23:     WindowsOsAbstractionLayer:   INFO] Executing command: 'C:\Windows\system32\schtasks.exe /query /tn "VMware Guest OS Customization Task"'
[2018-05-22T17:35:23:     WindowsOsAbstractionLayer:   WARN] Command execution failed with exit code: 1, output: 'ERROR: The system cannot find the file specified.


'
[2018-05-22T17:35:23:                 GuestCustUtil:   INFO] Task 'VMware Guest OS Customization Task' exists and will be deleted: false
[2018-05-22T17:35:23:                 GuestCustUtil:  DEBUG] Artifact full path: C:\sysprep\libeay32.dll
[2018-05-22T17:35:23:                 GuestCustUtil:   INFO] Copying C:\sysprep\libeay32.dll to C:\Windows\TEMP\vmw857B.tmp.
[2018-05-22T17:35:23:                              :  DEBUG] Copying file/directory from 'C:\sysprep\libeay32.dll' to 'C:\Windows\TEMP\vmw857B.tmp'
[2018-05-22T17:35:23:                 GuestCustUtil:  DEBUG] Artifact full path: C:\sysprep\ssleay32.dll
[2018-05-22T17:35:23:                 GuestCustUtil:   INFO] Copying C:\sysprep\ssleay32.dll to C:\Windows\TEMP\vmw857B.tmp.
[2018-05-22T17:35:23:                              :  DEBUG] Copying file/directory from 'C:\sysprep\ssleay32.dll' to 'C:\Windows\TEMP\vmw857B.tmp'
[2018-05-22T17:35:23:                 GuestCustUtil:  DEBUG] Artifact full path: C:\sysprep\guestcustutil.exe
[2018-05-22T17:35:23:                 GuestCustUtil:   INFO] Copying C:\sysprep\guestcustutil.exe to C:\Windows\TEMP\vmw857B.tmp.
[2018-05-22T17:35:23:                              :  DEBUG] Copying file/directory from 'C:\sysprep\guestcustutil.exe' to 'C:\Windows\TEMP\vmw857B.tmp'
[2018-05-22T17:35:23:                 GuestCustUtil:  DEBUG] Schedule command: 'C:\Windows\TEMP\vmw857B.tmp\guestcustutil.exe post-run HandleCustomizationCompleted<\|/>'
[2018-05-22T17:35:23:                              :   INFO] Scheduling 'VMware Guest OS Customization Task'
[2018-05-22T17:35:23:                              :  DEBUG] Executing command C:\Windows\system32\schtasks.exe /create /sc ONSTART /rl HIGHEST /np /z /v1 /ru SYSTEM /tr "C:\Windows\TEMP\vmw857B.tmp\guestcustutil.exe post-run HandleCustomizationCompleted<\|/>" /tn "VMware Guest OS Customization Task"
[2018-05-22T17:35:23:                 GuestCustUtil:   INFO] Post-customization activity successfully scheduled.
[2018-05-22T17:35:23:                              :   INFO] GuestCustUtil exiting.

[2018-05-22T17:35:23:                              :   INFO] GuestCustUtil invoked.
[2018-05-22T17:35:23:                              :   INFO] Params: deleteContainingFolder 
[2018-05-22T17:35:23:                              :  DEBUG] Registry value 'CustomRescheduleFlags' is not set. Returning default value: 0
[2018-05-22T17:35:23:                              :   INFO] Checking for Windows Sysprep Respecialize operation.
[2018-05-22T17:35:23:                              :  DEBUG] Sysprep process is not running.
[2018-05-22T17:35:23:                              :   INFO] Windows Sysprep Respecialize operation was not detected.
[2018-05-22T17:35:23:                              :  DEBUG] Deleting "C:\sysprep" ...
[2018-05-22T17:35:23:                              :  DEBUG] Deleted folder "C:\sysprep" .
[2018-05-22T17:35:23:                              :   INFO] GuestCustUtil exiting.

[2018-05-22T17:35:47:                              :   INFO] GuestCustUtil invoked.
[2018-05-22T17:35:47:                              :   INFO] Params: post-run HandleCustomizationCompleted<\|/>
[2018-05-22T17:35:47:                              :  DEBUG] Registry value 'CustomRescheduleFlags' is not set. Returning default value: 0
[2018-05-22T17:35:47:                              :   INFO] Checking for Windows Sysprep Respecialize operation.
[2018-05-22T17:35:47:                              :  DEBUG] Sysprep process is not running.
[2018-05-22T17:35:47:                              :   INFO] Windows Sysprep Respecialize operation was not detected.
[2018-05-22T17:35:47:                              :   INFO] Post-customization run operation: script 'HandleCustomizationCompleted<\|/>'
[2018-05-22T17:35:47:                              :   INFO] post-run HandleCustomizationCompleted
[2018-05-22T17:35:47:                              :   INFO] Deleting post-customization task to avoid re-execution
[2018-05-22T17:35:47:     WindowsOsAbstractionLayer:   INFO] Executing command: 'C:\Windows\system32\schtasks.exe /query /tn "VMware Guest OS Customization Task"'
[2018-05-22T17:35:48:     WindowsOsAbstractionLayer:   INFO] Command execution succeeded, output: '

Folder: \

TaskName                                 Next Run Time          Status         

======================================== ====================== ===============

VMware Guest OS Customization Task       N/A                    Running        

'
[2018-05-22T17:35:48:                 GuestCustUtil:   INFO] Task 'VMware Guest OS Customization Task' exists and will be deleted: true
[2018-05-22T17:35:48:                              :   INFO] Deleting 'VMware Guest OS Customization Task'
[2018-05-22T17:35:48:                              :  DEBUG] Executing command C:\Windows\system32\schtasks.exe /delete /f /tn "VMware Guest OS Customization Task"
[2018-05-22T17:35:48:                              :  DEBUG] HandleCustomizationCompleted
[2018-05-22T17:35:48:                              :  DEBUG] Customization status previously reported, nothing to do
[2018-05-22T17:35:48:                              :  DEBUG] Deleting "C:\Windows\TEMP\vmw857B.tmp" ...
[2018-05-22T17:35:48:                              :  DEBUG] Deleted folder "C:\Windows\TEMP\vmw857B.tmp" .
[2018-05-22T17:35:48:                              :   INFO] GuestCustUtil exiting.


/*
Secrets
*/
provider "vault" {
address = "https://<removed>:8200"
token = "<removed>"
}

data "vault_generic_secret" "terraform_secrets" {
path = "secret/serviceaccounts/default_emisgroup"
}

provider "vsphere" {
user = "${data.vault_generic_secret.terraform_secrets.data["username"]}@${data.vault_generic_secret.terraform_secrets.data["domain_fqdn"]}"
password = "${data.vault_generic_secret.terraform_secrets.data["password"]}"
vsphere_server = "<removed>"
}

/*
Variables
*/

#The template to use for creation of new Virtual Machine
variable "Template" { default = "W2012R2_RELEASE" }
#The Resource Pool where the new VM should be created
variable "ResourcePool" { default = "Self-Service" }
#The folder where the new VM should be located
variable "Folder" { default = "AIS1EM" }

/*
VM Build
*/
data "vsphere_datacenter" "dc" {
name = "Data Center"
}

data "vsphere_datastore" "datastore" {
name = "vsanDatastore"
datacenter_id = "${data.vsphere_datacenter.dc.id}"
}

data "vsphere_resource_pool" "pool" {
name = "${var.ResourcePool}"
datacenter_id = "${data.vsphere_datacenter.dc.id}"
}


data "vsphere_distributed_virtual_switch" "dvs" {
name = "DSwitch0"
datacenter_id = "${data.vsphere_datacenter.dc.id}"
}

data "vsphere_network" "network" {
name = "DPortGroup-VM-VLAN59"
datacenter_id = "${data.vsphere_datacenter.dc.id}"
}

data "vsphere_virtual_machine" "template" {
name = "${var.Template}"
datacenter_id = "${data.vsphere_datacenter.dc.id}"
}

# clone from template
resource "vsphere_virtual_machine" "Clone" {
name = "AIS1EM-SAMSON"
resource_pool_id = "${data.vsphere_resource_pool.pool.id}"
datastore_id = "${data.vsphere_datastore.datastore.id}"
wait_for_guest_net_timeout = false
num_cpus = 2
memory = 4096
guest_id = "${data.vsphere_virtual_machine.template.guest_id}"
scsi_type = "${data.vsphere_virtual_machine.template.scsi_type}"

network_interface {
network_id = "${data.vsphere_network.network.id}"
adapter_type = "vmxnet3"
}

disk {
label = "AIS1EM-SAMSON.vmdk"
size = "${data.vsphere_virtual_machine.template.disks.0.size}"
eagerly_scrub = "${data.vsphere_virtual_machine.template.disks.0.eagerly_scrub}"
thin_provisioned = "${data.vsphere_virtual_machine.template.disks.0.thin_provisioned}"
}

clone {
template_uuid = "${data.vsphere_virtual_machine.template.id}"

customize {

windows_options {
computer_name = "AIS1EM-SAMSON"
#join_domain = "<removed>"
#domain_admin_user = "<removed>"
#domain_admin_password = "<removed>"
admin_password = "<removed>"
}

network_interface {
ipv4_address = "192.168.59.50"
ipv4_netmask = "24"
dns_server_list = ["192.168.72.167", "192.168.72.168"]
#dns_domain = "emisais.com"
}

ipv4_gateway = "192.168.59.1"

}

}
}

output "ID" {
value = "${data.vsphere_network.network.id}"
}







Reply all
Reply to author
Forward
0 new messages