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

Currently, I am writing a puppet module for managing my sensu configuration.

Have split the whole thing into several classes and put them into their respective files in the sensu "manifests" directory:

sensu::common          (common.pp)
sensu::common::package (common/package.pp)
sensu::common::config  (common/config.pp)
sensu::server          (server.pp)
sensu::server::config  (server/config.pp)

In my server.pp, I have the following

class sensu::server {
  include sensu::common
  include sensu::server::config

  Class['sensu::common'] -> Class['sensu::server::config']
}

And the nodes.pp looks like this:

class role_monitoring_server {
  $my_role = 'monitoring_server'
  ...
  include sensu::server
}

node my_cool_server {
  include role_monitoring_server
}

As most of you might have guessed, I have trouble with the class dependency in server.pp:

Class['sensu::common'] -> Class['sensu::server::config']

just does not work. The class sensu::server::config needs to place a file in a directory, that will only be created by sensu::common. The thing is, that sensu::server::config will always be applied before sensu::commonand not after as expected.

What do I miss? There are so many questions out there on the web but I just don't find an answer, since I don't know what to look for.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You're creating a dependency relationship with the sensu::common class, but there's no implicit dependency relationship between sensu::common and its "children", package and config. So, unless your config looks otherwise (I'm assuming the sensu::common class is just a couple include lines?) those are still free to be applied at any time in relation to the sensu::server::config class.

You'll probably want to build the relationship with the class that contains the resources that you need; you're effectively creating a require relationship each resource in one class to each resource in the other (whichever one of these is needed, or both):

Class['sensu::common::package'] -> Class['sensu::server::config']
Class['sensu::common::config'] -> Class['sensu::server::config']
share|improve this answer
    
Thanks a lot, Shane! You solution works and the resources get applied in the right order. –  Tobias Sep 6 '12 at 8:43
    
Apart from the includes in common.pp, I have the following relationship Class['sensu::common::package'] -> Class['sensu::common::config']. So, I thought that this would ensure somehow the resources defined in them will get applied first. Where is the problem in my thinking? –  Tobias Sep 6 '12 at 8:49
    
@Tobias That builds the relationship between those two, but the common class itself still isn't actually involved in the dependency chain. –  Shane Madden Sep 6 '12 at 15:14
    
Thanks, now I got it. Just out of curiosity: What if I write Class['sensu::common::package'] -> Class['sensu::common::config'] -> Class[sensu::common]. Does that make sense? At least it won't work. Just have tried it. Got the error message, that sensu::common can't be found ... Anyways, will stick to your solution and thanks a lot again! –  Tobias Sep 6 '12 at 15:35

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.