19215: Uses controller's port when running diagnostics
[arvados.git] / tools / salt-install / installer.sh
index e5ff7be4e7a95f621932ab542a675afd253aa6ce..d734767d8376dd3a7d1f63e7a8c6927f81ae1b7b 100755 (executable)
@@ -42,6 +42,19 @@ declare DEPLOY_USER
 # This will be populated by loadconfig()
 declare GITTARGET
 
+checktools() {
+    local MISSING=''
+    for a in git ip ; do
+       if ! which $a ; then
+           MISSING="$MISSING $a"
+       fi
+    done
+    if [[ -n "$MISSING" ]] ; then
+       echo "Some tools are missing, please make sure you have the 'git' and 'iproute2' packages installed"
+       exit 1
+    fi
+}
+
 sync() {
     local NODE=$1
     local BRANCH=$2
@@ -86,14 +99,21 @@ deploynode() {
     # the appropriate roles.
 
     if [[ -z "$ROLES" ]] ; then
-       echo "No roles declared for '$NODE' in ${CONFIG_FILE}"
-       exit 1
+       echo "No roles specified for $NODE, will deploy all roles"
+    else
+       ROLES="--roles ${ROLES}"
     fi
 
+    logfile=deploy-${NODE}-$(date -Iseconds).log
+
     if [[ "$NODE" = localhost ]] ; then
-       sudo ./provision.sh --config ${CONFIG_FILE} --roles ${ROLES}
+       SUDO=''
+       if [[ $(whoami) != 'root' ]] ; then
+           SUDO=sudo
+       fi
+       $SUDO ./provision.sh --config ${CONFIG_FILE} ${ROLES} 2>&1 | tee $logfile
     else
-       ssh $DEPLOY_USER@$NODE "cd ${GITTARGET} && sudo ./provision.sh --config ${CONFIG_FILE} --roles ${ROLES}"
+       ssh $DEPLOY_USER@$NODE "cd ${GITTARGET} && sudo ./provision.sh --config ${CONFIG_FILE} ${ROLES}" 2>&1 | tee $logfile
     fi
 }
 
@@ -105,7 +125,10 @@ loadconfig() {
     GITTARGET=arvados-deploy-config-${CLUSTER}
 }
 
+set +u
 subcmd="$1"
+set -u
+
 if [[ -n "$subcmd" ]] ; then
     shift
 fi
@@ -116,6 +139,8 @@ case "$subcmd" in
            exit
        fi
 
+       checktools
+
        set +u
        SETUPDIR=$1
        PARAMS=$2
@@ -152,7 +177,9 @@ case "$subcmd" in
        cp -r config_examples/$SLS $SETUPDIR/${CONFIG_DIR}
 
        cd $SETUPDIR
-       git add *.sh ${CONFIG_FILE} ${CONFIG_DIR} tests
+       echo '*.log' > .gitignore
+
+       git add *.sh ${CONFIG_FILE} ${CONFIG_DIR} tests .gitignore
        git commit -m"initial commit"
 
        echo "setup directory initialized, now go to $SETUPDIR, edit '${CONFIG_FILE}' and '${CONFIG_DIR}' as needed, then run 'installer.sh deploy'"
@@ -162,6 +189,8 @@ case "$subcmd" in
        NODE=$1
        set -u
 
+       checktools
+
        loadconfig
 
        if grep -rni 'fixme' ${CONFIG_FILE} ${CONFIG_DIR} ; then
@@ -192,7 +221,7 @@ case "$subcmd" in
            do
                # Do 'database' role first,
                if [[ "${NODES[$NODE]}" =~ database ]] ; then
-                   deploynode $NODE ${NODES[$NODE]}
+                   deploynode $NODE "${NODES[$NODE]}"
                    unset NODES[$NODE]
                fi
            done
@@ -201,7 +230,7 @@ case "$subcmd" in
            do
                # then  'api' or 'controller' roles
                if [[ "${NODES[$NODE]}" =~ (api|controller) ]] ; then
-                   deploynode $NODE ${NODES[$NODE]}
+                   deploynode $NODE "${NODES[$NODE]}"
                    unset NODES[$NODE]
                fi
            done
@@ -210,14 +239,15 @@ case "$subcmd" in
            do
                # Everything else (we removed the nodes that we
                # already deployed from the list)
-               deploynode $NODE ${NODES[$NODE]}
+               deploynode $NODE "${NODES[$NODE]}"
            done
        else
            # Just deploy the node that was supplied on the command line.
            sync $NODE $BRANCH
-           deploynode $NODE
+           deploynode $NODE ""
        fi
 
+       set +x
        echo
        echo "Completed deploy, run 'installer.sh diagnostics' to verify the install"
 
@@ -242,7 +272,7 @@ case "$subcmd" in
            exit 1
        fi
 
-       export ARVADOS_API_HOST="${CLUSTER}.${DOMAIN}"
+       export ARVADOS_API_HOST="${CLUSTER}.${DOMAIN}:${CONTROLLER_EXT_SSL_PORT}"
        export ARVADOS_API_TOKEN="$SYSTEM_ROOT_TOKEN"
 
        arvados-client diagnostics $LOCATION