xin zhang
2013-Jun-04 16:06 UTC
[Puppet Users] exec failure doesn''t abort whole puppet transaction
I have my puppet defined as (pseudo code) class A { exec { somethingA: } } class B { exec { somethinB: } } Class[''A''] -> Class[''B''] the exec{ somethingA: } is actually failed on my setup, I was expecting the whole puppet transaction would fail. To my surprise, class B still got executed, and puppet agent returned with code 2 which means there were some changes but whole transaction was success. Puppet agent did output error message of exec{ somethingA: } on stderr. My application relays on return code, how can I make puppet abort when some exec fail? and return error code like 6? -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
jcbollinger
2013-Jun-05 13:05 UTC
[Puppet Users] Re: exec failure doesn''t abort whole puppet transaction
On Tuesday, June 4, 2013 11:06:53 AM UTC-5, xin zhang wrote:> > I have my puppet defined as (pseudo code) > > class A { > exec { somethingA: > } > } > > class B { > exec { somethinB: > } > } > > Class[''A''] -> Class[''B''] > > the exec{ somethingA: } is actually failed on my setup, I was expecting > the whole puppet transaction would fail. To my surprise, class B still got > executed, and puppet agent returned with code 2 which means there were some > changes but whole transaction was success. Puppet agent did output error > message of exec{ somethingA: } on stderr. >Are you certain that the Exec''s command is in fact delivering an exit code different from the expected success code (default 0)? Consider, for instance, that a script or program can encounter errors, write diagnostics to stderr, and still exit 0. Puppet cares only about the exit code for determining whether the Exec succeeds or fails. If you run the agent with the --debug option, then it should provide a lot of information about what''s happening, and in particular, it should indicate whether the Exec succeeds or fails. Generally speaking, Puppet proceeds despite failures, applying all the resources it successfully can do. It should not and normally does not apply a resource that depends on one that has failed, however. If indeed Exec[''somethingA''] is failing, therefore, it must not be causing Class[''A''] to fail. That would be contrary to your expectation, but not necessarily wrong (yet not clearly right, either; I''d have to check what the behavior is supposed to be). In that case, you should be able to ensure that Class[''B''] is not applied when the Exec fails by declaring a relationship directly with the Exec. For example, declare the Exec this way: exec { ''somethingA'': ... before => Class[''B''] }> My application relays on return code, how can I make puppet abort when > some exec fail? and return error code like 6? > >Are you running the agent with the --detailed-exitcodes option? If so, and if the Exec really is failing, then it looks like you have hit a bug. In that case file a ticket. If you wish, you can also troubleshoot it yourself, since Puppet is open-source. If you manage to fix the problem then you have the option of contributing your solution to the project. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.