意外的Puppet通知订单

我用傀儡vm跟随木偶教程,并有以下清单:

# /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!": } 

我的预期产出是:

 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!' 

我的实际产出是:

 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 

有人可以解释为什么我的通知转置。

谢谢。

正如写在这个PuppetLabs维基页面关于Puppetsorting:

Puppet可能会以任何顺序同步它们:与过程语言不同,清单中资源的物理顺序并不意味着逻辑顺序。

您应该使用before,require,notify,subscribe来定义清单中资源之间的依赖关系。 另外,您可以通过链接资源引用来定义您的依赖关系。 例如:

 notify { "I'm notifying you.": } -> notify { "So am I!": } 

为了保证在傀儡的执行顺序,你需要有一些类的层次结构。

单class内部的定义可以以任何顺序执行,你不能影响。