diff --git a/bin/deploy-on b/bin/deploy-on index d768199..8917d3a 100755 --- a/bin/deploy-on +++ b/bin/deploy-on @@ -1,72 +1,75 @@ #!/bin/bash # trigger a puppet deployment on a given SWH machine # see https://intranet.softwareheritage.org/index.php?title=Puppet_setup info () { echo "*** swh-deploy: $1" } prompt () { echo -n "*** swh-deploy: $1" } die_usage () { echo "Usage: bin/deploy-on [OPTION] HOST..." echo "E.g.: bin/deploy-on worker01 worker03" echo " bin/deploy-on --no-master worker02" exit 1 } DOMAIN="internal.softwareheritage.org" MASTER="pergamon.${DOMAIN}" SSH="ssh -t" # command line parsing deploy_on_master="yes" test_run="yes" if [ "$1" = "-h" -o "$1" = "--help" ] ; then die_usage fi if [ "$1" = "--no-master" ] ; then deploy_on_master="no" shift fi if [ -z "$1" ] ; then die_usage fi if [ "$deploy_on_master" = "yes" ] ; then info "deploying recipes on ${MASTER}..." $SSH "$MASTER" "sudo /usr/local/sbin/swh-puppet-master-deploy" info "master ok." fi for host in "$@" ; do if [ "$test_run" = "yes" ] ; then info "starting test run on ${host}..." $SSH "$host" "sudo /usr/local/sbin/swh-puppet-test" info "test run ok." fi while true ; do - prompt "does the above diff for ${host} look good? [y/n] " + prompt "does the above diff for ${host} look good? [y/n/q] " read yn case $yn in - [yY] ) break ;; + [yY] ) + info "deploying on ${host}..." + $SSH "$host" "sudo /usr/local/sbin/swh-puppet-apply" + info "deployment ok. Bye." + break ;; [nN] ) - info "deployment aborted, as requested." + info "skipping deployment on ${host}, as requested." + break ;; + [qQ] ) + info "aborting deployment. Bye." exit 2 ;; * ) continue ;; esac done - info "deploying on ${host}..." - $SSH "$host" "sudo /usr/local/sbin/swh-puppet-apply" - info "deployment ok. Bye." - done