[Puppet Users] Overriding a resource created in a define

114 views
Skip to first unread message

Ben Beuchler

unread,
Apr 21, 2010, 6:10:46 PM4/21/10
to puppet...@googlegroups.com
I'm using the resolv.conf pattern described here:

http://projects.puppetlabs.com/projects/puppet/wiki/Resolv_Conf_Patterns

In my node templates I have a "base" class that does all of the
housekeeping chores to set up a basic server (install preferred
editors, subversion, etc.). I added a call to the resolv_conf define
to set up the standard /etc/resolv.conf file used by 95% of our
systems. Of course, there are exceptions. I can't call the
resolv_conf define again in a specific node to generate a new config.
Any suggested approaches?

Thanks!

-Ben

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

John Lyman

unread,
Apr 22, 2010, 9:16:57 AM4/22/10
to Puppet Users
Here's how I do it...

In my nodes.pp, I define certain global variables at the top of the
manifest, outside of any node definitions. If I want to override a
default variable, I redefine the variable inside of the specific node
definition, before I include the class that uses the variable.

For example:
> cat nodes.pp
# defaults
$dnsname = "foo.local"
$dnsserver = [ "192.168.1.1", "192.168.2.1" ]
$dnssearchpath = [ "foo", "foo.local" ]

node "standard.node" {
include basenode
}

node "nonstandard.node" {
$dnsname = "bar.local"
$dnsserver = [ "192.168.100.1", "192.168.101.1" ]
$dnssearchpath = [ "bar", "bar.local" ]
include basenode
}

In my case, basenode includes a network module that contains a
resolv.conf file resource. The resolv.conf resource references the
variables instead of hard coding the actual values. So, your
definition would look like this:

resolv_conf { "example":
domainname => $dnsname,
searchpath => $dnssearchpath,
nameservers => $dnsserver,
}

I'm not using the same resolv.conf recipe that you are, but I think I
want to tweak my template a little now :)
Reply all
Reply to author
Forward
0 new messages