Using stages in puppet

9 views
Skip to first unread message

Richard Knight

unread,
Sep 2, 2010, 9:44:05 AM9/2/10
to Puppet Users
has anybody else noticed issues with nesting stage classes in 2.6.0?

Using Jeffs eariler post I easily make a stage script do what I need,
the problem is if you import it in site.pp it runs for every node in
the environment, it would seem becuase it is outside any class other
than it's special stage class . Any attempt to move the stageclass
structure inside a parent class to limit its execution seems to result
in script errors; As an example:

site.pp
----------
import "classes/works.pp"
import "classes/parent.pp"

node "my.domain.com {
include parent
}


works.pp
-------------

stage { "pre": before => Stage["main"] }
stage { "post": require => Stage["main"] }

class one { notify { "class one, first stage": } }
class two { notify { "class two, second stage": } }
class three { notify { "class three, third stage": } }

class { "one": stage => pre }
class { "two": }
class { "three": stage => post }


parent.pp
-------------

class parent {
stage { "pre": before => Stage["main"] }
stage { "post": require => Stage["main"] }

class one { notify { "class one, first stage": } }
class two { notify { "class two, second stage": } }
class three { notify { "class three, third stage": } }

class { "one": stage => pre }
class { "two": }
class { "three": stage => post }
}

the works.pp will work but will execute across all nodes regardless of
class structure or includes. parent.pp is one example of various
nesting attempts I have made to prevent staging from arbitrarily
executing the classes its using state on, but ultimatley always ends
up in an error. Through experimentation it seems that the special
stage class requires itself to be outside any other class, the problem
with this is that it will execute on any node in the environment
regardless of how you organize the classes its staging.

Markus

unread,
Sep 2, 2010, 8:08:27 PM9/2/10
to Puppet Users
Richard --

If I'm understanding you correctly, you've accurately described the
behaviour but it isn't really a problem. Stages aren't classes, and
they don't "do" anything unless you put resources in them, so there's
no real downside to having them global (which they effectively are).
Conversely, it isn't really meaningful to nest them in classes, since
they only exist as an organizing system among classes.

Think of stages as named time intervals like "before breakfast" or
"right after falling asleep" or even "just after typing the 43rd
letter of an e-mail"; we all have them (they are global) but only a
few of us ever even think about them.

Does that help?

-- Markus
Reply all
Reply to author
Forward
0 new messages