hashicorp / hashicorp/packer-plugin-oracle

Windows Server 2019 generalized image support files Generalize.cmd doesn't work with oracle oci packer builder

Open
#23 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
14
Forks
16
PR merge metrics
No merged PRs in 30d

Description

#### Overview of the Issue

I am using the Packer Oracle OCI builder to create windows server 2019 custom images. I am using the generalized image support files. https://docs.oracle.com/en-us/iaas/Content/Compute/References/generalizedimage.htm#Windows_Generalized_Image_Support_Files. This was working earlier, but recently this has started failing with the following error

```
==> oracle-oci: Provisioning with powershell script: /tmp/powershell-provisioner299066530
oracle-oci:
oracle-oci: C:\Users\opc>C:\Windows\System32\Sysprep\sysprep.exe /generalize /oobe /quit /unattend:C:\Windows\Panther\unattend.xml
oracle-oci:
oracle-oci: C:\Users\opc>PowerShell.exe -ExecutionPolicy Unrestricted -File C:\Windows\Panther\Post-Generalize.ps1
oracle-oci: Transcript started, output file is C:\Windows\Panther\Post-Generalize.log
oracle-oci: Current CmdLine
oracle-oci:
oracle-oci:
oracle-oci: CmdLine : oobe\windeploy.exe
oracle-oci: PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\System\Setup
oracle-oci: PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\System
oracle-oci: PSChildName : Setup
oracle-oci: PSDrive : HKLM
oracle-oci: PSProvider : Microsoft.PowerShell.Core\Registry
oracle-oci:
oracle-oci: Updating CmdLine
oracle-oci: New CmdLine
oracle-oci: CmdLine : C:\Windows\Panther\Specialize.cmd
oracle-oci: PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\System\Setup
oracle-oci: PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\System
oracle-oci: PSChildName : Setup
oracle-oci: PSDrive : HKLM
oracle-oci: PSProvider : Microsoft.PowerShell.Core\Registry
oracle-oci:
oracle-oci: Transcript stopped, output file is C:\Windows\Panther\Post-Generalize.log
oracle-oci:
oracle-oci:
oracle-oci:
oracle-oci: C:\Users\opc>PowerShell.exe -ExecutionPolicy Unrestricted -Command "Start-Sleep -Seconds 20"
==> oracle-oci: Provisioning step had errors: Running the cleanup provisioner, if present...
```

#### Reproduction Steps

The following is the snippet, the powershell provisioning step fails now (it used to work earlier without issues)
```
"provisioners": [
{
"type": "ansible",
"playbook_file": "./playbook.yml",
"user": "opc",
"use_proxy": false,
"extra_arguments": ["-e", "ansible_winrm_server_cert_validation=ignore", "-vvvv"]
},
{
"type": "powershell",
"inline": [
"& C:\\Windows\\Panther\\Generalize.cmd",
"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 } }"
]
}
]
```

### Plugin and Packer version

From `packer version`
Packer v1.7.2

### Simplified Packer Buildfile

[template-gist](https://gist.github.com/codingarchitect/88a45b777497bf03cbe57e64368511b8)

### Operating system and Environment details

Host machine in packer is run is Ubuntu 20.04,
Packer Custom Image OS is Windows Server 2019

### Log Fragments and crash.log files
[log-gist](https://gist.github.com/codingarchitect/2e27d6ad4ee4457b748f7df080aefe42)

It is difficult to debug as sysprep renders the image unusable from remote.
Any pointers to what might be the issue.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.