The command I run is:
/usr/bin/puppet agent --onetime --verbose --ignorecache --no-daemonize --no-usecacheonfailure --color=false --detailed-exitcodes
One of my execs executes a shell script which is returning a non-zero error code. The verbose output shows this:
err: /Stage[main]/Etp::Install/Etp::Deploy[discovery]/Exec[migrate-discovery-db]: Failed to call refresh: /usr/local/etp/bin/migrate_db.sh /home/etpdiscovery/conf /home/etpdiscovery/db /home/etpdiscovery/datagen disco.master.ben.xml returned 21 instead of one of [0] at /home/configmgr/puppet-trunk/etouchpoint-systems/src/main/puppet/modules/etp/manifests/deploy.pp:561
Because a lot of changes are being made when this error happens, I expect to see an exit code of ‘6’ but I get a ‘2’ every time. Even if no changes are made and this exec fails, I expect to see a ‘4’.
You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://projects.puppetlabs.com/my/account
Eric could you please provide a small, reproducible test case? I was unable to repro:
[er...@glitch.local ~/Sandbox/puppet-undef/manifests]% puppet apply --detailed-exitcodes --verbose -e 'exec { "/usr/local/bin/foooo": }' Info: Applying configuration version '1345673176' Error: Could not find command '/usr/local/bin/foooo' Error: /Stage[main]//Exec[/usr/local/bin/foooo]/returns: change from notrun to 0 failed: Could not find command '/usr/local/bin/foooo' Finished catalog run in 0.02 seconds [er...@glitch.local ~/Sandbox/puppet-undef/manifests]% echo $? 4 [er...@glitch.local ~/Sandbox/puppet-undef/manifests]% puppet apply --detailed-exitcodes --verbose -e 'exec { "/usr/local/bin/foooo": } file { "/Users/eric/wth": ensure => present }' Info: Applying configuration version '1345673460' /Stage[main]//File[/Users/eric/wth]/ensure: created Error: Could not find command '/usr/local/bin/foooo' Error: /Stage[main]//Exec[/usr/local/bin/foooo]/returns: change from notrun to 0 failed: Could not find command '/usr/local/bin/foooo' Finished catalog run in 0.03 seconds [er...@glitch.local ~/Sandbox/puppet-undef/manifests]% echo $? 6
Are you really on 2.6.4? The above was on a git checkout of our 2.6.x branch which has advanced a bit since 2.6.4 but not sure if this is implicated.
Eric S: I got bitten by this one this weekend as well. I can repro it in 2.7.x and 3.0.1. It’s causing me problems trying to write a custom type/provider, but you can repro it with built-in types using a manifest like this one:
notify { "hi": }
exec { "/bin/foo":
refreshonly => true,
subscribe => Notify["hi"],
}
Then run that with puppet apply --detailed-exitcodes
:
$ puppet apply --detailed-exitcodes ./foo2.pp
No LSB modules are available.
No LSB modules are available.
hi
/Stage[main]//Notify[hi]/message: defined 'message' as 'hi'
Error: /Stage[main]//Exec[/bin/foo]: Failed to call refresh: Could not find command '/bin/foo'
Error: /Stage[main]//Exec[/bin/foo]: Could not find command '/bin/foo'
Finished catalog run in 0.15 seconds
$ echo $?
2
$
It definitely seems like the exit code there should be ‘4’ or ‘6’.