How to configure multiple network interface as static in foreman

Hello ,

I am building new virtual server with eth0 and eth1 using foreman. I am
able to configure eth0 as static ip address during provisioning but i dont
get any idea about how to configure static ip address on eth1.

APPEND initrd=<%= @initrd %> ks=<%= foreman_url('provision')%>&static=yes
ks.device=bootif network ks.sendmac

eth1 is assign ip address with dhcp please refer below output.

network --onboot no --device eth1 --bootproto dhcp --noipv6 --hostname
XXXXXX

Please let me know to how to configure static ip address on eth1 using
foreman template.

//pradeep

Hello,

to configure additional interfaces (eth1 in your case) we use configuration
snippet as part of kickstart template (%post section). All you have to do is
to define eth1 correctly in Interfaces tab when you build a new host. If you
prefer static configuration, you'll have to define Subnet accordingly first.
Subnet should have IPAM attribute set to Internal DB and Boot mode should be
set to Static. Make sure that the interface is associated with this Subnet and
its Managed flag is checked.

Hope this helps

··· On Wednesday 15 of July 2015 07:42:49 Pradeep wrote: > Hello , > > I am building new virtual server with eth0 and eth1 using foreman. I am > able to configure eth0 as static ip address during provisioning but i dont > get any idea about how to configure static ip address on eth1. > > APPEND initrd=<%= @initrd %> ks=<%= foreman_url('provision')%>&static=yes > ks.device=bootif network ks.sendmac > > eth1 is assign ip address with dhcp please refer below output. > > network --onboot no --device eth1 --bootproto dhcp --noipv6 --hostname > XXXXXX > > > Please let me know to how to configure static ip address on eth1 using > foreman template. > > //pradeep


Marek

Not sure if this is 'proper' way to do this, but this is what I'm doing:

<% if i.identifier == 'eth0' %>
network --bootproto static --ip <%= i.ip %> --netmask <%= i.subnet.mask %>
–device <%= i.identifier %> --gateway=<%= @host.subnet.gateway %>
<%else %>
network --bootproto static --ip <%= i.ip %> --netmask <%= i.subnet.mask %>
–device <%= i.identifier %>
<% end %>
<% end %>

··· On Wednesday, July 15, 2015 at 10:43:14 AM UTC-4, Pradeep wrote: > > Hello , > > I am building new virtual server with eth0 and eth1 using foreman. I am > able to configure eth0 as static ip address during provisioning but i dont > get any idea about how to configure static ip address on eth1. > > APPEND initrd=<%= @initrd %> ks=<%= foreman_url('provision')%>&static=yes > ks.device=bootif network ks.sendmac > > eth1 is assign ip address with dhcp please refer below output. > > network --onboot no --device eth1 --bootproto dhcp --noipv6 --hostname > XXXXXX > > > Please let me know to how to configure static ip address on eth1 using > foreman template. > > //pradeep > >

Hello Marek,

Can i have sample of configuration snippet to configure multiple interface.

//pradeep

··· On Thursday, July 16, 2015 at 9:27:27 AM UTC+2, Marek Hulan wrote: > > On Wednesday 15 of July 2015 07:42:49 Pradeep wrote: > > Hello , > > > > I am building new virtual server with eth0 and eth1 using foreman. I am > > able to configure eth0 as static ip address during provisioning but i > dont > > get any idea about how to configure static ip address on eth1. > > > > APPEND initrd=<%= @initrd %> ks=<%= > foreman_url('provision')%>&static=yes > > ks.device=bootif network ks.sendmac > > > > eth1 is assign ip address with dhcp please refer below output. > > > > network --onboot no --device eth1 --bootproto dhcp --noipv6 --hostname > > XXXXXX > > > > > > Please let me know to how to configure static ip address on eth1 using > > foreman template. > > > > //pradeep > > Hello, > > to configure additional interfaces (eth1 in your case) we use > configuration > snippet as part of kickstart template (%post section). All you have to do > is > to define eth1 correctly in Interfaces tab when you build a new host. If > you > prefer static configuration, you'll have to define Subnet accordingly > first. > Subnet should have IPAM attribute set to Internal DB and Boot mode should > be > set to Static. Make sure that the interface is associated with this Subnet > and > its Managed flag is checked. > > Hope this helps > > -- > Marek >

Hi

you can find it among provisioning template, search for
kickstart_networking_setup. Alternatively you can find it in our community
repo at [1]. But as I stated before, you shouldn't need to touch it at all,
you just have to define interfaces in host form, the snippet will create ifcfg
files accordingly using this snippet.

[1] https://github.com/theforeman/community-templates/blob/develop/snippets/kickstart_networking_setup.erb

··· -- Marek

On Thursday 16 of July 2015 02:52:37 Pradeep wrote:

Hello Marek,

Can i have sample of configuration snippet to configure multiple interface.

//pradeep

On Thursday, July 16, 2015 at 9:27:27 AM UTC+2, Marek Hulan wrote:

On Wednesday 15 of July 2015 07:42:49 Pradeep wrote:

Hello ,

I am building new virtual server with eth0 and eth1 using foreman. I am
able to configure eth0 as static ip address during provisioning but i

dont

get any idea about how to configure static ip address on eth1.

APPEND initrd=<%= @initrd %> ks=<%=

foreman_url(‘provision’)%>&static=yes

ks.device=bootif network ks.sendmac

eth1 is assign ip address with dhcp please refer below output.

network --onboot no --device eth1 --bootproto dhcp --noipv6 --hostname
XXXXXX

Please let me know to how to configure static ip address on eth1 using
foreman template.

//pradeep

Hello,

to configure additional interfaces (eth1 in your case) we use
configuration
snippet as part of kickstart template (%post section). All you have to do
is
to define eth1 correctly in Interfaces tab when you build a new host. If
you
prefer static configuration, you’ll have to define Subnet accordingly
first.
Subnet should have IPAM attribute set to Internal DB and Boot mode should
be
set to Static. Make sure that the interface is associated with this Subnet
and
its Managed flag is checked.

Hope this helps


Marek

Hey Marek

I am looking at satellite 6.1 which uses foreman 1.7. It is indicated here
that static IPs can be set in the main PXE provisioning template… but the
example is not clear on how to reference the NICs that are entered through
the GUI. how are these valuves stored? Do we need to supply some looping
logic to cycle through each nic?

<% if @host.params['my_param_deploy_static'] == "true" -%>
network --bootproto <%= "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(',')}" %> --hostname <%= @host %>
<% else -%>
network --bootproto 'dhcp' --hostname <%= @host %>
<% end -

https://access.redhat.com/documentation/en-US/Red_Hat_Satellite/6.1/html/Provisioning_Guide/sect-Red_Hat_Satellite-Provisioning_Guide-Provisioning_Hosts_with_Static_IP_Addresses.html#sect-Red_Hat_Satellite-Provisioning_Guide-Provisioning_Hosts_with_Static_IP_Addresses-Using_Custom_Templates_to_Assign_Static_IP_Addresses

The kickstart snippet you have linked seems to reference the primary
interface which i get… but how to reference each additional interface?
the examples speak of managed and bonded interfaces. i am unclear here and
also is it a matter of choice if you do it in the main kickstart or in a
snippper

Hello

I was referring to something that's described in section 6.3.3. of document
you've sent. In this case you don't need to touch templates at all.

> Hey Marek
>
> I am looking at satellite 6.1 which uses foreman 1.7. It is indicated here
> that static IPs can be set in the main PXE provisioning template… but the
> example is not clear on how to reference the NICs that are entered through
> the GUI. how are these valuves stored? Do we need to supply some looping
> logic to cycle through each nic?
>
> <% if @host.params['my_param_deploy_static'] == "true" -%>
> network --bootproto <%= "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(',')}" %> --hostname <%= @host %> <% else -%>
> network --bootproto 'dhcp' --hostname <%= @host %>
> <% end -

Yes, you'd have to loop through all interfaces like
<% @host.interfaces.each do |interface| %>
network --ootproto statuc --ip=<%= interface.ip -%>…
<% end %>

See [1] for all macros that you can use in this template. Btw this is what's
suggested in 6.3.1, but I would still recommend 6.3.3.

> https://access.redhat.com/documentation/en-US/Red_Hat_Satellite/6.1/html/Pro
> visioning_Guide/sect-Red_Hat_Satellite-Provisioning_Guide-Provisioning_Hosts
> _with_Static_IP_Addresses.html#sect-Red_Hat_Satellite-Provisioning_Guide-Pro
> visioning_Hosts_with_Static_IP_Addresses-Using_Custom_Templates_to_Assign_St
> atic_IP_Addresses
>
> The kickstart snippet you have linked seems to reference the primary
> interface which i get… but how to reference each additional interface?
> the examples speak of managed and bonded interfaces. i am unclear here and
> also is it a matter of choice if you do it in the main kickstart or in a
> snippper

The snippet configures all interfaces, it just handles the primary interface
separately. The snippet is included into kickstart template (in %post section)
so it's used automatically. If you for some reason prefer to modify the
template yourself (6.3.1/6.3.2) you can use this snippet to get some ideas how
to iterate over host interfaces.

[1] TemplateWriting - Foreman

Hope this helps

··· On Wednesday 22 of July 2015 06:14:52 Matzuba wrote:


Marek

Thanks again for the reply.

I dont understand 6.3.3 - setting by subnet. Will this just allocate any
ip in the subnet and then set this to a static interface? or are the
valves still pulled from those entered for the hosts network details?
I thinking 6.3.2 is more suitables if these are the valuves pulled from
the GUI nic details you enter.

I just dont get the variable "if @host.params['my_param_deploy_static'] ==
"true" -%>" as it does not appear as a variable/class or whatever on the
template page.
I can see host.interfaces so that makes sense as you loop over that array
of nics

I think what you are saying is that the snippet should just work with
whatever i enter in the GUI and i should really have to play with the
snippet at all?

it will become clearer once i have this version installed and test

cheers

Hello

few comments below

> Thanks again for the reply.
>
> I dont understand 6.3.3 - setting by subnet. Will this just allocate any
> ip in the subnet and then set this to a static interface? or are the
> valves still pulled from those entered for the hosts network details?
> I thinking 6.3.2 is more suitables if these are the valuves pulled from
> the GUI nic details you enter.

It will allocate IP from that subnet and fill it in the hosts network details
for you (you can still override it if needed). So what you set in GUI always
wins.

> I just dont get the variable "if @host.params['my_param_deploy_static'] ==
> "true" -%>" as it does not appear as a variable/class or whatever on the
> template page.

You'd have to create such parameters first. See Global parameters subsection
of Parameters chapter [1] in our manual for more info.

> I can see host.interfaces so that makes sense as you loop over that array
> of nics
>
> I think what you are saying is that the snippet should just work with
> whatever i enter in the GUI and i should really have to play with the
> snippet at all?

Correct

>
> it will become clearer once i have this version installed and test
>
> cheers

Hope this helps

[1] http://www.theforeman.org/manuals/1.8/index.html#4.2.3Parameters

··· On Thursday 23 of July 2015 06:48:18 you wrote:


Marek