Merge branch '21020-pysdk-env-paths'
[arvados.git] / tools / salt-install / installer.sh
index bb57666da6c02eaf1fece49dd90c41b1a3cc06c4..36e87cca91f1e774cc20193409815cc58f5f4c9a 100755 (executable)
@@ -103,8 +103,15 @@ sync() {
     # from that.
 
     $SSH $DEPLOY_USER@$NODE git init --bare --shared=0600 ${GITTARGET}.git
-    $GIT push $NODE $BRANCH
-    $SSH $DEPLOY_USER@$NODE "umask 0077 && git clone -s ${GITTARGET}.git ${GITTARGET} && git -C ${GITTARGET} checkout ${BRANCH}"
+    if [[ "$BRANCH" == "HEAD" ]]; then
+      # When deploying from an individual commit instead of a branch. This can
+      # happen when deploying from a Jenkins pipeline.
+      $GIT push $NODE HEAD:refs/heads/HEAD
+      $SSH $DEPLOY_USER@$NODE "umask 0077 && git clone -s ${GITTARGET}.git ${GITTARGET} && git -C ${GITTARGET} checkout remotes/origin/HEAD"
+    else
+      $GIT push $NODE $BRANCH
+      $SSH $DEPLOY_USER@$NODE "umask 0077 && git clone -s ${GITTARGET}.git ${GITTARGET} && git -C ${GITTARGET} checkout ${BRANCH}"
+    fi
   fi
 }
 
@@ -274,7 +281,7 @@ terraform-destroy)
   ;;
 
 generate-tokens)
-  for i in BLOB_SIGNING_KEY MANAGEMENT_TOKEN SYSTEM_ROOT_TOKEN ANONYMOUS_USER_TOKEN WORKBENCH_SECRET_KEY DATABASE_PASSWORD; do
+  for i in BLOB_SIGNING_KEY MANAGEMENT_TOKEN SYSTEM_ROOT_TOKEN ANONYMOUS_USER_TOKEN DATABASE_PASSWORD; do
     echo ${i}=$(
       tr -dc A-Za-z0-9 </dev/urandom | head -c 32
       echo ''
@@ -442,14 +449,38 @@ diagnostics)
   arvados-client diagnostics $LOCATION
   ;;
 
+diagnostics-internal)
+  loadconfig
+  set -u
+
+  if [ -z "${ROLE2NODES['shell']:-}" ]; then
+    echo "No node with 'shell' role was found, cannot run diagnostics-internal"
+    exit 1
+  fi
+
+  # Pick the first shell node for test running
+  declare TESTNODE=$(echo ${ROLE2NODES['shell']} | cut -d\, -f1)
+  declare SSH=$(ssh_cmd "$TESTNODE")
+
+  # Run diagnostics
+  echo "Running diagnostics in $TESTNODE..."
+  $SSH $DEPLOY_USER@$TESTNODE bash <<EOF
+  export ARVADOS_API_HOST="${DOMAIN}:${CONTROLLER_EXT_SSL_PORT}"
+  export ARVADOS_API_TOKEN="$SYSTEM_ROOT_TOKEN"
+  sudo --preserve-env=ARVADOS_API_HOST,ARVADOS_API_TOKEN arvados-client diagnostics -internal-client
+EOF
+
+  ;;
+
 *)
   echo "Arvados installer"
   echo ""
-  echo "initialize        initialize the setup directory for configuration"
-  echo "terraform         create cloud resources using terraform"
-  echo "terraform-destroy destroy cloud resources created by terraform"
-  echo "generate-tokens   generate random values for tokens"
-  echo "deploy            deploy the configuration from the setup directory"
-  echo "diagnostics       check your install using diagnostics"
+  echo "initialize             initialize the setup directory for configuration"
+  echo "terraform              create cloud resources using terraform"
+  echo "terraform-destroy      destroy cloud resources created by terraform"
+  echo "generate-tokens        generate random values for tokens"
+  echo "deploy                 deploy the configuration from the setup directory"
+  echo "diagnostics            check your install running diagnostics locally"
+  echo "diagnostics-internal   check your install running diagnostics on a shell node"
   ;;
 esac