exclusion/exception in server.pp file

48 views
Skip to first unread message

puppetstan

unread,
Mar 12, 2014, 12:40:32 PM3/12/14
to puppet...@googlegroups.com
Hello

I have define in my server.pp file diferent zone and I defined my dns servers
(resolv_servers). for my /etc/resolv.conf for this zone


#Zone 1
        if $::ipaddress =~ /^172.17.3./ {
        $ntp_heure = "ntp.domain.fr"
        $fusioninventory_proxy = "http://proxy.domain.fr:8080"
        $resolv_servers = [ '172.30.12.11', '172.30.12.2' ]
        $resolv_search = "domain.fr"
        $yumconf_proxy = "http://proxy.domain.fr:8080"
        $yumconf_exclude = "kernel*"
        include base::minimal
        }


The problem is that in this zone one server (
172.17.3.4) that does not have the same dns. Is it possible to make an exclusion on this server and specify other addresses ips in this config file?

thank you in advance

Peter Bukowinski

unread,
Mar 12, 2014, 1:56:05 PM3/12/14
to puppet...@googlegroups.com
One way to add an exclusion for a single value is to use a selector to assign a unique value for $resolv_servers based on ip address. Non-matching hosts get the default.

if $::ipaddress =~ /^172.17.3./ {
$ntp_heure = "ntp.domain.fr"
$fusioninventory_proxy = "http://proxy.domain.fr:8080"
$resolv_servers = $::ipaddress ? {
'172.17.3.4' => [ 'a.b.c.d', 'w.x.y.z' ],
default => [ '172.30.12.11', '172.30.12.2' ],
}
$resolv_search = "domain.fr"
$yumconf_proxy = "http://proxy.domain.fr:8080"
$yumconf_exclude = "kernel*"
include base::minimal
}

--
Peter Bukowinski

José Luis Ledesma

unread,
Mar 12, 2014, 2:02:06 PM3/12/14
to puppet...@googlegroups.com

Hi,

  This kind of code is screaming for hiera!

But if you want to continue this way, just set another if
if $::ipaddress =~ /^172.17.3.4/ {
   Data here
} elsif  $::ipaddress =~ /^172.17.3./ {
    Another data here
}

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/dc908091-8fbe-4e46-a5bb-4e1d1b2e503c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

puppetstan

unread,
Mar 13, 2014, 2:28:46 PM3/13/14
to puppet...@googlegroups.com
Hi

Thanks for your answer.

You say This kind of code is screaming, but what is your solution when you have a lot of server and the only solution is to locate with the IP address

your prefer :

node1
node2
...
node 200
...
??

regards

José Luis Ledesma

unread,
Mar 13, 2014, 4:07:44 PM3/13/14
to puppet...@googlegroups.com

Facts + hiera is the short answer.

If different IP ranges means different zones or sites, just create a custom fact that returns the zone/site name. Setup the zone/site hierarchically in hiera and set the data there. Setup a higher level with the hostame in hiera and put the exceptions there.

Regards

puppetstan

unread,
Mar 21, 2014, 1:29:19 PM3/21/14
to puppet...@googlegroups.com
Thanks for your answer, can you have an example with two zones please?

regards
Reply all
Reply to author
Forward
0 new messages