Error: /bin/ls /doesnotexit returned 1 instead of one of [0]
Error: /Stage[main]//Exec[test]/returns: change from notrun to 0 failed: /bin/ls /doesnotexit returned 1 instead of one of [0]
However,
does not fail, because the last command did not return an error!
that's a problem, because there are many puppet modules which concatenate several commands in one puppet exec, and they do not explicitly handle the errors.
(inserting "set -e" at the head of the command line does not work, as it is bash script specific)
I think that, by default, the puppet exec resource should fail if any of the "single commands" fail (as in the second example).
and if it is not by default, at least there should be an option in puppet exec to do so (equivalent to "set -e" in bash)
(tested on puppet 3.3.2)
When you use concatenated commands any shell will only return the last command return code by design, and this is what puppet receives. So its a ' works at a expected'
If you need to control each of the return codes just use different exec resources
Regards,
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/fc8a32ca-1e7b-4376-ace7-a1c36dd665c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
> If you need to control each of the return codes just use different exec resources
> If "you",
the problem is that there are many puppet modules which use concatenated commands, without realising about this problem.
to be safe, I am suggesting that puppet should enable that behavior by default.
> need to control each of the return codes
i don't suggest executing every concatenated command and control each return control.
i am suggesting failing as soon as a concatenated command fails. (as in bash set -e)
in bash, for example, if you type "set -e" first, bash will stop and fail as soon as a concatenated command fails.(i agree that this behaviour is unfortunatelly not enabled by default in bash scripts)
exec {'test':
command => "/bin/ls /doesnotexit; /bin/echo hello",}
Regards,
David
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/05d8ba97-4c12-414b-a821-f9276b9e6a1d%40googlegroups.com.
+1
Moroever the ser -e its just for bash, and bash is not installed by default in most Unixes.
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/531EDEF1.9020508%40alumni.tu-berlin.de.
Changing the behavior of the shell to help people who write faulty shell
one-liners seems like a Bad Idea to me. Tools shouldn't enable and
encourage bad practices.
My bad, tried it incorrectly :s
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/lfsgen%24q2j%241%40ger.gmane.org.