Puppet Class execution order

1,828 views
Skip to first unread message

Larry Ludwig

unread,
Jun 14, 2011, 9:55:49 PM6/14/11
to puppet...@googlegroups.com
For the life of me I'm not sure why this isn't working properly but Puppet appears to execute classes in the order it feels like, not how I'm specifying it within the language.

I've tried the newer sytax

Class['one'] -> Class['two']

Yet, I see Class two get executed first.

I've also tried doing it by defining the class itself.

class { 'one': require => Class['two'] }

I've even gone down to the specific function within the class to see if this helps ie:

class {'one': require => Exec['withinclasstwo'] }

And the same issue.. what gives?

I haven't looked at the resource graph yet but the amount of modules we use it's almost readable.

How can I force one class to get executed first before the other? Why in my case is it not working?

Larry Ludwig

unread,
Jun 14, 2011, 10:00:34 PM6/14/11
to puppet...@googlegroups.com
Sorry the typo:

My examples should read:

class { 'two': require => Class['one'] }

class {'two: require => Exec['withinclassone'] }

Ken Barber

unread,
Jun 15, 2011, 9:25:16 AM6/15/11
to puppet...@googlegroups.com
So resource order is working in the following example:

class one {
notify{"class_one": message => "class one"}
}

class two {
notify{"class_two": message => "class two"}
}

class { "two": require => Class["one"] }

class { "one": }

kbarber:~ ken$ puppet apply -v tmp/executeorder.pp
info: Applying configuration version '1308143980'
notice: class one
notice: /Stage[main]/One/Notify[class_one]/message: defined 'message'
as 'class one'
notice: class two
notice: /Stage[main]/Two/Notify[class_two]/message: defined 'message'
as 'class two'
notice: Finished catalog run in 0.01 seconds

Even using the chained resource example you gave:

Class["one"]->Class["two"]

Now ... something to be careful of ... if you change the notify's and
make then notices you get:

kbarber:~ ken$ puppet apply -v tmp/executeorder.pp
notice: Scope(Class[Two]): two
notice: Scope(Class[One]): one
info: Applying configuration version '1308144128'
notice: Finished catalog run in 0.01 seconds
kbarber:~ ken$

This is because parse order is different to resource execution order.
Perhaps this is what you are seeing? Be mindful that code parsing
occurs on the server and generally follows the normal top
down/evaluation rules that most languages follow. Resource execution
is done after catalog creation time and happens on the client - this
is where your ordering specified with requires/chained resources kicks
in. Notify is a resource - so suffers client side ordering. Notice is
a function - so suffers parse order. Does that make sense?

By 'requiring' classes - you are requiring the class and all
_resources_ inside them. This won't change parse order though :-).

Can you post some more complete examples with some snippets of your
problem so we can all analyze your problem in detail perhaps?

ken.

> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-users/-/HIBnBYkxst4J.
> 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.
>

Larry Ludwig

unread,
Jun 15, 2011, 10:46:32 AM6/15/11
to puppet...@googlegroups.com
Thanks Ken,

Let me look further into the classes and see what's exactly happening.
Reply all
Reply to author
Forward
0 new messages