Problem:
I am attempting to use Foreman to provision windows VMs. I have followed the following documents:
Windows Provisioning made Easy! (iPXE)
GitHub - AutomationD/wimaging: Windows Imaging Toolkit (pxelinux)
When using either iPXE or pxelinux, the results are the same. Foreman deploys the VM on the hypervisor (in my case, I am testing things with Hyper-V) and attempts to boot to the network. It gets an IP address from the DHCP server along with the necessary parameters (next-server, etc.) and depending on the scenario, it boots either iPXE (latest complied version as of 7/30/2020) or pxelinux (v6.03) with no problems.
For the following example screenshot (using pxelinux), it shows that it successfully loads wimboot, but when it attempts to load the peSetup.cmd file via the unattended/script endpoint, it fails stating that the file is not found. I know that this script exists because it is defined within the Operating System section and I can read the erb within the Provisioning Templates section. I am using the default provisioning templates that came with Foreman (Windows default iPXE or Windows default PXELinux depending on the network boot method).
How can I test the unattended/script endpoint?
If this endpoint is not working properly, what do I need to do to get it working?
In the ‘Windows default iPXE’ template, for example, it appears to be using the peSetup.cmd file as a parameter for unattended/script:
<%#
kind: iPXE
name: Windows default iPXE
model: ProvisioningTemplate
oses:
- Windows
%>#!ipxe
set boot-url tftp://${next-server}/
kernel ${boot-url}<%= @host.operatingsystem.bootfile(medium_provider,:kernel) %>
initrd <%= foreman_url('script') %> peSetup.cmd
initrd ${boot-url}<%= @host.operatingsystem.bootfile(medium_provider,:bcd) %> BCD
initrd ${boot-url}<%= @host.operatingsystem.bootfile(medium_provider,:bootsdi) %> boot.sdi
initrd ${boot-url}<%= @host.operatingsystem.bootfile(medium_provider,:bootwim) %> boot.wim
boot
Just in case you are looking for it, here is the ‘Windows default PXELinux’ template:
<%#
kind: PXELinux
name: Windows default PXELinux
model: ProvisioningTemplate
oses:
- Windows
%>
DEFAULT menu
LABEL menu
COM32 linux.c32 <%= @host.operatingsystem.bootfile(medium_provider,:kernel) %>
APPEND initrdfile=<%= foreman_url('script') %>@peSetup.cmd,<%= @host.operatingsystem.bootfile(medium_provider,:bcd) %>,<%= @host.operatingsystem.bootfile(medium_provider,:bootsdi) %>,<%= @host.operatingsystem.bootfile(medium_provider,:bootwim) %>
Whether you are using iPXE or pxelinux, the process in which files are loaded appears to be the same.
- load the kernel file (wimboot)
- load the peSetup.cmd file
- load BCD
- load boot.sdi
- load boot.wim
In that order.
Where is the peSetup.cmd file name defined in order to make it into a parameter for foreman_url(‘script’)? I am looking at the template that appears to generate peSetup.cmd (Windows peSetup.cmd), but there is no place that I can see that defines the filename that gets passed to unattended/script, so I am not sure if the unattended/script endpoint is simply not working, that peSetup.cmd is not being generated via the ‘Windows peSetup.cmd’ template, or both.
Expected outcome:
After wimboot is loaded, the peSetup.cmd file gets passed into unattended/script, then the remaining initrd files get loaded as they are expected to.
Foreman and Proxy versions:
DHCP - v2.0.1
TFTP, HTTPboot - v2.0.0
Foreman version 2.0.0
Foreman and Proxy plugin versions:
Distribution and version:
Foreman Proxies - CentOS 7.8.2003
Hyper-V Host - Windows Server 2016 Datacenter
Hyper-V Guest (trying to deploy this) - Windows Server 2019 Standard
Other relevant data:
This is a snippet of /var/log/foreman/production.log at the time of the PXE, which was started by clicking on the “cancel build” button of the test VM, followed by clicking the “build” button and a reboot:
Foreman ProductionDotLog - PXELinux.log (33.7 KB)