How to use DNS servers parameters in subnet

Hello,

In foreman you can define subnets, and define DNS servers for them. I want
to use these entries to configure the network in the hosts, using puppet
classes.
Currently i have my own custom class (which uses razoredge/network) to
reconfigure my network to bond both interfaces, and then declare it's IP
etc on the bond:

network::bond::static { 'bond0':
ensure => 'up',
ipaddress => "$::ipaddress",
peerdns => true,
dns1 => '172.16.1.102',
dns2 => '172.16.1.112',
gateway => '172.16.1.10',
domain => 'domain.local',
netmask => '255.255.255.0',
bonding_opts => 'mode=active-backup miimon=100'
}
network::bond::slave { 'em1':
ethtool_opts => 'autoneg off speed 1000 duplex full',
macaddress => "$::macaddress_em1",
master => 'bond0',
}
network::bond::slave { 'p1p1':
ethtool_opts => 'autoneg off speed 1000 duplex full',
macaddress => "$::macaddress_p1p1",
master => 'bond0',
}

However, as you can see I'm currently hard coding DNS servers and gateway.
I want to use the settings for the 172.16.1.0/24 subnet. How do I do this?

On a general note: Is there a list somewhere of all $:: variables I can use?

Krist

> However, as you can see I'm currently hard coding DNS servers and gateway.
> I want to use the settings for the 172.16.1.0/24 subnet. How do I do this?
>

In 1.3 you can use ERB in your parameters - so for example, you can create
a parameter like:

"mysubnet" => "<%= @host.subnet.network %>/<%= @host.subnet.cidr %>"

> On a general note: Is there a list somewhere of all $:: variables I can
> use?
>

Click the YAML button on a Host page to see all the data that's being sent
to Puppet for that Host.

··· On 6 November 2013 09:26, Krist van Besien wrote:

>
>> However, as you can see I'm currently hard coding DNS servers and
>> gateway. I want to use the settings for the 172.16.1.0/24 subnet. How do
>> I do this?
>>
>
> In 1.3 you can use ERB in your parameters - so for example, you can create
> a parameter like:
>
> "mysubnet" => "<%= @host.subnet.network %>/<%= @host.subnet.cidr %>"
>

Another option, since 1.3, its possible to use erb within foreman
parameters…

e.g.

add a new parameter somewhere (domain etc) and in the value for you could
do:
<%= "#{host.subnet.network}" %>

in theory, you could go further and even use host.subnet.attributes and
pass it to create_resource, but you might need to turn off safe rendering
for that.

Ohad

··· On Wed, Nov 6, 2013 at 2:03 PM, Greg Sutcliffe wrote: > On 6 November 2013 09:26, Krist van Besien wrote:

On a general note: Is there a list somewhere of all $:: variables I can
use?

Click the YAML button on a Host page to see all the data that’s being sent
to Puppet for that Host.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, 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 http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks. I'm going to try that out.

On a related note. Is it possible to define multiple subnets for a host in
foreman?

Krist

··· On Wednesday, November 6, 2013 1:03:17 PM UTC+1, Greg Sutcliffe wrote: > > On 6 November 2013 09:26, Krist van Besien <krist.v...@gmail.com > > wrote: > >> However, as you can see I'm currently hard coding DNS servers and >> gateway. I want to use the settings for the 172.16.1.0/24 subnet. How do >> I do this? >> > > In 1.3 you can use ERB in your parameters - so for example, you can create > a parameter like: > > "mysubnet" => "<%= @host.subnet.network %>/<%= @host.subnet.cidr %>" >

You can add multiple interfaces to a host in Foreman with different
subnets, IP addresses and names which are available then as
@host.interfaces in templates.

Check
TemplateWriting - Foreman for
some notes on using it. I think you may need to disable render_safemode
for access to these variables.

··· On 11/11/13 10:35, Krist van Besien wrote: > > > On Wednesday, November 6, 2013 1:03:17 PM UTC+1, Greg Sutcliffe wrote: > > On 6 November 2013 09:26, Krist van Besien > wrote: > > However, as you can see I'm currently hard coding DNS servers > and gateway. I want to use the settings for the 172.16.1.0/24 > subnet. How do I do this? > > > In 1.3 you can use ERB in your parameters - so for example, you can > create a parameter like: > > "mysubnet" => "<%= @host.subnet.network %>/<%= @host.subnet.cidr %>" > > > > Thanks. I'm going to try that out. > > On a related note. Is it possible to define multiple subnets for a host > in foreman?


Dominic Cleal
Red Hat Engineering