FAQ

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.

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
grouppuppet-users @
categoriespuppet
postedJun 4, '13 at 4:06p
activeJun 5, '13 at 1:05p
posts2
users2
websitepuppetlabs.com

2 users in discussion

Xin zhang: 1 post Jcbollinger: 1 post

People

Translate

site design / logo © 2022 Grokbase