Understanding the "default" node.

6 views
Skip to first unread message

Fred Clausen

unread,
Dec 22, 2008, 8:22:50 AM12/22/08
to Puppet Users
Hello,

We are making an initial, small scale Puppet deployment to test Puppet
and also to learn more of how Puppet can be used in our environment.

My question is regarding the default node and how it applies when a
defined node connects - this is perhaps best explained with a few
examples, to start with a very basic nodes.pp -

--- nodes.pp ---
node default {
include unix
}
--- eof ---

The "unix" class is just the permissions and ownership policy for the
passwd, group and shadow files - a fairly standard example.

I wish to expand the nodes.pp to look like this -

--- nodes.pp ---
node default {
include unix
}

node freebsd-box {
File["/etc/passwd"] { group => wheel }
File["/etc/shadow"] { group => wheel }
}
--- eof ---

Does the default node apply to all nodes, including those with their
own node entry or only nodes without an explicit node entry? That is,
will I need to make the "freebsd-box" explicitly inherit the "default"
node?

I hope this makes sense - feel free to ask for clarification.

Cheers,

Fred.

Trevor Vaughan

unread,
Dec 22, 2008, 8:58:14 AM12/22/08
to puppet...@googlegroups.com
Fred,

This does indeed make sense and yes, you will need to 'inherit' the
default node to have other nodes apply the settings.

Trevor

Peter Meier

unread,
Dec 22, 2008, 9:08:44 AM12/22/08
to puppet...@googlegroups.com
Hi

> This does indeed make sense and yes, you will need to 'inherit' the
> default node to have other nodes apply the settings.

well actually you have to inherit the unix class, that you overwrite the
parameters.
Pay attention to the fact that inheritance in nodes is slightly
different than in classes. The Best thing imho is to build such
inheritance in the classes itself and leave any inheritance out of the
node definitions.

cheers pete

Evan Hisey

unread,
Dec 22, 2008, 10:41:53 AM12/22/08
to puppet...@googlegroups.com
Fred-

> Does the default node apply to all nodes, including those with their
> own node entry or only nodes without an explicit node entry? That is,
> will I need to make the "freebsd-box" explicitly inherit the "default"
> node?
>

The answer as stated in
http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial#nodes, is
that the default node is used when there is _no_ other matching node.

Evan

Fred Clausen

unread,
Dec 22, 2008, 10:52:41 AM12/22/08
to Puppet Users
Hi,

On Dec 22, 4:41 pm, "Evan Hisey" <ehi...@gmail.com> wrote:
> Fred-
>
> > Does the default node apply to all nodes, including those with their
> > own node entry or only nodes without an explicit node entry? That is,
> > will I need to make the "freebsd-box" explicitly inherit the "default"
> > node?
>
> The answer as stated inhttp://reductivelabs.com/trac/puppet/wiki/LanguageTutorial#nodes, is
> that the default node is used when there is _no_ other matching node.
>

Thanks all for the helpful advice and the timely reference to the Fine
Manual :-) I will indeed do the inheritance through the the classes -
perhaps make a class called "myworkplace-standard" that will pull in
all classes we need and include this "myworkplace-standard" in all
nodes (default or otherwise.)

Cheers,

Fred.

Robin Lee Powell

unread,
Dec 22, 2008, 2:22:23 PM12/22/08
to puppet...@googlegroups.com
On Mon, Dec 22, 2008 at 03:08:44PM +0100, Peter Meier wrote:
>
> Pay attention to the fact that inheritance in nodes is slightly
> different than in classes. The Best thing imho is to build such
> inheritance in the classes itself and leave any inheritance out of
> the node definitions.

Can you explain that in a bit more detail?

-Robin

--
They say: "The first AIs will be built by the military as weapons."
And I'm thinking: "Does it even occur to you to try for something
other than the default outcome?" -- http://shorl.com/tydruhedufogre
http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/

Peter Meier

unread,
Dec 22, 2008, 5:32:07 PM12/22/08
to puppet...@googlegroups.com
Hi

>> Pay attention to the fact that inheritance in nodes is slightly
>> different than in classes. The Best thing imho is to build such
>> inheritance in the classes itself and leave any inheritance out of
>> the node definitions.
>
> Can you explain that in a bit more detail?

Some of that I explained in these 2 mails:

http://markmail.org/message/ivwno5cpaouavgsu
http://markmail.org/message/ls2bxc7yqwre564s

however, I thought that I explained in another thread it more in a
detail, but I can't find it anymore.
If you have further questions, don't hesitate to ask.

cheers pete

Jeffrey Hulten

unread,
Dec 23, 2008, 9:48:58 PM12/23/08
to puppet...@googlegroups.com
So the way I have implemented it is that we have a basenode node with the common elements that all nodes get.  The basenode is then inherited by each of the specific nodes, therefore you get something like:

import "foo"
import "httpd"

node basenode {
 include foo
}

node webnode inherits basenode {
 include httpd
}

node www1.example.com inherits webnode {}
node www2.example.com inherits webnode {}


Does that make sense?

Peter Meier

unread,
Dec 24, 2008, 3:55:09 AM12/24/08
to puppet...@googlegroups.com
Hi

> So the way I have implemented it is that we have a basenode node with the
> common elements that all nodes get. The basenode is then inherited by each
> of the specific nodes, therefore you get something like:
>
> import "foo"
> import "httpd"
>
> node basenode {
> include foo
> }
>
> node webnode inherits basenode {
> include httpd
> }
>
> node www1.example.com inherits webnode {}
> node www2.example.com inherits webnode {}
>
>
> Does that make sense?


yeah that will work. However sooner or later you will get one problem here:

if you use in the class httpd a variable which should be defined in the
node and you will define this variable in the definition of
www1.example.com, this variable will always be empty, as the class gets
evaluated before the variable is set in the subnode of the webnode.

So something like that, will give you problems:

node webnode inherits basenode {
include httpd
}

node www1.example.com inherits webnode {
# i'm used in the class httpd
$httpd_server_name = $fqdn
}

this is how inheritance works for nodes and which "confuses" a lot of
people. Therefore imho the best thing is to do inheritance in a bunch of
config-classes and using nodes only to set variables and include the
config class in every node _after_ setting all the variables. Or
switching over to external nodes, which will give you a lot more
flexibility than the site.pp file.

cheers pete

Carl Caum

unread,
Dec 24, 2008, 9:49:39 AM12/24/08
to puppet...@googlegroups.com

On Dec 24, 2008, at 2:55 AM, Peter Meier wrote:

>
> Hi
>
>> So the way I have implemented it is that we have a basenode node
>> with the
>> common elements that all nodes get. The basenode is then inherited
>> by each
>> of the specific nodes, therefore you get something like:
>>
>> import "foo"
>> import "httpd"
>>
>> node basenode {
>> include foo
>> }
>>
>> node webnode inherits basenode {
>> include httpd
>> }
>>
>> node www1.example.com inherits webnode {}
>> node www2.example.com inherits webnode {}
>>
>>
>> Does that make sense?
>
>
> yeah that will work. However sooner or later you will get one
> problem here:
>
> if you use in the class httpd a variable which should be defined in
> the
> node and you will define this variable in the definition of
> www1.example.com, this variable will always be empty, as the class
> gets
> evaluated before the variable is set in the subnode of the webnode.

I understand this is just the way puppet works, but it's very
counterintuitive. If puppet wasn't a declarative language, it would
make perfect sense. Shouldn't puppet gather all variables and set
their values before evaluating resources? I haven't delved in to the
code to see if this is possible or not.
Reply all
Reply to author
Forward
0 new messages