Windows provisioning on bare metal


#1

Anyone manage to setup windows provisioning or know a decent guide I could follow? I tried follow this video:

and also I tried this guide and tool:

But it doesn’t appear to be currently maintained and I ran into errors and needed to adjust a few of the scripts to get it somewhat working. All I need is to get a windows iso installed on a host, I plan on configuring it via ansible and won’t be managing the servers long term.

If anyone could point me in the right direction it would be greatly appreciated. I like to document as I go so if I can get it working I’ll document it and post for others. Thanks in advance.


#2

We pretty much only do windows here. That is the original guide we started with, then trimmed parts of it down. https://github.com/LiamLeane/ForemanWindows

You wont be using a standard ISO. You will be using WIM files, which is basically the same thing.
What are your errors, maybe I can help.


#3

Thanks Jeff I will definitely check out the guide. The resources I used a bit old so I ran into a lot of dism errors and mounting errors. The scripts also were calling an older version of the windows deployment tools and had to be edited for the newer versions. Going to take a look at what you sent and update if I have any questions. Thanks again!


#4

What I have wont be totally up to date. Probably havent updated in quite some time. However, the basic instructions are the same. You will just need the latest WDK kit for windows. It took me 3-4 months to get windows deploys working, back when I had no clue how any of this works. So Id be more than happy to help you through it. Any issues you run into, just reply here and we’ll get it figured out as time permits.


#5

There were also some issues reported when using the provisioning templates from wimaging repo in recent foreman versions, we would be happy to provide supported windows templates for all users in the community templates repo if someone contributes an initial working version of them.


#6

So I ran into 2 initial issues. One is when loading the templates into foreman and using preview
I got the following errors:

Warning! There was an error rendering the WAIK unattend.xml template: undefined method `unpack1’ for nil:NilClass – This is on the provision.erb template

Warning! There was an error rendering the WAIK peSetup.cmd template: wrong number of arguments (given 1, expected 0) — this is for the script.erb

It let me add them so not sure if this is an issue or not.

Then when I tried to build the image for a win2012r2 I got the followings errors:

Mount-WindowsImage : The system cannot find the path specified.
At C:\Users\ksuber\Documents\Code\ForemanWimScripts\ForemanWimScripts\Functions.ps1:43 char:9

  •     Mount-WindowsImage -ImagePath $sourcesInstall -Path $tempmoun ...
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:slight_smile: [Mount-WindowsImage], COMException
    • FullyQualifiedErrorId : Microsoft.Dism.Commands.MountWindowsImageCommand

ApplyUpdates: Adding updates from C:\Users\ksuber\desktop\wsusoffline\client\w63-x64\glb to C:\Users\ksuber\Documents\Code\ForemanWimScripts\ForemanWimScripts\working\mnt\c3vxepre.cpr
Add-WindowsPackage : An error occurred. No operation was performed.
Verify that DISM is installed properly in the image, and then try the operation again.
At C:\Users\ksuber\Documents\Code\ForemanWimScripts\ForemanWimScripts\Functions.ps1:102 char:9

  •     Add-WindowsPackage -Path $path -PackagePath $updatesPath -Log ...
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:slight_smile: [Add-WindowsPackage], COMException
    • FullyQualifiedErrorId : Microsoft.Dism.Commands.AddWindowsPackageCommand

ApplyUpdates: Adding updates from C:\Users\ksuber\desktop\wsusoffline\client\w63-x64\glb to C:\Users\ksuber\Documents\Code\ForemanWimScripts\ForemanWimScripts\working\mnt\c3vxepre.cpr
Add-WindowsPackage : An error occurred. No operation was performed.
Verify that DISM is installed properly in the image, and then try the operation again.
At C:\Users\ksuber\Documents\Code\ForemanWimScripts\ForemanWimScripts\Functions.ps1:102 char:9

  •     Add-WindowsPackage -Path $path -PackagePath $updatesPath -Log ...
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:slight_smile: [Add-WindowsPackage], COMException
    • FullyQualifiedErrorId : Microsoft.Dism.Commands.AddWindowsPackageCommand

Any clue on what is causing these errors? Thanks


#7

If I manage to get it working I’ll submit what I have. I wish the documentation was better for writing the templates and at least what needs to be in at a minimum that why I could just write my own templates from scratch.


#8

Actually, we use some very well working templates which I’m willing to share as community template; will see what needs to be done but I think it should run out-of-the-box without having to enable unsafe parameters. Will upload them this weekend :slight_smile:


#9

That would be great much appreciated thanks!!!


#10

But, now that I’m talking about it, I seem to remember we augemented the Wimaging part (the part that let’s you generate a WIM file) a teeny tiny bit as we actually inject the WinPE image with an installation script. I’ll see to document this in a wiki post perhaps; I think Windows provisioning is well worth a big update (as it works great on foreman)! :smiley:


#11

All those scripts error out for me now. The waik in the scripts is the wrong version and some of the variables have changed names. As soon as I fix one error I get a new one. Foreman was easy to setup for centos or ubuntu but for windows its hard to know where to start. I do agree I like the tool very much and wish to use it. I just wish I knew enough to write my own templates.


#12

So I have managed to get the image built using the ForemanWimScripts. I changed a few things for my personal taste but for the most part they seem to work out the box. I was running into an issue where it would not mount the image but in the end this turned out to be an issue with a gpo policy we have here. After getting that addressed I was able to mount and build the image.

Now I’m trying to get these templates to run https://github.com/LiamLeane/ForemanWindows . But I’m running into errors with two of the scripts when I import them.

The script.erb gives this error: Warning! There was an error rendering the WaIK script.erb template: wrong number of arguments (given 1, expected 0)

The provision.erb gives this error: Warning! There was an error rendering the WAIK provision.erb template: undefined method `unpack1’ for nil:NilClass

When I boot the machine it gets discovered when I try to provision with windows it just boots to a boot prompt with the error: Could not find kernel image: udionly.kpxe.

Again if anyone could point me in the right direction or have any working scripts to share it would be greatly appreciated.