Adrian van Dongen
2011-Oct-12 11:09 UTC
[Puppet Users] Override values from default node inheritance (variable scoping).
Hi, I have a pretty basic question about variable scooping. We have been using puppet for the past few weeks now and were running into some problems which are probably caused by a lack of understanding or best practices. We have run into the following scenario and are not sure how to fix this. The majority of our host all use the same resolvers in our network (our internal dns servers) but there are a few node that are an exception, they need to use external dns servers. Our current puppet configuration has a default node template which includes a "resolver" class. Every node inherits the default node template. So for some host we would like to change the the resolver address. If we try to change this inside the node definition we get a "Duplicate definition" error. From what we know this is to be expected because of the variable scoping. We define companyname (see code snippet below) twice, once in the default node and once in the node definition. We currently fixed this by including the default node (class) instead of inheriting it. Although this solves our current problem we are wondering what the best way to go is in this setup. Is there a way to override the values with an default node of should we leave everything that isn''t a "true default" outside of the default node. Thanks you in advance for you answer. Regards, Adrian. Templates.pp: node default_template { ... include resolver resolver::resolv_conf { "company": domainname => "company.local", searchpath => [''company.local''], nameservers => [''192.168.1.123'', ''192.168.1.124''], } ... } Node configuration: node "node.company.local" inherits default_template { ... } Resolver class: class resolver { define resolv_conf($domainname = "$domain", $searchpath, $nameservers) { file { "/etc/resolv.conf": owner => root, group => root, mode => 644, content => template("resolver/resolv.conf.erb"), } } } -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.