diff --git a/bin/deploy-on b/bin/deploy-on index 8917d3a..fe8e636 100755 --- a/bin/deploy-on +++ b/bin/deploy-on @@ -1,75 +1,81 @@ #!/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" +apt_update="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 [ "$apt_update" = "yes" ] ; then + info "apt-get update on ${host}..." + $SSH "$host" "sudo apt-get update -qq" + fi + 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/q] " read yn case $yn in [yY] ) info "deploying on ${host}..." $SSH "$host" "sudo /usr/local/sbin/swh-puppet-apply" info "deployment ok. Bye." break ;; [nN] ) info "skipping deployment on ${host}, as requested." break ;; [qQ] ) info "aborting deployment. Bye." exit 2 ;; * ) continue ;; esac done done