Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using the puppet vm to follow the puppet tutorial, and have the following manifest:

# /root/learning-manifests/2.file.pp

file {
  '/tmp/test1':
  ensure        => present,
  content => "Hi.",
}

file {
  '/tmp/test2':
  ensure     => directory,
  mode => 0644,
}

file {
  '/tmp/test3':
  ensure       => link,
  target => '/tmp/test1',
}

notify {
  "I'm notifying you.":
}

notify {
  "So am I!":
}

My expected output is:

notice: I'm notifying you.
notice: /Stage[main]//Notify[I'm notifying you.]/message: defined 'message' as 'I'm notifying you.'
notice: So am I!
notice: /Stage[main]//Notify[So am I!]/message: defined 'message' as 'So am I!'

My actual output is:

notice: So am I!
notice: /Stage[main]//Notify[So am I!]/message: defined 'message' as 'So am I!'
notice: I'm notifying you.
notice: /Stage[main]//Notify[I'm notifying you.]/message: defined 'message' as 'I'm notifying you.'
notice: Finished catalog run in 0.06 seconds

Can someone please explain why my notices are transposed.

Thanks.

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

As written in this PuppetLabs wiki page about Puppet ordering:

Puppet might sync them in any order: unlike with a procedural language, the physical order of resources in a manifest doesn’t imply a logical order.

You should use before, require, notify, subscribe to define dependencies between resources in your manifests. Also, you can define your dependencies by chaining your resource references. E.g:

notify {
  "I'm notifying you.":
}
-> 
notify {
  "So am I!":
}
share|improve this answer
    
Ordering came later in the tutorial - thanks for the example –  Romski Dec 22 '12 at 12:11
add comment

To guarantee order of execution in puppet you need to have some class hierarchy.

Definitions inside single class can be executed in any order, you cannot influence that.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.