Undefined method `pxedir' for #<Windows:xxxxxxxxxxxxx>

When trying to create a new Windows host I get the following error regardless of what I write in my PXELinux template.

Unable to render PXELinux template ‘1-Windows PXELinux’: undefined method pxedir' for #<Windows:0x00007ff4aea838b0> Fetch TFTP boot files for test02.lab.lan task failed with the following error: undefined methodpxedir’ for #Windows:0x00007ff4aea838b0

Foreman and Proxy versions:

There is a mention of that error in the end of issue 26036. But it was closed before anyone resolved it.

You are trying to put Windows template content into PXELinux template. The content in the issue seem to be what’s called a finish template, make sure you store your template as “finish” type. PXE is not supported for Windows, thus the error.

I can’t help you with Windows setup tho, this is not something I do. No clue how this is all set up.

Same issue here - my hosts are booting via iPXE and I’m trying to have a PXE template which chain them to the windows WDS server:

set net0/next-server
chain tftp://

when provisioning the host I get the same error as in the subjet.

It’s the same PXELinux template I used for PXE booting Windows installations on Foreman 1.16.0 a year ago and it worked perfectly then. It’s based on the wimaging_pxelinux template from foreman-wimaging.

Sadly, the templates in foreman-wimaging are no longer compatible with current foreman versions, and the repo appears to be no longer maintained afaict.

If anyone is interested in fixing them, we would be happy to add them to the community templates repository, so that they get shipped with future foreman versions, are updated when something in the foreman templating engine changes, and are tested against new releases. I know @Shimon_Shtein started looking into them with the user who reported that issue, but I’m not sure if they got to a point where there was an actual working template.

I know that the foreman-wimaging templates are no longer compatible. (Becasue the variables have changed from what i heard) I’m now using my own simplified version just to get the template to compile, but without success.

kind: PXELinux
name: 1-Windows PXELinux
- Windows Server 2008
- Windows Server 2008 R2
- Windows Server 2012
- Windows Server 2012 R2
- Windows Server 2016
- Windows
DEFAULT menu    
LABEL menu         
     COM32 linux.c32 boot/wimboot

You are right, this looks like a bug in the medium provider code introduced by the fix for Bug #25733: Media provider unique ID does not work for Debian-based distros - Foreman which assumes all operating systems have the pxedir method. Can you please open a report for this issue on our redmine tracker?

Until the bug is properly fixed, you could try working around it by changing that line (should be under /usr/share/foreman/app/services/medium_providers/default.rb) to:

 digest = Base64.urlsafe_encode64(Digest::SHA1.digest(medium_uri(entity.operatingsystem.try(:pxedir)).to_s), padding: false)

and restarting the httpd service.

1 Like

Your change fixed the problem. I will open a report for this issue.
Thanks for the help!

Would you like to open a PR with the fix perhaps? :slightly_smiling_face:

1 Like

I was unable to find any Windows provisioning template in our community-templates repo: https://github.com/theforeman/community-templates

If we have one, at least a good example, this will be fetched in the core repo and our snapshot test suite will make sure it won’t regress in the future. If you can provide good example of such templates go ahead and file a PR as well.

@lzap, we had working (well, compiling - didn’t actually test it myself) templates that were attached to https://github.com/theforeman/foreman/pull/6302.

I have the same error message with the https://github.com/kireevco/wimaging templates but with version 1.21.0

I then went there and got into this file:


and inserted there:

  def pxedir
  at the end

I’m not sure if this is the right way to go or if the error has a completely different cause or needs a completely different solution. But as a workaround this seems to have worked for the first time.

This will be fixed in 1.21.1 by Bug #26154: NoMethodError: undefined method `pxedir' for #<Windows:0x0000000007298338> - Foreman, in the meantime adding the empty pxedir method should work as well.

1 Like