FAQ
Hello,

I am a beginner in puppet so please excuse my lack of knowledge.
(I use puppet 3.1).

We have nodes in different networks - they use different DNS servers.
I'd like to set up its /etc/resolv.conf dependent on network they are in.

What approach would you recommend to solve the problem ?

Thanks in advance
Przemek

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Josh at Apr 12, 2013 at 9:09 am

    On Friday, April 12, 2013 9:44:31 AM UTC+1, ForumUser wrote:

    We have nodes in different networks - they use different DNS servers.
    I'd like to set up its /etc/resolv.conf dependent on network they are in.
    Are you using Hiera? We run multiple datacentres that have different
    management networks, syslog servers and such, I provide the server with
    knowledge of the datacentre with a custom fact (which just reads a file in
    my case) and then in the hiera config I have:

    :hierarchy:
       - nodes/%{hostname}
       - common/%{datacentre}

    Then anything specific to the datacentre goes in that file. You could
    easily do something similar for the network.

    Alternatively you might be able to define it all in a case statement
    matching the IP address of the server, although depending on how
    complicated your network architecture the regexs could become complicated:

    case $::ipaddress_eth0 {
      /^192.168.1/: { $nameserver = '192.168.1.254' }
      /^192.168.2/: { $nameserver = '192.168.2.254' }
    }

    Josh

    --
    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+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.
  • ForumUser at Apr 12, 2013 at 9:37 am
    We are not using Hiera yet (but it seems that this is what we should do in
    the close future ...)
    At the moment the regexp expression is the simplest one.
    Thank you :-)
    On Friday, 12 April 2013 10:09:00 UTC+1, Josh wrote:
    On Friday, April 12, 2013 9:44:31 AM UTC+1, ForumUser wrote:

    We have nodes in different networks - they use different DNS servers.
    I'd like to set up its /etc/resolv.conf dependent on network they are in.
    Are you using Hiera? We run multiple datacentres that have different
    management networks, syslog servers and such, I provide the server with
    knowledge of the datacentre with a custom fact (which just reads a file in
    my case) and then in the hiera config I have:

    :hierarchy:
    - nodes/%{hostname}
    - common/%{datacentre}

    Then anything specific to the datacentre goes in that file. You could
    easily do something similar for the network.

    Alternatively you might be able to define it all in a case statement
    matching the IP address of the server, although depending on how
    complicated your network architecture the regexs could become complicated:

    case $::ipaddress_eth0 {
    /^192.168.1/: { $nameserver = '192.168.1.254' }
    /^192.168.2/: { $nameserver = '192.168.2.254' }
    }

    Josh
    --
    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+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.
  • ForumUser at Apr 12, 2013 at 2:54 pm
    Josh,

    what if I have 192.168.* with exception of 192.168.100.* ?
    Is the order in case statement important ?
    E.g.:

    case $::ipaddress_eth0 {
      /^192.168.100/: { $nameserver = '192.168.100.254' }
      /^192.168./: { $nameserver = '192.168.1.254' }
    }


    On Friday, 12 April 2013 10:09:00 UTC+1, Josh wrote:
    On Friday, April 12, 2013 9:44:31 AM UTC+1, ForumUser wrote:

    We have nodes in different networks - they use different DNS servers.
    I'd like to set up its /etc/resolv.conf dependent on network they are in.
    Are you using Hiera? We run multiple datacentres that have different
    management networks, syslog servers and such, I provide the server with
    knowledge of the datacentre with a custom fact (which just reads a file in
    my case) and then in the hiera config I have:

    :hierarchy:
    - nodes/%{hostname}
    - common/%{datacentre}

    Then anything specific to the datacentre goes in that file. You could
    easily do something similar for the network.

    Alternatively you might be able to define it all in a case statement
    matching the IP address of the server, although depending on how
    complicated your network architecture the regexs could become complicated:

    case $::ipaddress_eth0 {
    /^192.168.1/: { $nameserver = '192.168.1.254' }
    /^192.168.2/: { $nameserver = '192.168.2.254' }
    }

    Josh
    --
    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+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Josh at Apr 12, 2013 at 3:29 pm

    On Friday, April 12, 2013 3:54:16 PM UTC+1, ForumUser wrote:
    what if I have 192.168.* with exception of 192.168.100.* ?
    Is the order in case statement important ?
    E.g.:

    case $::ipaddress_eth0 {
    /^192.168.100/: { $nameserver = '192.168.100.254' }
    /^192.168./: { $nameserver = '192.168.1.254' }
    }
    It will choose the first match in the case statement.

    You can also add a default (and I would always have a default anyway, even
    if it is just to fail with a sensible message)

    case $::ipaddress_eth0 {
    /^192.168.100/: { $nameserver = '192.168.100.254' }
    /^192.168./: { $nameserver = '192.168.1.254' }
    default: { fail("You shouldn't get this far") }
    }

    --
    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+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users?hl=en.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Jakov Sosic at Jul 1, 2013 at 4:53 pm

    On 04/12/2013 10:44 AM, ForumUser wrote:
    Hello,

    I am a beginner in puppet so please excuse my lack of knowledge.
    (I use puppet 3.1).

    We have nodes in different networks - they use different DNS servers.
    I'd like to set up its /etc/resolv.conf dependent on network they are in.

    What approach would you recommend to solve the problem ?
    Use facts about your network, like ip_address and netmask, and calculate
    nameservers from that info:

    $ facter -p | egrep "^(ipaddress |netmask )"
    ipaddress => 192.168.0.164
    netmask => 255.255.255.0

    --
    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+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedApr 12, '13 at 8:44a
activeJul 1, '13 at 4:53p
posts6
users3
websitepuppetlabs.com

3 users in discussion

ForumUser: 3 posts Josh: 2 posts Jakov Sosic: 1 post

People

Translate

site design / logo © 2021 Grokbase