Puppet: create service before file but notify service if file changes

dependenciespuppet

I want file "run" to be created AFTER Service nginx, but also i want to notify Service nginx if file run changes. Notify implies that it is run BEFORE nginx.

The use case is the following. We use dj bernsteins daemontools for managing nginx. Since we need to do some steps (creating /etc/service, adding the run files.. ) we build a defined type which does these things. Now we dont want our nginx module to have any connection to the daemontools module, thats why we dont want to subscribe to a daemontools file. Also subscribe would turn around the dependency cycle. Im searching for something like, only run module when module nginx is completely finished.

class { daemontools:
  file {'run':
    require => Service[nginx],
    notify => Service[nginx];  # <<< this wont do :(
  }
}

class { nginx: 
  service { 'nginx': }
}    

Any ideas?

Thomas

Best Answer

You could try using using stages if your use case can handle its limitations.

stage { 'first':
  before => Stage['main'],
}
stage { 'last': }
Stage['main'] -> Stage['last']

class { daemontools:
  stage => last;
  file {'run':
    require => Service[nginx],
    notify  => Service[nginx];
  }
}

class { nginx: 
  stage => last;
  service { 'nginx': }
}
Related Topic