Ask Your Question

Stop execution if dependency fails

asked 2015-05-21 18:37:07 -0500

R gravatar image

updated 2015-05-21 22:15:43 -0500

My Puppet Module has the following structure, under manifests I have four files init.pp, prerequisites.pp, install.pp and postinstall.pp.

init.pp calls the files in the following order: include prerequistes.pp include install.pp include postinstall.pp

Now if prerequistes.pp or install.pp fails postinstall.pp shouldn't get executed. If all of this is in the same .pp file we can use this operator "-> " to tie them together. How do we build the dependencies between the classes. Please let me know.

Thanks a lot in advance.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-05-22 01:10:07 -0500

GregLarkin gravatar image

You'll want to do something like this:

class demo {
  contain demo::prerequisites
  contain demo::install
  contain demo::postinstall

  Class['demo::prerequisites'] -> Class['demo::install'] -> Class['demo::postinstall']

The contain keyword ensures that the resources and classes included in each of the demo:: classes are ordered correctly with your dependency arrows. Because of the dependencies, if any resource in any class fails, the subsequent classes in the chain (and their contained resources) will fail to be applied.

Here is some additional information about containment in Puppet:

edit flag offensive delete link more


Thank you Greg, let me try that.

R gravatar imageR ( 2015-05-22 16:31:31 -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


Asked: 2015-05-21 18:37:07 -0500

Seen: 176 times

Last updated: May 22 '15