Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation Issue with Sysprep in Deprovision /mode:vm and IIS machine Key #301

Closed
makaanneo opened this issue May 5, 2023 · 0 comments
Labels

Comments

@makaanneo
Copy link

Overview of the Issue

Creating a Windows 2016 Server Image by using an Azure Base Image Windows 2016 Datacenter with IIS installation in packer build

Add a Deprovision code block at the end for Windows based on Documentation

Creating A Vm from the Image try to restart the IIS with

iisreset /restart

does not work error 'Invalid signature' error form IIS Admin Service

Reproduction Steps

Image Build from Azure base Image for Windows 2016 Datacenter

Installing IIS with some features ('Web-WebServer','Web-Scripting-Tools','Web-Mgmt-Console','Web-DAV-Publishing','Web-Http-Redirect','Web-Asp-Net45','Web-AppInit')

executing Deprovision command at the end of the Packer build

 provisioner "powershell" {
    elevated_password = var.install_password
    elevated_user     = var.install_user
    inline = [
      "if( Test-Path $Env:SystemRoot\\System32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\System32\\Sysprep\\unattend.xml -Force}",
      "& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /mode:vm /quit",
      "while($true) { $imageState = Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\State | Select ImageState; if($imageState.ImageState -ne 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { Write-Output $imageState.ImageState; Start-Sleep -s 10  } else { break } }"
    ]
  }
}

(This is based on the example inside the Azure ARM Packer Plugin Documentation)

Packer build succeeds successful.

Use for Packer build another hardware setting to use for building (Azure VM SKU) then for the VM deployed afterward

Error occurs afterward by creating an Azure VM from the image, then the Machine key for the IIS is updated/broken
Error on direct service startup:

Windows could not start the IIS Admin Service on Local Computer. service-specific error code -2146893818

Eventlog error:

Event 7024
The IIS Admin Service service terminated with the following service-specific error: Invalid Signature

Plugin and Packer version

From packer version

1.8.5

Operating system and Environment details

Windows Server 2022, Azure, Different hardware for VM from image and Image build

Suggested Change

change the documentation for Deprovision a Windows VM (the example) accordingly to remove the option /mode:vm in the documentation, according to Microsoft Documentation it requires the Image to be deployed with the same Hardware Profile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants