Ask Your Question
0

Which class is call first in manifest?

asked 2015-04-23 09:05:50 -0500

akshay gravatar image

I wrote the code in site.pp file i.e. I am included the 4 classes in my site.pp file. So my question is, Which class is called first? What sequence it call the classes?

node 'node_name' {
include class1
include class2
include class3
include class4
}

So these are my classes. I have to install this classes in sequential manner. But it could not seem like this. It install the last class first and then randomly whatever class. So what code should written in my manifest that's why it run in sequential manner i.e first to last Please help me. Its very urgent. Thanks in Advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-04-23 09:09:24 -0500

JohnsonEarls gravatar image

updated 2015-04-23 14:02:40 -0500

To install in a sequential manner, you need to chain the classes with require / before or subscribe / notify parameters, or use the -> and ~> chaining operators:

node 'node_name' {
    include class1
    include class2
    include class3
    include class4
    # classes must run in specific order:
    Class['class1'] -> Class['class2'] -> Class['class3'] -> Class['class4']
}

Please see the Language: Relationships and Ordering documentation page for details

An example:

# manifests/test.pp
include class1
include class2
include class3
include class4

# require this specific order:
Class['class3'] -> Class['class1'] -> Class['class4'] -> Class['class2']

Test via apply:

$ puppet apply --modulepath=`pwd`/modules manifests/test.pp
Notice: Compiled catalog for ... in environment production in 0.03 seconds
Notice: class3
Notice: /Stage[main]/Class3/Notify[class3]/message: defined 'message' as 'class3'
Notice: class1
Notice: /Stage[main]/Class1/Notify[class1]/message: defined 'message' as 'class1'
Notice: class4
Notice: /Stage[main]/Class4/Notify[class4]/message: defined 'message' as 'class4'
Notice: class2
Notice: /Stage[main]/Class2/Notify[class2]/message: defined 'message' as 'class2'
Notice: Finished catalog run in 0.03 seconds
edit flag offensive delete link more

Comments

But in my situation it could not like this. It install the last call first then another. But I have to install the first class and then second and so on.

akshay gravatar imageakshay ( 2015-04-23 09:11:52 -0500 )edit

@akshay : The line I put in at the end is what will _cause_ the classes to be applied in a specific order.

JohnsonEarls gravatar imageJohnsonEarls ( 2015-04-23 13:47:26 -0500 )edit

One thing to be aware of here is if the included classes include other classes themselves, you'll have the "containment problem" described here: https://puppetlabs.com/blog/class-containment-puppet. If so, the include statements above may need to be changed to be contain statements.

GregLarkin gravatar imageGregLarkin ( 2015-04-23 16:48:21 -0500 )edit

Johnson, What you say I am not understand. Where to put this line? And what to written in that file? Please mention in quotes. Give me answer fast. Its very urgent for me.

akshay gravatar imageakshay ( 2015-04-24 00:48:44 -0500 )edit

akshay: look at the last line of my original example. that shows you how to use the chain operators to ensure that class 1 is applied before class 2 which is applied before class 3 which is applied before class 4.

JohnsonEarls gravatar imageJohnsonEarls ( 2015-04-24 01:06:16 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-04-23 09:05:50 -0500

Seen: 1,624 times

Last updated: Apr 23 '15