Ask Your Question

Force Run stop when exec fails

asked 2014-02-03 07:00:02 -0500

onitlikesonic gravatar image

I have an exec that should be ran before anything else, in my case an "apt-get update" that should be run before any Package install... I am achieving this with a "Class['apt_get'] -> Package <| |>"

However if that exec fails the puppet execution should terminate...

How can i force the whole puppet run to fail if that command fails? Puppet still runs other execs etc... since i'm only restricting it to run before Package installs....

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-02-03 07:48:04 -0500

doc75 gravatar image

For this kind of specific case you can use Stage:

stage { 'init':
   before => Stage['main'],

class { 'apt-get':
      stage => first,

You just need to create a class containing only the exec executing the apt-get update.

class apt-get {
  exec { ... }

You can specify stage only for classes.

edit flag offensive delete link more


I have been discouraged to use Stages previously by the #puppet users/probably admins also @_rc if i remember it correctly

onitlikesonic gravatar imageonitlikesonic ( 2014-02-03 07:59:53 -0500 )edit

You are totally right, but this is the kind of simple pattern where this is not an issue: cf.

doc75 gravatar imagedoc75 ( 2014-02-03 09:02:55 -0500 )edit

answered 2014-02-03 14:47:11 -0500

lavaman gravatar image

While that is possible to achieve, I would wonder why you would want that. The idempotent nature of puppet means that it will and should attempt to configure whatever it can. If you have issues with execs and things failing because packages aren't installed, you should resolve those dependencies in your code rather than trying to fail out.

edit flag offensive delete link more


You mention it is possible to achieve... How ?

onitlikesonic gravatar imageonitlikesonic ( 2014-02-05 07:01:23 -0500 )edit

Place it in a run stage that runs before main, like the below answer suggests.

lavaman gravatar imagelavaman ( 2014-03-12 19:01:37 -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

1 follower


Asked: 2014-02-03 07:00:02 -0500

Seen: 740 times

Last updated: Feb 03 '14