Switch pxe booting to local before getting unattended/built

Hi there,

Still trying to provision windows using the Foreman.
Windows requires reboot several times during the installation problem.
Problem is, when it reboots it won't boot from the local drive and restart
the setup.
I worked around this by getting unattended/built before the first reboot.
While this works, it has two big disadvantages:

  • First, it instructs foreman that the system is installed. However when
    the status is set to build, it's only the first reboot during the install
    and things can still go very wrong => reporting is misleading
  • Second, the finish script is not available anymore once built is
    called (http get returns an empty file). I could get the script from
    another place (like network drive) but it's not ideal => additional
    complexity / less flexibility

So my question is: is there a proper way to make the foreman change the pxe
booting of a host to local drive before getting unattended/built?

Since I know calling unattended/build does it, I've tried to dig in the
source code.
In the routes and couldn't find an url in unattended/??? to enable pxe
local boot.
Also I am not sure I understand what happens when we get unattended/built.
I found this piece of code from the unattended_controller.rb:

def built
> logger.info "#{controller_name}: #{@host.name} is Built!"
> update_ip if Setting[:update_ip_from_built_request]
> head(@host.built ? :created : :conflict)
> end

I don't understand (new to ruby and rails) how this could trigger actions
such as changing tftp. Not sure what head is nor where it's defined.
Is it changing an host parameter? Then this change sends a signal and other
scripts run? Which ones?

Also I've seen that the proxy receive a POST request to change the booting
file (in my case /tftp/syslinux/mac_address)
I am guessing I could try to post from the host to the proxy server
directly but this seems wrong as well.

Have you had this issue before ?
How did you tackle it?
Would you have any pointers?

Thanks,

Hi,

this line

head(@host.built ? :created : :conflict)

calls Host::Managed#built method which triggers our orchestration via
ActiveRecord hooks. Specifically Orchestration::TFTP method setTftp.

LZ

··· -- Later, Lukas "lzap" Zapletal

Thanks for the reply Lukas.

I solved my problem with writing a small python http server that would
change the file on the tftp server. Not super elegant but does the trick
and will be easier to maintain with my current knowledge.
find Ruby/Rails a bit puzzling at first cause the link between the
different files / elements are implicit. I might have another look later.

Cheers,

··· On 11 October 2016 at 08:47, Lukas Zapletal wrote:

Hi,

this line

head(@host.built ? :created : :conflict)

calls Host::Managed#built method which triggers our orchestration via
ActiveRecord hooks. Specifically Orchestration::TFTP method setTftp.

LZ


Later,
Lukas “lzap” Zapletal


You received this message because you are subscribed to a topic in the
Google Groups “Foreman users” group.
To unsubscribe from this topic, visit https://groups.google.com/d/
topic/foreman-users/LVjsn4p4Go0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.


Bernard Landon