ошибка sysprep настройки terraform Windows с (0x800708b3) : «База данных безопасности не запущена».

#windows #terraform #vsphere #windows-server-2019 #sysprep

Вопрос:

Я пытаюсь настроить виртуальную машину Windows Server 2019, на которой я установил контроллер домена с помощью terraform. Вот как я пытаюсь это сделать:

 resource "vsphere_virtual_machine" "Active_Directory" {
  name             = "Active Directory"
  num_cpus         = 2
  memory           = 4196
  datastore_id     = data.vsphere_datastore.datastore.id
  host_system_id   = data.vsphere_host.host.id
  resource_pool_id = data.vsphere_resource_pool.pool.id
  guest_id         = data.vsphere_virtual_machine.template_win2016.guest_id
  scsi_type        = data.vsphere_virtual_machine.template_win2016.scsi_type

  # Configure network interface

  network_interface {
    network_id = data.vsphere_network.AD_network.id
  }
  

  disk {
    name = "Active Directory.vmdk"
    size = "35"
  }

  # Define template and customisation params
  clone {
    template_uuid = data.vsphere_virtual_machine.template_win2016.id

    customize {
      #windows_sysprep_text = "${file("data/unattend.xml")}"
      windows_options{
        computer_name="DomainControl"
        admin_password="XXXX"
      }
      
      network_interface {
        ipv4_address = "192.168.7.2"
        ipv4_netmask = 24
      } 
      ipv4_gateway = "192.168.7.1"

    }
  }
}
 

Но настройка идет не так, как предполагалось.
Терраформируй мне эту общую ошибку:

 ╷
│ Error: 
│ Virtual machine customization failed on "XXX/Active Directory":
│ 
│ timeout waiting for customization to complete
│ 
│ The virtual machine has not been deleted to assist with troubleshooting. If
│ corrective steps are taken without modifying the "customize" block of the
│ resource configuration, the resource will need to be tainted before trying
│ again. For more information on how to do this, see the following page:
│ https://www.terraform.io/docs/commands/taint.html
│ 
│ 
│   with vsphere_virtual_machine.Active_Directory,
│   on 061-Active Directory.tf line 6, in resource "vsphere_virtual_machine" "Active_Directory":
│    6: resource "vsphere_virtual_machine" "Active_Directory" {
│ 
 

В этом нет ничего C:/Windows/System32/Sysprep/Panther/setuperr.log и я получил эти предупреждения в setupact.log:

     2021-05-03 09:25:58, Warning    [0x0f008f] SYSPRP RunRegistryDlls:Registry key is either empty or malformed: SOFTWAREMicrosoftWindowsCurrentVersionSetupSysPrepExternalCleanup
    2021-05-03 09:25:58, Warning    [0x0f008f] SYSPRP RunRegistryDlls:Registry key is either empty or malformed: SOFTWAREMicrosoftWindowsCurrentVersionSetupSysPrepExternalGeneralize
    2021-05-03 09:25:59, Warning                      [shsetup] CleanupAdministratorPassword: NetUserGetInfo(23) failed (0x800708b3)
    2021-05-03 09:25:59, Warning               SYSPRP MSS: Cleanup cannot delete Directory C:ProgramDataMicrosoftSearchDataApplicationsWindows in Windows Search Data Directory with error 0x3.
    2021-05-03 09:25:59, Warning               SYSPRP MSS: Cleanup call failed to delete data folder C:ProgramDataMicrosoftSearchDataApplicationsWindows - error 0x0.
    2021-05-03 09:26:00, Warning                      TapiSysPrep.dll:RetainTapiLocations:RegQueryValueEx() returned 2
    2021-05-03 09:26:26, Warning               SYSPRP SPPNP: Failed to configure netvwifibus.inf. Err = 0x2
    2021-05-03 09:26:32, Warning               SYSPRP SPPNP: Unable to configure all driver packages. Err = 0x2
    2021-05-03 09:26:32, Warning               SYSPRP iphlpsvc.dll: sysprep generalize failed to delete tunnel registry
    2021-05-03 09:26:32, Warning               SYSPRP iphlpsvc.dll: sysprep generalize failed to delete tunnel registry
    2021-05-03 09:26:33, Warning               SYSPRP Ignoring folder Deleted because could not convert to family name
 

I figured out that 0x800708b3 means «The security database has not been started». I guess it is the major bug that must be resolve for Sysprep to work.
I checked in :/Windows/Panther/setup.etl to see what caused the database to not start but i found nothing. (Or maybe I just don’t know what to search for)

Does anyone know where should I look to resolve this issue or how to solve it?