Ask Your Question

how to set priority of instances in define type

asked 2013-04-03 18:51:13 -0500

redmine gravatar image

updated 2013-04-03 18:52:28 -0500

I have this kind of define code: example :
define { Exec {" command1":
some dependecy
Exec {" command2":
some other dependency
Exec {" command3":
some dependency
Exec {" command4":
some other dependency
Exec {" command5":
file { "myfile":

My goal is to run file resource at last, after checking or executing all other Exec resourses. I want to set the priority like this - for example : Exec(command2) should run after Exec(command1), without caring if Exec(command1) failed or worked . likewise command3 should execute only after executing command 2 , inspite of command2 fails or works. I tried to use require ., ifonly and before but it gives error ... (more)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-04-03 20:26:47 -0500

lavaman gravatar image

Then you want a script, not puppet. Then entire point of puppet is to enforce a state and dependencies between resources. It was specifically written to not do what you're asking since that's mostly how scripting has worked since the beginning of unix.

Just write a script, push it with file, and exec it.

edit flag offensive delete link more


I agree. Long-term management of the process is much easier if you contain your logic within a script, and code Puppet to enforce that your script be executed on every run.

Ancillas gravatar imageAncillas ( 2013-04-04 13:42:41 -0500 )edit

answered 2013-04-04 01:48:41 -0500

jonn gravatar image

The exec resource type supports a "returns" parameter which specifies the return codes that will be treated as successful. For example, /bin/false returns 1 so puppet flags an error here:

$ puppet apply -e ' exec { "/bin/false": } '
err: /Stage[main]//Exec[/bin/false]/returns: change from notrun to 0 failed: /bin/false returned 1 instead of one of [0] at line 1
notice: Finished catalog run in 0.09 seconds

We can allow the exec to succeed by providing a "returns" parameter which states that a return code of 1 is OK. This parameter can be an array:

$ puppet apply ...
edit flag offensive delete link more

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: 2013-04-03 18:51:13 -0500

Seen: 446 times

Last updated: Apr 04 '13