diff --git a/bin/deploy-on b/bin/deploy-on index cbf5d4a..b59772b 100755 --- a/bin/deploy-on +++ b/bin/deploy-on @@ -1,49 +1,68 @@ #!/bin/bash set -e # 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" + echo " bin/deploy-on --no-master worker02" + exit 1 +} + DOMAIN="internal.softwareheritage.org" MASTER="pergamon.${DOMAIN}" -ssh="ssh -t" +SSH="ssh -t" + +# command line parsing + +deploy_on_master="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 - echo "Usage: bin/deploy-on HOST" - echo "E.g.: bin/deploy-on worker01" - exit 1 + die_usage fi host="$1" shift -info "deploying recipes on ${MASTER}..." -$ssh "$MASTER" "sudo /usr/local/sbin/swh-puppet-master-deploy" -info "master ok." +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 info "starting test run on ${host}..." -$ssh "$host" "sudo /usr/local/sbin/swh-puppet-test" +$SSH "$host" "sudo /usr/local/sbin/swh-puppet-test" info "test run ok." while true ; do prompt "does the above diff look good? [y/n] " read yn case $yn in [yY] ) break ;; [nN] ) info "deployment aborted, as requested." exit 2 ;; * ) continue ;; esac done info "deploying on ${host}..." -$ssh "$host" "sudo /usr/local/sbin/swh-puppet-apply" +$SSH "$host" "sudo /usr/local/sbin/swh-puppet-apply" info "deployment ok. Bye."