puppetlabs/puppet — pull request #1541 by lkundrak (2013-03-21 16:35:40+00:00)
Title: (#19805) Report failures to restart in exit code if requested

Documentation to --detailed-exitcodes states that mask 0x4 is applied in case
"there were failures during the transaction." Currently only failures to change
resource state are reported, failures to restart the resource are still ignored.

Only change (code=2) to Exec['/bin/true'] is considered here:

$ puppet apply --detailed-exitcodes -e 'service { "duckfaced": restart => "/bin/false", ensure => running, status => "/bin/true" } exec { "/bin/true": notify => Service["duckfaced"] }'
$ echo $?
2

Needless to say, information about failed restarts is usually as important to
the user as the status changes, since they usually mean that desired
configuration is not in effect.

This change makes Puppet consider information about failed restarts when
setting the failure bit.

Another possibility to avoid loosing the information would be to introduce
another bit in the exit code mask, but that would change semantics with respect
to existing documentation and thus probably be more confusing.