Allows deployment scripts to be interactive

Previously, because we were piping the compiled script blob over ssh to
decompress over there without creating an intermediated bundled file, we
were allocating the stdin of the ssh session to have the read from the
pipe.

This blocked the allocation of the /dev/tty over the session and
prevented users to interact with the script. We would like some of the
interactions to work, like prompting for a confirmation or typing a
password.

To fix this, the deployment process was split in two steps. The first
step still receives the bundled file over a pipe, decompresses it on a
temprary folder, and outputs the location of the deployment folder.

We grab this output to feed on the second step, which has a script to go
to the deployment folder and start the execution.

Now, roles can make use of read, as well as sudo with password.
This commit is contained in:
Bruno Tavares 2015-09-26 22:30:55 -03:00
parent aafa6df1b7
commit 41cf8f98bf

View File

@ -9,20 +9,30 @@ shift
[ "$DEBUG" ] && debug="-x" [ "$DEBUG" ] && debug="-x"
remote_command=$( kickstart compile "$@"
copy_command=$(
cat <<CMD cat <<CMD
{ {
deploy_folder=\$(mktemp -d -t kickstart.XXXXX) deploy_folder=\$(mktemp -d -t kickstart.XXXXX)
mkdir -p "\$deploy_folder" mkdir -p "\$deploy_folder"
cd "\$deploy_folder" cd "\$deploy_folder"
tar xz tar xz
echo "\$deploy_folder"
}
CMD
)
deploy_folder=$(tar chz -C compile . | ssh $target "bash -c '$copy_command'")
execute_command=$(
cat <<CMD
{
cd $deploy_folder
exit_status=0 exit_status=0
$prefix bash $debug install.sh || exit_status=\$? $prefix bash $debug install.sh || exit_status=\$?
rm -rf "\$deploy_folder" rm -rf "$deploy_folder"
exit \$exit_status exit \$exit_status
} }
CMD CMD
) )
ssh $target "bash -c '$execute_command'"
kickstart compile "$@"
tar chz -C compile . | ssh $target "bash -c '$remote_command'"