Using the <%= options %> or <%= pxe_kernel_options %> array in templates?

Hi all,

Currently, we have a couple templates with local customizations to do
things like pass on Kernel parameters, like this example from the
Kickstart default PXELinux template.

<%-# NOTE:
# If host is VMware (If it uses the VMware provider), than pass
kernel params to avoid ‘consistent network device naming’.
# If host is not VMware, then assign a serial console for IPMI/SOL.
Assuming standard Supermicro ttyS1 for now.
-%>
<% if @host.provider == 'VMware' -%>
<%-# I am a Virtual Machine -%>
APPEND initrd=<%= @initrd %> ks=<%= foreman_url('provision')%> network
ks.sendmac net.ifnames=0 biosdevname=0
<% else -%>
<%-# I am a Physical Machine -%>
append initrd=<%= @initrd %> ks=<%= foreman_url('provision')%> network
ks.sendmac console=tty0 console=ttyS0,9600
<% end -%>
<% else -%>
APPEND initrd=<%= @initrd %> ks=<%= foreman_url('provision')%>
ksdevice=bootif network kssendmac
<% end -%>

I noticed that newer versions of the Kickstart default PXELinux template
have added an array named &lt;%= options %&gt; or &lt;%= pxe_kernel_options %&gt;,
like so:

Foreman 1.13:

&lt;% elsif @host.operatingsystem.name == &#39;Fedora&#39; and @host.

operatingsystem.major.to_i > 16 -%>
APPEND initrd=<%= @initrd %> ks=<%= foreman_url('provision') %>
ks.device=bootif network ks.sendmac <%= pxe_kernel_options %>

Foreman 1.12 and older:

&lt;% elsif @host.operatingsystem.name == &#39;Fedora&#39; and @host.

operatingsystem.major.to_i > 16 -%>
APPEND initrd=<%= @initrd %> ks=<%= foreman_url('provision')%>
ks.device=bootif network ks.sendmac <%= options %>

It looks like many of many customizations can be folded into one of these
arrays, which would simplify our own templates and make it easier to keep
them in sync with the upstream versions.

How could I make use of the <%= options %> or <%= pxe_kernel_options %>
arrays? I can't find any documentation about them. Would I want to set
parameters on a Host Group basis?

Thanks,

-= Stefan

> It looks like many of many customizations can be folded into one of these
> arrays, which would simplify our own templates and make it easier to keep
> them in sync with the upstream versions.
>
> How could I make use of the <%= options %> or <%= pxe_kernel_options %>
> arrays? I can't find any documentation about them. Would I want to set
> parameters on a Host Group basis?

Options array is defined in the template itself, just scroll up a page.
It was just a refactoring to make the template little bit more readable.

For the pxe_kernel_options, you identified it right, it's an attempt to
move some customization from templates into host parameters. Currently
it only accepts blacklist options for Redhat systems. The method is
defined in Operatingsystem model. For all other systems it returns just
an empty array.

If you can help us defining which options to include, that would be
great. I only use Redhat systems and blacklist is the only parameter I
make use of, so can't think of others.

Maybe we could make a generic param kernel_cmdline that would work with
any OS. If you like the idea, file a feature ticket for me, easy change.

··· -- Later, Lukas #lzap Zapletal

> > It looks like many of many customizations can be folded into one of these
> > arrays, which would simplify our own templates and make it easier to keep
> > them in sync with the upstream versions.
> >
> > How could I make use of the <%= options %> or <%= pxe_kernel_options %>
> > arrays? I can't find any documentation about them. Would I want to set
> > parameters on a Host Group basis?
>
> If you can help us defining which options to include, that would be
> great. I only use Redhat systems and blacklist is the only parameter I
> make use of, so can't think of others.
>

Our own examples are a bit localized, but are probably useful for other
groups. Currently, I'm adding options using simple 'if/elsif/else'
statements in the body of my templates, but I think this could be
accomplished more elegantly.

  • The first option is to workaround a bug with VMware and Red Hat's
    consistent device naming, which creates network device names with crazy
    names like 'eno16777723' and 'eno33555201'. Our workaround is to
    append 'net.ifnames=0
    biosdevname=0' to the kernel parameters, as you can see above.

  • The second is to activate a serial console for our Supermicro bare metal
    servers, using the device assigned for the IPMI/BMC's "Serial over LAN"
    feature.

If these kernel parameters are added during provisioning, they persist
after the provisioning is complete. Systemd will automatically activate the
serial console,
and there is no need to add a new Puppet class to make the changes.

Maybe we could make a generic param kernel_cmdline that would work with
> any OS. If you like the idea, file a feature ticket for me, easy change.

Sounds good. I'll file a ticket soon.

(Whoa, sorry for the delay. I thought I sent this message last week!)

-= Stefan

··· On Fri, Oct 14, 2016 at 1:21 AM, Lukas Zapletal wrote:


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/to
pic/foreman-users/pFSAPKen7QA/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.


Stefan Lasiewski Email: stefanl@nersc.gov
Computer System Engineer III Email: slasiewski@lbl.gov
NERSC Data Infrastructure Group

National Energy Research Scientific Computing Center (NERSC
http://nersc.gov)
Lawrence Berkeley National Laboratory

I hate to necro such an old thread, but did kernel_cmdline ever get implemented under a different name? Google is only helping me back to this page.

Based on what I saw in a code recently, kernelcmd is the current name https://github.com/theforeman/foreman/blob/develop/app/models/operatingsystem.rb#L316

1 Like