wilas / vbkick

Tool for building and maintaining VirtualBox VMs described as a code in a single definition file.
Other
8 stars 5 forks source link

vbkick should fail when postinstall/update/validate command fail #28

Closed wilas closed 10 years ago

wilas commented 10 years ago

Right now expect always return true, even when spawned command fail. Same with ssh command in postinstall/update/validate (all of them use ssh_exec function) which was combined with || true to always return true.

This behaviour is stupid and dangerous ("mea culpa"), because after fail next commands are executed and we lost control and information about what exactly was wrong with our scripts (It make debugging process difficult). The build box process must be predictable and repeatable, that mean I will be alarm when one of my postinstall scripts fail and the job won't be continued.

If I expect that given command/script/scripts should fail and I'm happy with this, e.g. validate scripts which inform me what more should be done on my box, then inside that script I use || true and I have full control on return status. Example:

this pass: postinstall_launch=( "false || true" "echo 'hello'") 
this fail: postinstall_launch=("false" "echo 'hello'")

After fix you can safely use vbkick as a test to your bootstrapping scripts (kickstart files, etc.).

wilas commented 10 years ago

Good practice: inside your bash postinstall scripts use set -eEu - It will immediately stop your script if any command fails.