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

Add Packer Template for Building supported Windows client and server images #144

Draft
wants to merge 60 commits into
base: master
Choose a base branch
from

Conversation

lukasfazik
Copy link

OpenNebula forum thread discussing these changes

Changes include

Packer template files

  • There is a core packer build template windows.pkr.hcl like in other distributions.
    • This template uses a separate file variables.pkr.hcl file for variables, but unlike other distributions, the installation files are not directly referenced here. Only the type of installation media for a given Windows edition is referenced here.
  • variables.auto.pkrvars.hcl references paths for the Windows ISO files. As discussed here. I will try to make an example file out of this one in a later commit.
  • Next there is a template for Autounattend.xml file used for automation of Windows installation process. The placeholder values for edition names and language are substituted during the build process.
  • Lastly, there is a template for the OOBEUnattend.xml file which is used to automate the OOBE (Out of box experience)

Powershell scripts

The scripts are in scripts folder with exception of Run-Scripts.ps1. The Run-Scripts.ps1 script is called from unattended (automated) Windows installation multiple times during each phase of online installation (not Windows PE phase). This script executes scripts in alphabetical order and passes the return values to the unattended installation, so reboots are possible and don't break the unattended installation.

The scripts are divided into:

  • specialize
    • Runs during the first reboot after Windows PE finishes offline installation (deployment of fresh Windows image to disk)
  • audit
    • Runs after the second reboot when on normal installation OOBE would be present. In our case, we boot into audit mode to make changes and Sysprep the image
  • oobe
    • Runs when the finished Windows image is used (after Sysprep).

The Install-Updates.ps1 script is dependent on PSWindowsUpdate module which is included in cd_files directory. This is an external module, but it's also on the official PowerShell Gallery webpage. It is licensed under MIT License, and therefore, it should be usable in our project. Correct me if I am wrong.

Empty iso directory

This directory is used when searching for ISO files. Also, the virtio-win.iso drivers file must be included here. the ISO files could be obtained from official Microsoft sources:

For testing purposes, the hash values for the ISO files could be omitted by replacing them with none keyword.

Signed-off-by: Lukáš Fázik <[email protected]>
According to best practices

Signed-off-by: Lukáš Fázik <[email protected]>
Run-Scripts.ps1 in Copy-Scritps.ps1 and remove
Unnecessary return value

Signed-off-by: Lukáš Fázik <[email protected]>
Silenced clean up phase
Script array of zero/one element is stored properly in progress.json

Signed-off-by: Lukáš Fázik <[email protected]>
boot_wait was too slow for running on bare metal Fedora install

Signed-off-by: Lukáš Fázik <[email protected]>
Signed-off-by: Lukáš Fázik <[email protected]>
Signed-off-by: Lukáš Fázik <[email protected]>
Merge Copy-Scripts.ps1 and Copy-Unattend.ps1 into single Copy-Files.ps1

Signed-off-by: Lukáš Fázik <[email protected]>
…ase of Autounatend file

This speeds up imaging and subsequent installation

Signed-off-by: Lukáš Fázik <[email protected]>
Now the user is logged out only after OOBE finishes

Signed-off-by: Lukáš Fázik <[email protected]>
The Join-Path is the preferred way of joining paths and works correctly on Windows, Linux and other platforms

Signed-off-by: Lukáš Fázik <[email protected]>
$Args switched to params syntax. First ($ScriptRoot) argument is unaffected by this change

Signed-off-by: Lukáš Fázik <[email protected]>
Now the currently executed scrpt will not take down the main script, even if it has $ErrorActionPreference = "Stop" inside

Signed-off-by: Lukáš Fázik <[email protected]>
…nished in OOBEFinish.ps1

Signed-off-by: Lukáš Fázik <[email protected]>
Replace call operator with Start-Process and -Wait parameter

Signed-off-by: Lukáš Fázik <[email protected]>
This prevents built in MSIs coliding with later MSI packages executed by another scripts

Signed-off-by: Lukáš Fázik <[email protected]>
This script cleans up windows component store using DISM and trims the drive

Signed-off-by: Lukáš Fázik <[email protected]>
This paths are used in unattend files as an argument for Run-Scripts.ps1

Signed-off-by: Lukáš Fázik <[email protected]>
Feature will be installed only on supported Windows versions

Signed-off-by: Lukáš Fázik <[email protected]>
This better reflects Windows 11 minimum requirements and makes the build
process less demanding

Signed-off-by: Lukáš Fázik <[email protected]>
@lukasfazik lukasfazik changed the title Add Packer Template for Building supported Windows client and server images DRAFT: Add Packer Template for Building supported Windows client and server images Dec 2, 2024
@lukasfazik lukasfazik changed the title DRAFT: Add Packer Template for Building supported Windows client and server images Add Packer Template for Building supported Windows client and server images Dec 2, 2024
@lukasfazik lukasfazik marked this pull request as draft December 2, 2024 18:22
@rsmontero rsmontero added type: feature A new feature planned for implementation category: context windows Windows OS contextualization packages status: pending Issue needs to be processed by the team community Issue created by OpenNebula Community labels Dec 3, 2024
@rsmontero rsmontero added this to the Release 6.10.2 milestone Dec 3, 2024
@lukasfazik
Copy link
Author

I have noticed a file header in the context-windows/src/context.ps1 contains information about the author and copyright. Should I include something like this in my files?

Fixes "Windows cannot find the Microsoft license software terms" error
in installation of Windows 10 Enterprise LTSC 2015

Signed-off-by: Lukáš Fázik <[email protected]>
…cript

Ensures backward compatibility with PowerShell 5.0 in Windows 10 Enterprise LTSB 2015 (missing Disable-LocalUser cmdlet)

Signed-off-by: Lukáš Fázik <[email protected]>
…enSSH-Server script

Note: -ErrorAction did not work and still produced errors

Signed-off-by: Lukáš Fázik <[email protected]>
@lukasfazik
Copy link
Author

lukasfazik commented Dec 6, 2024

I have added support for Windows LTSC editions. But Windows 10 Enterprise 2015 LTSB is broken in following ways:

  • Virtio drivers refuse to install because the OS is not Windows 10 :)
  • PSWindowsUpdate module does not support Powershell 5.0 (requires 5.1 and above)

Virttio installation error

Possible future solutions:

Also, the support for Windows 10 Enterprise 2015 LTSB is ending on 14.10.2025, so maybe it's not worth spending the time to make it work.

I have decided to keep it in since other people can build on top of this work or customize it for their needs.

This reverts commit 6409357.

Broke unattended installation of some Windows Server editions
@lukasfazik
Copy link
Author

The last commit revert fixes Windows Server editions, but Windows 10 Enterprise 2015 LTSB is broken instead.

@rsmontero rsmontero modified the milestones: Release 6.10.2, Release 6.10.0-3 Jan 8, 2025
@rsmontero rsmontero requested review from sk4zuzu and jaimecb January 8, 2025 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: context windows Windows OS contextualization packages community Issue created by OpenNebula Community status: pending Issue needs to be processed by the team type: feature A new feature planned for implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants