PXE provision and finish templates

All,
Please note, my frame of reference is only as it applies to
Kickstarting/CentOS, using Foreman 1.10.0 (stable). Debian/Preseed might
handle this situation differently. Furthermore, if I've directed this at
the wrong audience, please just point me to the right one!

 Currently when doing PXE based builds, the Finish template is never 

incorporated into the final kickstart script presented to the host. It
seems the kickstart script presented to the host is only the kickstart
provision template within foreman. The foreman documentation suggests that
a pxe based host creation includes the PXE, provision, and finish templates:

http://www.theforeman.org/manuals/1.10/index.html#4.4.3ProvisioningTemplates

> The Create Host action deploys the PXELinux template to the TFTP
> server. The PXELinux template directs the host to retrieve the Provision
> template. The Provision template will direct the installer to retrieve and
> run the Finish template at the end of the install, and the* Finish
> template will notify Foreman the build is complete just before reboot*.
>

With the default templates shipped with 1.10.0, the %post section of the
kickstart default *provision *template fulfills most (but not all) of the
tasks specified in the kickstart default *finish *template (including
notification of build completion to foreman). It should be noted, there
are some slight differences between the %post in provision template, and
the finish template.

My use-case that brought this up: I have several custom applications (some
my dev's wrote, some they didn't) that I need to lay down as part of a
kickstart process. No puppet modules currently exists (on my wish-list,
likely not within the scope of what our customer is willing to pay for). I
want to leverage the "finish" template such that I could have one
standardized Provision template. I can then select the appropriate finish
template at host-creation time, which would dictate what kind of host that
would be (i.e. what application is running on that host).

TL;DR: Which direction does the foreman team want to go?

A) Have the finish templates be intended for image based deployments only,
and update the documentation accordingly.
or
B) Refactor the kickstart (and potentially preseed) provision templates to
call their respective finish templates during the %post. Would this be a
discussion for the foreman_templates plugin?

Given my use-case, I would prefer option b. It seems like that would
provide more modularity to the overall provisioning process. That being
said, I understand completely that a single use-case shouldn't (and won't)
dictate the direction of an entire project, hence, this dialog. If
anything is unclear, please let me know and I'll happily clarify.

Apologies for my verbosity and thank you in advance!

Regards,
Mike

I'll give this more thought overnight, but just for a fast reply - Preseed
does indeed work differently, and actually the way you would expect. The
finish script is executed in the chroot environment of the newly installed
disk, prior to reboot. As such, it's a effectively OS-agnostic basj script
(although in practice it's full of apt-get commands…). You can see it
happening at [1] and [2].

Food for thought though, more later :slight_smile:

Greg

[1]
https://github.com/theforeman/community-templates/blob/develop/preseed/provision.erb#L153
[2]
https://github.com/theforeman/community-templates/blob/develop/preseed/finish.erb#L58

··· On 19 January 2016 at 22:39, Mike Deffenbaugh wrote:

All,
Please note, my frame of reference is only as it applies to
Kickstarting/CentOS, using Foreman 1.10.0 (stable). Debian/Preseed might
handle this situation differently. Furthermore, if I’ve directed this at
the wrong audience, please just point me to the right one!

> With the default templates shipped with 1.10.0, the %post section of the
> kickstart default *provision *template fulfills most (but not all) of
> the tasks specified in the kickstart default *finish *template
> (including notification of build completion to foreman). It should be
> noted, there are some slight differences between the %post in provision
> template, and the finish template.

Some will be quite deliberate, e.g. repositories may be set up in the
header of the main kickstart rather than in %post, but there's plenty of
stuff that should be combined.

> My use-case that brought this up: I have several custom applications
> (some my dev's wrote, some they didn't) that I need to lay down as part
> of a kickstart process. No puppet modules currently exists (on my
> wish-list, likely not within the scope of what our customer is willing
> to pay for). I want to leverage the "finish" template such that I could
> have one standardized Provision template. I can then select the
> appropriate finish template at host-creation time, which would dictate
> what kind of host that would be (i.e. what application is running on
> that host).
>
> TL;DR: Which direction does the foreman team want to go?
>
> A) Have the finish templates be intended for image based deployments
> only, and update the documentation accordingly.
> or
> B) Refactor the kickstart (and potentially preseed) provision templates
> to call their respective finish templates during the %post. Would this
> be a discussion for the foreman_templates plugin?

Sure, please do refactor it - though it's held in the
community-templates repository
(https://github.com/theforeman/community-templates) and synced on each
release into Foreman, or used directly by foreman_templates.

It might be preferable to pull the common code out into a snippet shared
between the two, which'd avoid the need for another HTTP call and for
the non-applicable bits of the finish script (root password, repos) from
being run on a regular kickstart.

··· On 19/01/16 22:39, Mike Deffenbaugh wrote:


Dominic Cleal
dominic@cleal.org