From: Peter Amstutz Date: Sun, 26 Jun 2022 22:42:03 +0000 (-0400) Subject: 18870: New script to help manage install X-Git-Tag: 2.5.0~127^2~28 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/722fbc71928e7fc6b91eb101788b51c2bb9577eb?ds=inline 18870: New script to help manage install Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- diff --git a/tools/salt-install/installer.sh b/tools/salt-install/installer.sh new file mode 100755 index 0000000000..7bd789f689 --- /dev/null +++ b/tools/salt-install/installer.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: CC-BY-SA-3.0 + +set -e + +subcmd="$1" +if test -n "$subcmd" ; then + shift +fi +case "$subcmd" in + initialize) + if ! test -f provision.sh ; then + echo "Must be run from arvados/tools/salt-install" + exit + fi + + SETUPDIR=$1 + PARAMS=$2 + SLS=$3 + + err= + if test -z "$PARAMS" -o ! -f local.params.example.$PARAMS ; then + echo "Not found: local.params.example.$PARAMS" + echo "Expected one of multiple_hosts, single_host_multiple_hostnames, single_host_single_hostname" + err=1 + fi + + if test -z "$SLS" -o ! -d config_examples/$SLS ; then + echo "Not found: config_examples/$SLS" + echo "Expected one of multi_host/aws, single_host/multiple_hostnames, single_host/single_hostname" + err=1 + fi + + if test -z "$SETUPDIR" -o -z "$PARAMS" -o -z "$SLS" ; then + echo "installer.sh " + err=1 + fi + + if test -n "$err" ; then + exit 1 + fi + + echo "Initializing $SETUPDIR" + git init $SETUPDIR + cp -r *.sh tests $SETUPDIR + + cp local.params.example.$PARAMS $SETUPDIR/local.params + cp -r config_examples/$SLS $SETUPDIR/local_config_dir + + cd $SETUPDIR + git add *.sh local.params local_config_dir tests + git commit -m"initial commit" + + echo "setup directory initialized, now go to $SETUPDIR, edit 'local.params' and 'local_config_dir' as needed, then run 'installer.sh deploy'" + ;; + deploy) + CONFIG_FILE=local.params + if ! test -s $CONFIG_FILE ; then + echo "Must be run from arvados-setup, maybe you need to 'initialize' first?" + fi + + source ${CONFIG_FILE} + + git commit -m"prepare for deploy" + for NODE in "${!NODES[@]}" + do + if ! ssh $NODE test -d arvados-setup.git ; then + ssh $NODE git init --bare arvados-setup.git + git add remote $NODE $DEPLOY_USER@$NODE:arvados-setup.git + git push $NODE + ssh $NODE git clone arvados-setup.git arvados-setup + fi + + git push $NODE master + ssh $NODE git -C arvados-setup pull + + ssh $DEPLOY_USER@$NODE "cd arvados-setup && sudo ./provision.sh --config local.params --roles ${NODES[$NODE]}" + done + ;; + *) + echo "Arvados installer" + echo "" + echo "initialize initialize the setup directory for configuration" + echo "deploy deploy the configuration from the setup directory" + ;; +esac