Define @static macro

Hi all,

The Kickstart Default template refers to the @static macro determine
whether to configure the host with a static or dynamic IP. I found the
reference in
TemplateWriting - Foreman.
According to the documentation it's a Boolean value, however I cannot
figure out where to set it. Is it possible to set the macro or should I
pull the line out of my kickstart file?

Thanks,
Gareth

You can force it to be set from your PXELinux or iPXE bootloader by
changing the URL to the kickstart.

Currently you'll have something like this in a PXELinux file:

append initrd=<%= @initrd %> ks=<%= foreman_url('provision')%>
ksdevice=bootif network kssendmac

Instead, change the ks= bit to read:

ks=<%= foreman_url('provision')%>&static=yes

This will create a URL similar to
ks=https://foreman/unattended/provision?token=…&static=yes, and this
causes @static to be set inside the kickstart template, forcing a static
IP address.

Hope that helps.

··· On 27/03/14 16:16, Gareth Allen wrote: > Hi all, > > The Kickstart Default template refers to the @static macro determine > whether to configure the host with a static or dynamic IP. I found the > reference in > http://projects.theforeman.org/projects/foreman/wiki/TemplateWriting. > According to the documentation it's a Boolean value, however I cannot > figure out where to set it. Is it possible to set the macro or should I > pull the line out of my kickstart file?


Dominic Cleal
Red Hat Engineering

I have the same problem. I tried the work around but am still unable to use
a static IP for new hosts. I have just upgraded from 1.2 to 1.4, this was
working before the upgrade. So I have either broken it am missing
something.

After setting a static IP under the Network tab for a new host the review
option for the template shows the below:

network --bootproto dhcp --hostname test01.mydomain.com

I have this in my kickstart template:

network --bootproto <%= @static_proof ? "static --ip=#{@host.ip}
–netmask=#{@host.subnet.mask} --gateway=#{@host.subnet.gateway}
–nameserver=#{[@host.subnet.dns_primary,@host.subnet.dns_secondary].reject{|n|
n.blank?}.join(',')}" : 'dhcp' %> --hostname <%= @host %>

I have tried disabling safemode_render still no luck. I am simply unable to
write static IP config to the kickstart template.

There is no DHCP in place. I am using the foreman boot ISO so I need to get
this sorted.

I am having to manually set the IP in the my kickstart templates as a work
around.

Any help would be great, it's doing my head in!

> I have the same problem. I tried the work around but am still unable to
> use a static IP for new hosts. I have just upgraded from 1.2 to 1.4,
> this was working before the upgrade. So I have either broken it am
> missing something.
>
> After setting a static IP under the Network tab for a new host the
> review option for the template shows the below:
>
> network --bootproto dhcp --hostname test01.mydomain.com
>
> I have this in my kickstart template:
>
> network --bootproto <%= @static_proof ? "static --ip=#{@host.ip}
> --netmask=#{@host.subnet.mask} --gateway=#{@host.subnet.gateway}
> --nameserver=#{[@host.subnet.dns_primary,@host.subnet.dns_secondary].reject{|n|
> n.blank?}.join(',')}" : 'dhcp' %> --hostname <%= @host %>

This should say @static and not @static_proof.

> I have tried disabling safemode_render still no luck. I am simply unable
> to write static IP config to the kickstart template.
>
> There is no DHCP in place. I am using the foreman boot ISO so I need to
> get this sorted.

If the above doesn't fix it, can you paste the contents of your iPXE
template?

Regards,

··· On 01/04/14 21:48, Oleg Mcnoleg wrote:


Dominic Cleal
Red Hat Engineering