3 # Copyright (C) The Arvados Authors. All rights reserved.
5 # SPDX-License-Identifier: CC-BY-SA-3.0
7 # If you want to test arvados in a single host, you can run this script, which
8 # will install it using salt masterless
9 # This script is run by the Vagrant file when you run it with
16 # capture the directory that the script is running from
17 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
21 echo >&2 "Usage: ${0} [-h] [-h]"
23 echo >&2 "${0} options:"
24 echo >&2 " -d, --debug Run salt installation in debug mode"
25 echo >&2 " -c <local.params>, --config <local.params> Path to the local.params config file"
26 echo >&2 " -t, --test Test installation running a CWL workflow"
27 echo >&2 " -r, --roles List of Arvados roles to apply to the host, comma separated"
28 echo >&2 " Possible values are:"
30 echo >&2 " controller"
31 echo >&2 " dispatcher"
33 echo >&2 " keepbalance"
36 echo >&2 " monitoring"
41 echo >&2 " workbench2"
42 echo >&2 " Defaults to applying them all"
43 echo >&2 " -h, --help Display this help and exit"
44 echo >&2 " --dump-config <dest_dir> Dumps the pillars and states to a directory"
45 echo >&2 " This parameter does not perform any installation at all. It's"
46 echo >&2 " intended to give you a parsed set of configuration files so"
47 echo >&2 " you can inspect them or use them in you Saltstack infrastructure."
49 echo >&2 " - parses the pillar and states templates,"
50 echo >&2 " - downloads the helper formulas with their desired versions,"
51 echo >&2 " - prepares the 'top.sls' files both for pillars and states"
52 echo >&2 " for the selected role(s)"
53 echo >&2 " - writes the resulting files into <dest_dir>"
54 echo >&2 " -v, --vagrant Run in vagrant and use the /vagrant shared dir"
55 echo >&2 " --development Run in dev mode, using snakeoil certs"
60 # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
61 if ! which getopt > /dev/null; then
62 echo >&2 "GNU getopt is required to run this script. Please install it and re-reun it"
66 TEMP=$(getopt -o c:dhp:r:tv \
67 --long config:,debug,development,dump-config:,help,roles:,test,vagrant \
71 then echo "Please check the parameters you entered and re-run again"
74 # Note the quotes around `$TEMP': they are essential!
77 while [ ${#} -ge 1 ]; do
89 if [[ ${2} = /* ]]; then
90 DUMP_SALT_CONFIG_DIR=${2}
92 DUMP_SALT_CONFIG_DIR=${PWD}/${2}
95 S_DIR="${DUMP_SALT_CONFIG_DIR}/salt"
97 F_DIR="${DUMP_SALT_CONFIG_DIR}/formulas"
99 P_DIR="${DUMP_SALT_CONFIG_DIR}/pillars"
101 T_DIR="${DUMP_SALT_CONFIG_DIR}/tests"
112 # Verify the role exists
113 if [[ ! "database,balancer,controller,keepstore,websocket,keepweb,workbench2,webshell,keepbalance,keepproxy,shell,workbench,dispatcher,monitoring" == *"$i"* ]]; then
114 echo "The role '${i}' is not a valid role"
118 ROLES="${ROLES:-} ${i}"
146 mkdir -p --mode=0700 /srv/salt/certs
148 if [ -f ${cert_dir}/${cert_name}.crt ]; then
149 install --mode=0600 ${cert_dir}/${cert_name}.crt /srv/salt/certs/arvados-${cert_name}.pem
151 echo "${cert_dir}/${cert_name}.crt does not exist. Exiting"
154 if [ -f ${cert_dir}/${cert_name}.key ]; then
155 install --mode=0600 ${cert_dir}/${cert_name}.key /srv/salt/certs/arvados-${cert_name}.key
157 echo "${cert_dir}/${cert_name}.key does not exist. Exiting"
162 apply_var_substitutions() {
165 sed "s#__ANONYMOUS_USER_TOKEN__#${ANONYMOUS_USER_TOKEN}#g;
166 s#__BLOB_SIGNING_KEY__#${BLOB_SIGNING_KEY}#g;
167 s#__CONTROLLER_EXT_SSL_PORT__#${CONTROLLER_EXT_SSL_PORT}#g;
168 s#__CLUSTER__#${CLUSTER}#g;
169 s#__DOMAIN__#${DOMAIN}#g;
170 s#__HOSTNAME_EXT__#${HOSTNAME_EXT}#g;
171 s#__IP_INT__#${IP_INT}#g;
172 s#__INITIAL_USER_EMAIL__#${INITIAL_USER_EMAIL}#g;
173 s#__INITIAL_USER_PASSWORD__#${INITIAL_USER_PASSWORD}#g;
174 s#__INITIAL_USER__#${INITIAL_USER}#g;
175 s#__LE_AWS_REGION__#${LE_AWS_REGION:-}#g;
176 s#__LE_AWS_SECRET_ACCESS_KEY__#${LE_AWS_SECRET_ACCESS_KEY:-}#g;
177 s#__LE_AWS_ACCESS_KEY_ID__#${LE_AWS_ACCESS_KEY_ID:-}#g;
178 s#__DATABASE_NAME__#${DATABASE_NAME}#g;
179 s#__DATABASE_USER__#${DATABASE_USER}#g;
180 s#__DATABASE_PASSWORD__#${DATABASE_PASSWORD}#g;
181 s#__DATABASE_INT_IP__#${DATABASE_INT_IP:-}#g;
182 s#__DATABASE_EXTERNAL_SERVICE_HOST_OR_IP__#${DATABASE_EXTERNAL_SERVICE_HOST_OR_IP:-}#g;
183 s#__DATABASE_POSTGRESQL_VERSION__#${DATABASE_POSTGRESQL_VERSION}#g;
184 s#__KEEPWEB_EXT_SSL_PORT__#${KEEPWEB_EXT_SSL_PORT}#g;
185 s#__KEEP_EXT_SSL_PORT__#${KEEP_EXT_SSL_PORT}#g;
186 s#__MANAGEMENT_TOKEN__#${MANAGEMENT_TOKEN}#g;
187 s#__RELEASE__#${RELEASE}#g;
188 s#__SYSTEM_ROOT_TOKEN__#${SYSTEM_ROOT_TOKEN}#g;
189 s#__VERSION__#${VERSION}#g;
190 s#__WEBSHELL_EXT_SSL_PORT__#${WEBSHELL_EXT_SSL_PORT}#g;
191 s#__WEBSOCKET_EXT_SSL_PORT__#${WEBSOCKET_EXT_SSL_PORT}#g;
192 s#__WORKBENCH1_EXT_SSL_PORT__#${WORKBENCH1_EXT_SSL_PORT}#g;
193 s#__WORKBENCH2_EXT_SSL_PORT__#${WORKBENCH2_EXT_SSL_PORT}#g;
194 s#__CLUSTER_INT_CIDR__#${CLUSTER_INT_CIDR}#g;
195 s#__CONTROLLER_INT_IP__#${CONTROLLER_INT_IP}#g;
196 s#__WEBSOCKET_INT_IP__#${WEBSOCKET_INT_IP}#g;
197 s#__KEEP_INT_IP__#${KEEP_INT_IP}#g;
198 s#__KEEPSTORE0_INT_IP__#${KEEPSTORE0_INT_IP}#g;
199 s#__KEEPWEB_INT_IP__#${KEEPWEB_INT_IP}#g;
200 s#__WEBSHELL_INT_IP__#${WEBSHELL_INT_IP}#g;
201 s#__SHELL_INT_IP__#${SHELL_INT_IP}#g;
202 s#__WORKBENCH1_INT_IP__#${WORKBENCH1_INT_IP}#g;
203 s#__WORKBENCH2_INT_IP__#${WORKBENCH2_INT_IP}#g;
204 s#__SSL_KEY_ENCRYPTED__#${SSL_KEY_ENCRYPTED}#g;
205 s#__SSL_KEY_AWS_REGION__#${SSL_KEY_AWS_REGION:-}#g;
206 s#__SSL_KEY_AWS_SECRET_NAME__#${SSL_KEY_AWS_SECRET_NAME}#g;
207 s#__CONTROLLER_MAX_WORKERS__#${CONTROLLER_MAX_WORKERS:-}#g;
208 s#__CONTROLLER_MAX_QUEUED_REQUESTS__#${CONTROLLER_MAX_QUEUED_REQUESTS:-128}#g;
209 s#__MONITORING_USERNAME__#${MONITORING_USERNAME}#g;
210 s#__MONITORING_EMAIL__#${MONITORING_EMAIL}#g;
211 s#__MONITORING_PASSWORD__#${MONITORING_PASSWORD}#g;
212 s#__DISPATCHER_SSH_PRIVKEY__#${DISPATCHER_SSH_PRIVKEY//$'\n'/\\n}#g;
213 s#__ENABLE_BALANCER__#${ENABLE_BALANCER}#g;
214 s#__DISABLED_CONTROLLER__#${DISABLED_CONTROLLER}#g;
215 s#__BALANCER_NODENAME__#${ROLE2NODES['balancer']:-}#g;
216 s#__PROMETHEUS_NODENAME__#${ROLE2NODES['monitoring']:-}#g;
217 s#__PROMETHEUS_DATA_RETENTION_TIME__#${PROMETHEUS_DATA_RETENTION_TIME:-15d}#g;
218 s#__CONTROLLER_NODES__#${ROLE2NODES['controller']:-}#g;
219 s#__NODELIST__#${NODELIST}#g;
220 s#__DISPATCHER_INT_IP__#${DISPATCHER_INT_IP}#g;
221 s#__KEEPBALANCE_INT_IP__#${KEEPBALANCE_INT_IP}#g;
222 s#__COMPUTE_AMI__#${COMPUTE_AMI:-}#g;
223 s#__COMPUTE_SG__#${COMPUTE_SG:-}#g;
224 s#__COMPUTE_SUBNET__#${COMPUTE_SUBNET:-}#g;
225 s#__COMPUTE_AWS_REGION__#${COMPUTE_AWS_REGION:-}#g;
226 s#__COMPUTE_USER__#${COMPUTE_USER:-}#g;
227 s#__KEEP_AWS_S3_BUCKET__#${KEEP_AWS_S3_BUCKET:-}#g;
228 s#__KEEP_AWS_IAM_ROLE__#${KEEP_AWS_IAM_ROLE:-}#g;
229 s#__KEEP_AWS_REGION__#${KEEP_AWS_REGION:-}#g" \
230 "${SRCFILE}" > "${DSTFILE}"
234 CONFIG_FILE="${SCRIPT_DIR}/local.params"
235 CONFIG_DIR="local_config_dir"
238 CONTROLLER_EXT_SSL_PORT=443
241 NGINX_INSTALL_SOURCE="install_from_repo"
246 # Hostnames/IPs used for single-host deploys
251 INITIAL_USER_EMAIL=""
252 INITIAL_USER_PASSWORD=""
254 CONTROLLER_EXT_SSL_PORT=8000
255 KEEP_EXT_SSL_PORT=25101
256 # Both for collections and downloads
257 KEEPWEB_EXT_SSL_PORT=9002
258 WEBSHELL_EXT_SSL_PORT=4202
259 WEBSOCKET_EXT_SSL_PORT=8002
260 WORKBENCH1_EXT_SSL_PORT=443
261 WORKBENCH2_EXT_SSL_PORT=3001
263 SSL_MODE="self-signed"
264 USE_LETSENCRYPT_ROUTE53="no"
265 CUSTOM_CERTS_DIR="${SCRIPT_DIR}/local_config_dir/certs"
267 GRAFANA_DASHBOARDS_DIR="${SCRIPT_DIR}/local_config_dir/dashboards"
269 ## These are ARVADOS-related parameters
270 # For a stable release, change RELEASE "production" and VERSION to the
271 # package version (including the iteration, e.g. X.Y.Z-1) of the
273 # The "local.params.example.*" files already set "RELEASE=production"
274 # to deploy production-ready packages
275 RELEASE="development"
278 # These are arvados-formula-related parameters
279 # An arvados-formula tag. For a stable release, this should be a
280 # branch name (e.g. X.Y-dev) or tag for the release.
281 # ARVADOS_TAG="2.2.0"
284 # We pin the salt version to avoid potential incompatibilities when a new
285 # stable version is released.
288 # Other formula versions we depend on
289 #POSTGRES_TAG="v0.44.0"
290 #POSTGRES_URL="https://github.com/saltstack-formulas/postgres-formula.git"
291 POSTGRES_TAG="0.45.0-bugfix327"
292 POSTGRES_URL="https://github.com/arvados/postgres-formula.git"
296 LETSENCRYPT_TAG="v2.1.0"
297 LOGROTATE_TAG="v0.14.0"
298 PROMETHEUS_TAG="v5.6.5"
302 DUMP_SALT_CONFIG_DIR=""
305 STATES_TOP=${S_DIR}/top.sls
307 F_DIR="/srv/formulas"
310 PILLARS_TOP=${P_DIR}/top.sls
312 T_DIR="/tmp/cluster_tests"
317 declare -A ROLE2NODES
322 if [ ! -d ${CONFIG_DIR} ]; then
323 echo >&2 "You don't seem to have a config directory with pillars and states."
324 echo >&2 "Please create a '${CONFIG_DIR}' directory (as configured in your '${CONFIG_FILE}'). Please see"
325 echo >&2 " * https://doc.arvados.org/install/salt-single-host.html#single_host, or"
326 echo >&2 " * https://doc.arvados.org/install/salt-multi-host.html#multi_host_multi_hostnames"
330 if grep -rni 'fixme' ${CONFIG_FILE}.secrets ${CONFIG_FILE} ${CONFIG_DIR} ; then
331 echo >&2 "The config files has some parameters that need to be modified."
332 echo >&2 "Please, fix them and re-run the provision script."
336 if ! grep -qE '^[[:alnum:]]{5}$' <<<${CLUSTER} ; then
337 echo >&2 "ERROR: <CLUSTER> must be exactly 5 lowercase alphanumeric characters long"
338 echo >&2 "Fix the cluster name in the 'local.params' file and re-run the provision script"
342 # Only used in single_host/single_name deploys
343 if [ ! -z "${HOSTNAME_EXT:-}" ] ; then
344 # We need to add some extra control vars to manage a single certificate vs. multiple
345 USE_SINGLE_HOSTNAME="yes"
346 # Make sure that the value configured as IP_INT is a real IP on the system.
347 # If we don't error out early here when there is a mismatch, the formula will
348 # fail with hard to interpret nginx errors later on.
349 ip addr list |grep "${IP_INT}/" >/dev/null
350 if [[ $? -ne 0 ]]; then
351 echo "Unable to find the IP_INT address '${IP_INT}' on the system, please correct the value in local.params. Exiting..."
355 USE_SINGLE_HOSTNAME="no"
356 # We set this variable, anyway, so sed lines do not fail and we don't need to add more
358 HOSTNAME_EXT="${DOMAIN}"
361 if [ "${DUMP_CONFIG}" = "yes" ]; then
362 echo "The provision installer will just dump a config under ${DUMP_SALT_CONFIG_DIR} and exit"
364 # Install a few dependency packages
365 # First, let's figure out the OS we're working on
366 OS_ID=$(grep ^ID= /etc/os-release |cut -f 2 -d= |cut -f 2 -d \")
367 echo "Detected distro: ${OS_ID}"
371 echo "WARNING! Disabling SELinux, see https://dev.arvados.org/issues/18019"
372 sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/sysconfig/selinux
373 setenforce permissive
374 yum install -y curl git jq
377 # Wait 2 minutes for any apt locks to clear
378 # This option is supported from apt 1.9.1 and ignored in older apt versions.
379 # Cf. https://blog.sinjakli.co.uk/2021/10/25/waiting-for-apt-locks-without-the-hacky-bash-scripts/
380 DEBIAN_FRONTEND=noninteractive apt -o DPkg::Lock::Timeout=120 update
381 DEBIAN_FRONTEND=noninteractive apt install -y curl git jq
385 if which salt-call; then
386 echo "Salt already installed"
388 curl -L https://bootstrap.saltstack.com -o /tmp/bootstrap_salt.sh
389 sh /tmp/bootstrap_salt.sh -XdfP -x python3 old-stable ${SALT_VERSION}
390 /bin/systemctl stop salt-minion.service
391 /bin/systemctl disable salt-minion.service
394 # Set salt to masterless mode
395 cat > /etc/salt/minion << EOFSM
410 mkdir -p ${S_DIR} ${F_DIR} ${P_DIR} ${T_DIR}
412 # Get the formula and dependencies
413 cd ${F_DIR} || exit 1
414 echo "Cloning formulas"
415 test -d docker && ( cd docker && git fetch ) \
416 || git clone --quiet https://github.com/saltstack-formulas/docker-formula.git ${F_DIR}/docker
417 ( cd docker && git checkout --quiet tags/"${DOCKER_TAG}" )
420 test -d locale && ( cd locale && git fetch ) \
421 || git clone --quiet https://github.com/saltstack-formulas/locale-formula.git ${F_DIR}/locale
422 ( cd locale && git checkout --quiet tags/"${LOCALE_TAG}" )
425 test -d nginx && ( cd nginx && git fetch ) \
426 || git clone --quiet https://github.com/saltstack-formulas/nginx-formula.git ${F_DIR}/nginx
427 ( cd nginx && git checkout --quiet tags/"${NGINX_TAG}" )
430 test -d postgres && ( cd postgres && git fetch ) \
431 || git clone --quiet ${POSTGRES_URL} ${F_DIR}/postgres
432 ( cd postgres && git checkout --quiet tags/"${POSTGRES_TAG}" )
435 test -d prometheus && ( cd prometheus && git fetch ) \
436 || git clone --quiet https://github.com/saltstack-formulas/prometheus-formula.git ${F_DIR}/prometheus
437 ( cd prometheus && git checkout --quiet tags/"${PROMETHEUS_TAG}" )
440 test -d grafana && ( cd grafana && git fetch ) \
441 || git clone --quiet https://github.com/saltstack-formulas/grafana-formula.git ${F_DIR}/grafana
442 ( cd grafana && git checkout --quiet "${GRAFANA_TAG}" )
444 echo "...letsencrypt"
445 test -d letsencrypt && ( cd letsencrypt && git fetch ) \
446 || git clone --quiet https://github.com/saltstack-formulas/letsencrypt-formula.git ${F_DIR}/letsencrypt
447 ( cd letsencrypt && git checkout --quiet tags/"${LETSENCRYPT_TAG}" )
450 test -d logrotate && ( cd logrotate && git fetch ) \
451 || git clone --quiet https://github.com/saltstack-formulas/logrotate-formula.git ${F_DIR}/logrotate
452 ( cd logrotate && git checkout --quiet tags/"${LOGROTATE_TAG}" )
455 test -d arvados || git clone --quiet https://git.arvados.org/arvados-formula.git ${F_DIR}/arvados
457 # If we want to try a specific branch of the formula
458 if [[ ! -z "${BRANCH:-}" && "x${BRANCH}" != "xmain" ]]; then
459 ( cd ${F_DIR}/arvados && git fetch && git checkout --quiet "${BRANCH}" || git checkout --quiet -t origin/"${BRANCH}" -b "${BRANCH}" )
460 elif [ "x${ARVADOS_TAG:-}" != "x" ]; then
461 ( cd ${F_DIR}/arvados && git checkout --quiet tags/"${ARVADOS_TAG}" -b "${ARVADOS_TAG}" )
464 if [ "x${VAGRANT:-}" = "xyes" ]; then
465 EXTRA_STATES_DIR="/home/vagrant/${CONFIG_DIR}/states"
466 SOURCE_PILLARS_DIR="/home/vagrant/${CONFIG_DIR}/pillars"
467 SOURCE_TOFS_DIR="/home/vagrant/${CONFIG_DIR}/tofs"
468 SOURCE_TESTS_DIR="/home/vagrant/${TESTS_DIR}"
470 EXTRA_STATES_DIR="${SCRIPT_DIR}/${CONFIG_DIR}/states"
471 SOURCE_PILLARS_DIR="${SCRIPT_DIR}/${CONFIG_DIR}/pillars"
472 SOURCE_TOFS_DIR="${SCRIPT_DIR}/${CONFIG_DIR}/tofs"
473 SOURCE_TESTS_DIR="${SCRIPT_DIR}/${TESTS_DIR}"
476 SOURCE_STATES_DIR="${EXTRA_STATES_DIR}"
478 echo "Writing pillars and states"
480 # Replace variables (cluster, domain, etc) in the pillars, states and tests
481 # to ease deployment for newcomers
482 if [ ! -d "${SOURCE_PILLARS_DIR}" ]; then
483 echo "${SOURCE_PILLARS_DIR} does not exist or is not a directory. Exiting."
486 for f in $(ls "${SOURCE_PILLARS_DIR}"/*); do
487 apply_var_substitutions "${f}" "${P_DIR}"/$(basename "${f}")
490 if [ ! -d "${SOURCE_TESTS_DIR}" ]; then
491 echo "WARNING: The tests directory was not copied to \"${SOURCE_TESTS_DIR}\"."
492 if [ "x${TEST:-}" = "xyes" ]; then
493 echo "WARNING: Disabling tests for this installation."
498 # Replace cluster and domain name in the test files
499 for f in $(ls "${SOURCE_TESTS_DIR}"/*); do
500 FILTERS="s#__CLUSTER__#${CLUSTER}#g;
501 s#__CONTROLLER_EXT_SSL_PORT__#${CONTROLLER_EXT_SSL_PORT}#g;
502 s#__DOMAIN__#${DOMAIN}#g;
503 s#__IP_INT__#${IP_INT}#g;
504 s#__INITIAL_USER_EMAIL__#${INITIAL_USER_EMAIL}#g;
505 s#__INITIAL_USER_PASSWORD__#${INITIAL_USER_PASSWORD}#g
506 s#__INITIAL_USER__#${INITIAL_USER}#g;
507 s#__DATABASE_PASSWORD__#${DATABASE_PASSWORD}#g;
508 s#__SYSTEM_ROOT_TOKEN__#${SYSTEM_ROOT_TOKEN}#g"
509 if [ "$USE_SINGLE_HOSTNAME" = "yes" ]; then
510 FILTERS="s#__CLUSTER__.__DOMAIN__#${HOSTNAME_EXT}#g;
514 "${f}" > ${T_DIR}/$(basename "${f}")
516 chmod 755 ${T_DIR}/run-test.sh
519 # Replace helper state files that differ from the formula's examples
520 if [ -d "${SOURCE_STATES_DIR}" ]; then
521 mkdir -p "${F_DIR}"/extra/extra
522 rm -rf "${F_DIR}"/extra/extra/*
524 for f in $(ls "${SOURCE_STATES_DIR}"/*); do
525 apply_var_substitutions "${f}" "${F_DIR}/extra/extra"/$(basename "${f}")
529 # Now, we build the SALT states/pillars trees
530 # As we need to separate both states and pillars in case we want specific
531 # roles, we iterate on both at the same time
533 # Formula template overrides (TOFS)
534 # See: https://template-formula.readthedocs.io/en/latest/TOFS_pattern.html#template-override
535 if [ -d ${SOURCE_TOFS_DIR} ]; then
536 find ${SOURCE_TOFS_DIR} -mindepth 1 -maxdepth 1 -type d -exec cp -r "{}" ${S_DIR} \;
540 cat > ${STATES_TOP} << EOFTSLS
547 cat > ${PILLARS_TOP} << EOFPSLS
554 # States, extra states
555 if [ -d "${F_DIR}"/extra/extra ]; then
556 SKIP_SNAKE_OIL="snakeoil_certs"
558 if [[ "$DEV_MODE" = "yes" || "${SSL_MODE}" == "self-signed" ]] ; then
559 # In dev mode, we create some snake oil certs that we'll
560 # use as CUSTOM_CERTS, so we don't skip the states file.
561 # Same when using self-signed certificates.
562 SKIP_SNAKE_OIL="dont_add_snakeoil_certs"
564 for f in $(ls "${F_DIR}"/extra/extra/*.sls | egrep -v "${SKIP_SNAKE_OIL}|shell_"); do
565 echo " - extra.$(basename ${f} | sed 's/.sls$//g')" >> ${STATES_TOP}
567 # Use byo or self-signed certificates
568 if [ "${SSL_MODE}" != "lets-encrypt" ]; then
569 mkdir -p "${F_DIR}"/extra/extra/files
573 # If we want specific roles for a node, just add the desired states
574 # and its dependencies
575 if [ -z "${ROLES:-}" ]; then
577 echo " - nginx.passenger" >> ${STATES_TOP}
578 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
579 if [ "${USE_LETSENCRYPT_ROUTE53}" = "yes" ]; then
580 grep -q "aws_credentials" ${STATES_TOP} || echo " - extra.aws_credentials" >> ${STATES_TOP}
582 grep -q "letsencrypt" ${STATES_TOP} || echo " - letsencrypt" >> ${STATES_TOP}
584 mkdir -p --mode=0700 /srv/salt/certs
585 if [ "${SSL_MODE}" = "bring-your-own" ]; then
586 # Copy certs to formula extra/files
587 install --mode=0600 ${CUSTOM_CERTS_DIR}/* /srv/salt/certs/
588 # We add the custom_certs state
589 grep -q "custom_certs" ${STATES_TOP} || echo " - extra.custom_certs" >> ${STATES_TOP}
590 if [ "${SSL_KEY_ENCRYPTED}" = "yes" ]; then
591 grep -q "ssl_key_encrypted" ${STATES_TOP} || echo " - extra.ssl_key_encrypted" >> ${STATES_TOP}
594 # In self-signed mode, the certificate files will be created and put in the
595 # destination directory by the snakeoil_certs.sls state file
598 echo " - postgres" >> ${STATES_TOP}
599 echo " - logrotate" >> ${STATES_TOP}
600 echo " - docker.software" >> ${STATES_TOP}
601 echo " - arvados.repo" >> ${STATES_TOP}
602 echo " - arvados.config" >> ${STATES_TOP}
603 echo " - arvados.ruby" >> ${STATES_TOP}
604 echo " - arvados.api" >> ${STATES_TOP}
605 echo " - arvados.controller" >> ${STATES_TOP}
606 echo " - arvados.keepstore" >> ${STATES_TOP}
607 echo " - arvados.websocket" >> ${STATES_TOP}
608 echo " - arvados.keepweb" >> ${STATES_TOP}
609 echo " - arvados.workbench2" >> ${STATES_TOP}
610 echo " - arvados.keepproxy" >> ${STATES_TOP}
611 echo " - arvados.shell" >> ${STATES_TOP}
612 echo " - arvados.dispatcher" >> ${STATES_TOP}
613 echo " - extra.shell_sudo_passwordless" >> ${STATES_TOP}
614 echo " - extra.shell_cron_add_login_sync" >> ${STATES_TOP}
615 echo " - extra.passenger_rvm" >> ${STATES_TOP}
618 echo " - docker" >> ${PILLARS_TOP}
619 echo " - nginx_api_configuration" >> ${PILLARS_TOP}
620 echo " - logrotate_api" >> ${PILLARS_TOP}
621 echo " - nginx_controller_configuration" >> ${PILLARS_TOP}
622 echo " - nginx_keepproxy_configuration" >> ${PILLARS_TOP}
623 echo " - nginx_keepweb_configuration" >> ${PILLARS_TOP}
624 echo " - nginx_passenger" >> ${PILLARS_TOP}
625 echo " - nginx_websocket_configuration" >> ${PILLARS_TOP}
626 echo " - nginx_webshell_configuration" >> ${PILLARS_TOP}
627 echo " - nginx_workbench2_configuration" >> ${PILLARS_TOP}
628 echo " - nginx_workbench_configuration" >> ${PILLARS_TOP}
629 echo " - logrotate_wb1" >> ${PILLARS_TOP}
630 echo " - postgresql" >> ${PILLARS_TOP}
632 # We need to tweak the Nginx's pillar depending whether we want plan nginx or nginx+passenger
633 NGINX_INSTALL_SOURCE="install_from_phusionpassenger"
634 sed -i "s/__NGINX_INSTALL_SOURCE__/${NGINX_INSTALL_SOURCE}/g" ${P_DIR}/nginx_passenger.sls
636 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
637 if [ "${USE_LETSENCRYPT_ROUTE53}" = "yes" ]; then
638 grep -q "aws_credentials" ${PILLARS_TOP} || echo " - aws_credentials" >> ${PILLARS_TOP}
640 grep -q "letsencrypt" ${PILLARS_TOP} || echo " - letsencrypt" >> ${PILLARS_TOP}
642 hosts=("controller" "websocket" "workbench" "workbench2" "webshell" "keepproxy")
643 if [ ${USE_SINGLE_HOSTNAME} = "no" ]; then
644 hosts+=("download" "collections")
649 for c in "${hosts[@]}"; do
650 # Are we in a single-host-single-hostname env?
651 if [ "${USE_SINGLE_HOSTNAME}" = "yes" ]; then
652 # Are we in a single-host-single-hostname env?
653 CERT_NAME=${HOSTNAME_EXT}
655 # We are in a multiple-hostnames env
656 CERT_NAME=${c}.${DOMAIN}
659 # As the pillar differs whether we use LE or custom certs, we need to do a final edition on them
660 sed -i "s/__CERT_REQUIRES__/cmd: create-initial-cert-${CERT_NAME}*/g;
661 s#__CERT_PEM__#/etc/letsencrypt/live/${CERT_NAME}/fullchain.pem#g;
662 s#__CERT_KEY__#/etc/letsencrypt/live/${CERT_NAME}/privkey.pem#g" \
663 ${P_DIR}/nginx_${c}_configuration.sls
666 # Use custom certs (either dev mode or prod)
667 grep -q "extra_custom_certs" ${PILLARS_TOP} || echo " - extra_custom_certs" >> ${PILLARS_TOP}
668 # And add the certs in the custom_certs pillar
669 echo "extra_custom_certs_dir: /srv/salt/certs" > ${P_DIR}/extra_custom_certs.sls
670 echo "extra_custom_certs:" >> ${P_DIR}/extra_custom_certs.sls
672 for c in controller websocket workbench workbench2 webshell keepweb keepproxy; do
673 # Are we in a single-host-single-hostname env?
674 if [ "${USE_SINGLE_HOSTNAME}" = "yes" ]; then
675 # Are we in a single-host-single-hostname env?
676 CERT_NAME=${HOSTNAME_EXT}
678 # We are in a multiple-hostnames env
682 if [[ "$SSL_MODE" == "bring-your-own" ]]; then
683 copy_custom_cert ${CUSTOM_CERTS_DIR} ${CERT_NAME}
686 grep -q ${CERT_NAME} ${P_DIR}/extra_custom_certs.sls || echo " - ${CERT_NAME}" >> ${P_DIR}/extra_custom_certs.sls
688 # As the pillar differs whether we use LE or custom certs, we need to do a final edition on them
689 sed -i "s/__CERT_REQUIRES__/file: extra_custom_certs_${CERT_NAME}_cert_file_copy/g;
690 s#__CERT_PEM__#/etc/nginx/ssl/arvados-${CERT_NAME}.pem#g;
691 s#__CERT_KEY__#/etc/nginx/ssl/arvados-${CERT_NAME}.key#g" \
692 ${P_DIR}/nginx_${c}_configuration.sls
696 # If we add individual roles, make sure we add the repo first
697 echo " - arvados.repo" >> ${STATES_TOP}
698 # We add the extra_custom_certs state
699 grep -q "extra.custom_certs" ${STATES_TOP} || echo " - extra.custom_certs" >> ${STATES_TOP}
700 if [ "${SSL_KEY_ENCRYPTED}" = "yes" ]; then
701 grep -q "ssl_key_encrypted" ${STATES_TOP} || echo " - extra.ssl_key_encrypted" >> ${STATES_TOP}
704 # And we add the basic part for the certs pillar
705 if [ "${SSL_MODE}" != "lets-encrypt" ]; then
706 # And add the certs in the custom_certs pillar
707 echo "extra_custom_certs_dir: /srv/salt/certs" > ${P_DIR}/extra_custom_certs.sls
708 echo "extra_custom_certs:" >> ${P_DIR}/extra_custom_certs.sls
709 grep -q "extra_custom_certs" ${PILLARS_TOP} || echo " - extra_custom_certs" >> ${PILLARS_TOP}
712 # Prometheus state on all nodes due to the node exporter below
713 grep -q "\- prometheus$" ${STATES_TOP} || echo " - prometheus" >> ${STATES_TOP}
714 # Prometheus node exporter pillar
715 grep -q "prometheus_node_exporter" ${PILLARS_TOP} || echo " - prometheus_node_exporter" >> ${PILLARS_TOP}
717 for R in ${ROLES:-}; do
721 grep -q "\- postgres$" ${STATES_TOP} || echo " - postgres" >> ${STATES_TOP}
722 grep -q "extra.prometheus_pg_exporter" ${STATES_TOP} || echo " - extra.prometheus_pg_exporter" >> ${STATES_TOP}
724 grep -q "postgresql" ${PILLARS_TOP} || echo " - postgresql" >> ${PILLARS_TOP}
725 grep -q "prometheus_pg_exporter" ${PILLARS_TOP} || echo " - prometheus_pg_exporter" >> ${PILLARS_TOP}
728 ### Support files ###
729 GRAFANA_DASHBOARDS_DEST_DIR=/srv/salt/dashboards
730 mkdir -p "${GRAFANA_DASHBOARDS_DEST_DIR}"
731 rm -f "${GRAFANA_DASHBOARDS_DEST_DIR}"/*
732 # "ArvadosPromDataSource" is the hardcoded UID for Prometheus' datasource
734 for f in $(ls "${GRAFANA_DASHBOARDS_DIR}"/*.json); do
735 sed "s#__TLS_EXPIRATION_YELLOW__#${TLS_EXPIRATION_YELLOW}#g;
736 s#__TLS_EXPIRATION_GREEN__#${TLS_EXPIRATION_GREEN}#g;
737 s#\${DS_PROMETHEUS}#ArvadosPromDataSource#g" \
738 "${f}" > "${GRAFANA_DASHBOARDS_DEST_DIR}"/$(basename "${f}")
742 grep -q "\- nginx$" ${STATES_TOP} || echo " - nginx" >> ${STATES_TOP}
743 grep -q "extra.nginx_prometheus_configuration" ${STATES_TOP} || echo " - extra.nginx_prometheus_configuration" >> ${STATES_TOP}
745 grep -q "\- grafana$" ${STATES_TOP} || echo " - grafana" >> ${STATES_TOP}
746 grep -q "extra.grafana_datasource" ${STATES_TOP} || echo " - extra.grafana_datasource" >> ${STATES_TOP}
747 grep -q "extra.grafana_dashboards" ${STATES_TOP} || echo " - extra.grafana_dashboards" >> ${STATES_TOP}
748 grep -q "extra.grafana_admin_user" ${STATES_TOP} || echo " - extra.grafana_admin_user" >> ${STATES_TOP}
750 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
751 grep -q "letsencrypt" ${STATES_TOP} || echo " - letsencrypt" >> ${STATES_TOP}
752 if [ "x${USE_LETSENCRYPT_ROUTE53:-}" = "xyes" ]; then
753 grep -q "aws_credentials" ${STATES_TOP} || echo " - aws_credentials" >> ${STATES_TOP}
755 elif [ "${SSL_MODE}" = "bring-your-own" ]; then
756 for SVC in grafana prometheus; do
757 copy_custom_cert ${CUSTOM_CERTS_DIR} ${SVC}
761 grep -q "prometheus_server" ${PILLARS_TOP} || echo " - prometheus_server" >> ${PILLARS_TOP}
762 grep -q "grafana" ${PILLARS_TOP} || echo " - grafana" >> ${PILLARS_TOP}
763 for SVC in grafana prometheus; do
764 grep -q "nginx_${SVC}_configuration" ${PILLARS_TOP} || echo " - nginx_${SVC}_configuration" >> ${PILLARS_TOP}
766 grep -q "nginx_snippets" ${PILLARS_TOP} || echo " - nginx_snippets" >> ${PILLARS_TOP}
767 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
768 grep -q "letsencrypt" ${PILLARS_TOP} || echo " - letsencrypt" >> ${PILLARS_TOP}
769 for SVC in grafana prometheus; do
770 grep -q "letsencrypt_${SVC}_configuration" ${PILLARS_TOP} || echo " - letsencrypt_${SVC}_configuration" >> ${PILLARS_TOP}
771 sed -i "s/__CERT_REQUIRES__/cmd: create-initial-cert-${SVC}.${DOMAIN}*/g;
772 s#__CERT_PEM__#/etc/letsencrypt/live/${SVC}.${DOMAIN}/fullchain.pem#g;
773 s#__CERT_KEY__#/etc/letsencrypt/live/${SVC}.${DOMAIN}/privkey.pem#g" \
774 ${P_DIR}/nginx_${SVC}_configuration.sls
776 if [ "${USE_LETSENCRYPT_ROUTE53}" = "yes" ]; then
777 grep -q "aws_credentials" ${PILLARS_TOP} || echo " - aws_credentials" >> ${PILLARS_TOP}
779 elif [ "${SSL_MODE}" = "bring-your-own" ]; then
780 grep -q "ssl_key_encrypted" ${PILLARS_TOP} || echo " - ssl_key_encrypted" >> ${PILLARS_TOP}
781 for SVC in grafana prometheus; do
782 sed -i "s/__CERT_REQUIRES__/file: extra_custom_certs_${SVC}_cert_file_copy/g;
783 s#__CERT_PEM__#/etc/nginx/ssl/arvados-${SVC}.pem#g;
784 s#__CERT_KEY__#/etc/nginx/ssl/arvados-${SVC}.key#g" \
785 ${P_DIR}/nginx_${SVC}_configuration.sls
786 grep -q ${SVC} ${P_DIR}/extra_custom_certs.sls || echo " - ${SVC}" >> ${P_DIR}/extra_custom_certs.sls
792 grep -q "\- nginx$" ${STATES_TOP} || echo " - nginx" >> ${STATES_TOP}
794 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
795 grep -q "letsencrypt" ${STATES_TOP} || echo " - letsencrypt" >> ${STATES_TOP}
796 if [ "x${USE_LETSENCRYPT_ROUTE53:-}" = "xyes" ]; then
797 grep -q "aws_credentials" ${STATES_TOP} || echo " - aws_credentials" >> ${STATES_TOP}
799 elif [ "${SSL_MODE}" = "bring-your-own" ]; then
800 copy_custom_cert ${CUSTOM_CERTS_DIR} ${R}
804 grep -q "nginx_${R}_configuration" ${PILLARS_TOP} || echo " - nginx_${R}_configuration" >> ${PILLARS_TOP}
806 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
807 grep -q "letsencrypt" ${PILLARS_TOP} || echo " - letsencrypt" >> ${PILLARS_TOP}
809 grep -q "letsencrypt_${R}_configuration" ${PILLARS_TOP} || echo " - letsencrypt_${R}_configuration" >> ${PILLARS_TOP}
810 sed -i "s/__CERT_REQUIRES__/cmd: create-initial-cert-${ROLE2NODES['balancer']}*/g;
811 s#__CERT_PEM__#/etc/letsencrypt/live/${ROLE2NODES['balancer']}/fullchain.pem#g;
812 s#__CERT_KEY__#/etc/letsencrypt/live/${ROLE2NODES['balancer']}/privkey.pem#g" \
813 ${P_DIR}/nginx_${R}_configuration.sls
815 if [ "${USE_LETSENCRYPT_ROUTE53}" = "yes" ]; then
816 grep -q "aws_credentials" ${PILLARS_TOP} || echo " - aws_credentials" >> ${PILLARS_TOP}
818 elif [ "${SSL_MODE}" = "bring-your-own" ]; then
819 grep -q "ssl_key_encrypted" ${PILLARS_TOP} || echo " - ssl_key_encrypted" >> ${PILLARS_TOP}
820 sed -i "s/__CERT_REQUIRES__/file: extra_custom_certs_${R}_cert_file_copy/g;
821 s#__CERT_PEM__#/etc/nginx/ssl/arvados-${R}.pem#g;
822 s#__CERT_KEY__#/etc/nginx/ssl/arvados-${R}.key#g" \
823 ${P_DIR}/nginx_${R}_configuration.sls
824 grep -q "${R}" ${P_DIR}/extra_custom_certs.sls || echo " - ${R}" >> ${P_DIR}/extra_custom_certs.sls
829 grep -q " - logrotate" ${STATES_TOP} || echo " - logrotate" >> ${STATES_TOP}
830 if grep -q " - nginx.*$" ${STATES_TOP}; then
831 sed -i s/"^ - nginx.*$"/" - nginx.passenger"/g ${STATES_TOP}
833 echo " - nginx.passenger" >> ${STATES_TOP}
835 echo " - extra.passenger_rvm" >> ${STATES_TOP}
836 grep -q "^ - postgres\\.client$" ${STATES_TOP} || echo " - postgres.client" >> ${STATES_TOP}
838 ### If we don't install and run LE before arvados-api-server, it fails and breaks everything
839 ### after it. So we add this here as we are, after all, sharing the host for api and controller
840 if [ "${ENABLE_BALANCER}" == "no" ]; then
841 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
842 if [ "x${USE_LETSENCRYPT_ROUTE53:-}" = "xyes" ]; then
843 grep -q "aws_credentials" ${STATES_TOP} || echo " - aws_credentials" >> ${STATES_TOP}
845 grep -q "letsencrypt" ${STATES_TOP} || echo " - letsencrypt" >> ${STATES_TOP}
846 elif [ "${SSL_MODE}" = "bring-your-own" ]; then
847 copy_custom_cert ${CUSTOM_CERTS_DIR} ${R}
848 grep -q controller ${P_DIR}/extra_custom_certs.sls || echo " - controller" >> ${P_DIR}/extra_custom_certs.sls
851 grep -q "arvados.api" ${STATES_TOP} || echo " - arvados.api" >> ${STATES_TOP}
852 grep -q "arvados.controller" ${STATES_TOP} || echo " - arvados.controller" >> ${STATES_TOP}
855 grep -q "logrotate_api" ${PILLARS_TOP} || echo " - logrotate_api" >> ${PILLARS_TOP}
856 grep -q "aws_credentials" ${PILLARS_TOP} || echo " - aws_credentials" >> ${PILLARS_TOP}
857 grep -q "postgresql" ${PILLARS_TOP} || echo " - postgresql" >> ${PILLARS_TOP}
858 grep -q "nginx_passenger" ${PILLARS_TOP} || echo " - nginx_passenger" >> ${PILLARS_TOP}
859 grep -q "nginx_snippets" ${PILLARS_TOP} || echo " - nginx_snippets" >> ${PILLARS_TOP}
860 grep -q "nginx_api_configuration" ${PILLARS_TOP} || echo " - nginx_api_configuration" >> ${PILLARS_TOP}
861 grep -q "nginx_controller_configuration" ${PILLARS_TOP} || echo " - nginx_controller_configuration" >> ${PILLARS_TOP}
863 if [ "${ENABLE_BALANCER}" == "no" ]; then
864 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
865 if [ "${USE_LETSENCRYPT_ROUTE53}" = "yes" ]; then
866 grep -q "aws_credentials" ${PILLARS_TOP} || echo " - aws_credentials" >> ${PILLARS_TOP}
869 grep -q "letsencrypt" ${PILLARS_TOP} || echo " - letsencrypt" >> ${PILLARS_TOP}
870 grep -q "letsencrypt_${R}_configuration" ${PILLARS_TOP} || echo " - letsencrypt_${R}_configuration" >> ${PILLARS_TOP}
871 sed -i "s/__CERT_REQUIRES__/cmd: create-initial-cert-${R}.${DOMAIN}*/g;
872 s#__CERT_PEM__#/etc/letsencrypt/live/${R}.${DOMAIN}/fullchain.pem#g;
873 s#__CERT_KEY__#/etc/letsencrypt/live/${R}.${DOMAIN}/privkey.pem#g" \
874 ${P_DIR}/nginx_${R}_configuration.sls
876 grep -q "ssl_key_encrypted" ${PILLARS_TOP} || echo " - ssl_key_encrypted" >> ${PILLARS_TOP}
877 sed -i "s/__CERT_REQUIRES__/file: extra_custom_certs_${R}_cert_file_copy/g;
878 s#__CERT_PEM__#/etc/nginx/ssl/arvados-${R}.pem#g;
879 s#__CERT_KEY__#/etc/nginx/ssl/arvados-${R}.key#g" \
880 ${P_DIR}/nginx_${R}_configuration.sls
881 grep -q ${R} ${P_DIR}/extra_custom_certs.sls || echo " - ${R}" >> ${P_DIR}/extra_custom_certs.sls
884 # We need to tweak the Nginx's pillar depending whether we want plain nginx or nginx+passenger
885 NGINX_INSTALL_SOURCE="install_from_phusionpassenger"
886 sed -i "s/__NGINX_INSTALL_SOURCE__/${NGINX_INSTALL_SOURCE}/g" ${P_DIR}/nginx_passenger.sls
888 "websocket" | "workbench" | "workbench2" | "webshell" | "keepweb" | "keepproxy")
890 grep -q "\- nginx$" ${STATES_TOP} || echo " - nginx" >> ${STATES_TOP}
892 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
893 if [ "x${USE_LETSENCRYPT_ROUTE53:-}" = "xyes" ]; then
894 grep -q "aws_credentials" ${STATES_TOP} || echo " - aws_credentials" >> ${STATES_TOP}
896 grep -q "letsencrypt" ${STATES_TOP} || echo " - letsencrypt" >> ${STATES_TOP}
898 # Use custom certs, special case for keepweb
899 if [ ${R} = "keepweb" ]; then
900 if [ "${SSL_MODE}" = "bring-your-own" ]; then
901 copy_custom_cert ${CUSTOM_CERTS_DIR} download
902 copy_custom_cert ${CUSTOM_CERTS_DIR} collections
905 if [ "${SSL_MODE}" = "bring-your-own" ]; then
906 copy_custom_cert ${CUSTOM_CERTS_DIR} ${R}
911 # webshell role is just a nginx vhost, so it has no state
912 # workbench role is deprecated since 2.7.0
913 if [[ "${R}" != "webshell" && "${R}" != "workbench" ]]; then
914 grep -q "arvados.${R}" ${STATES_TOP} || echo " - arvados.${R}" >> ${STATES_TOP}
918 grep -q "nginx_${R}_configuration" ${PILLARS_TOP} || echo " - nginx_${R}_configuration" >> ${PILLARS_TOP}
919 grep -q "nginx_snippets" ${PILLARS_TOP} || echo " - nginx_snippets" >> ${PILLARS_TOP}
920 # Special case for keepweb
921 if [ ${R} = "keepweb" ]; then
922 grep -q "nginx_download_configuration" ${PILLARS_TOP} || echo " - nginx_download_configuration" >> ${PILLARS_TOP}
923 grep -q "nginx_collections_configuration" ${PILLARS_TOP} || echo " - nginx_collections_configuration" >> ${PILLARS_TOP}
926 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
927 if [ "${USE_LETSENCRYPT_ROUTE53}" = "yes" ]; then
928 grep -q "aws_credentials" ${PILLARS_TOP} || echo " - aws_credentials" >> ${PILLARS_TOP}
930 grep -q "letsencrypt" ${PILLARS_TOP} || echo " - letsencrypt" >> ${PILLARS_TOP}
931 grep -q "letsencrypt_${R}_configuration" ${PILLARS_TOP} || echo " - letsencrypt_${R}_configuration" >> ${PILLARS_TOP}
933 # As the pillar differ whether we use LE or custom certs, we need to do a final edition on them
934 # Special case for keepweb
935 if [ ${R} = "keepweb" ]; then
936 for kwsub in download collections; do
937 sed -i "s/__CERT_REQUIRES__/cmd: create-initial-cert-${kwsub}.${DOMAIN}*/g;
938 s#__CERT_PEM__#/etc/letsencrypt/live/${kwsub}.${DOMAIN}/fullchain.pem#g;
939 s#__CERT_KEY__#/etc/letsencrypt/live/${kwsub}.${DOMAIN}/privkey.pem#g" \
940 ${P_DIR}/nginx_${kwsub}_configuration.sls
943 sed -i "s/__CERT_REQUIRES__/cmd: create-initial-cert-${R}.${DOMAIN}*/g;
944 s#__CERT_PEM__#/etc/letsencrypt/live/${R}.${DOMAIN}/fullchain.pem#g;
945 s#__CERT_KEY__#/etc/letsencrypt/live/${R}.${DOMAIN}/privkey.pem#g" \
946 ${P_DIR}/nginx_${R}_configuration.sls
949 grep -q "ssl_key_encrypted" ${PILLARS_TOP} || echo " - ssl_key_encrypted" >> ${PILLARS_TOP}
950 # As the pillar differ whether we use LE or custom certs, we need to do a final edition on them
951 # Special case for keepweb
952 if [ ${R} = "keepweb" ]; then
953 for kwsub in download collections; do
954 sed -i "s/__CERT_REQUIRES__/file: extra_custom_certs_${kwsub}_cert_file_copy/g;
955 s#__CERT_PEM__#/etc/nginx/ssl/arvados-${kwsub}.pem#g;
956 s#__CERT_KEY__#/etc/nginx/ssl/arvados-${kwsub}.key#g" \
957 ${P_DIR}/nginx_${kwsub}_configuration.sls
958 grep -q ${kwsub} ${P_DIR}/extra_custom_certs.sls || echo " - ${kwsub}" >> ${P_DIR}/extra_custom_certs.sls
961 sed -i "s/__CERT_REQUIRES__/file: extra_custom_certs_${R}_cert_file_copy/g;
962 s#__CERT_PEM__#/etc/nginx/ssl/arvados-${R}.pem#g;
963 s#__CERT_KEY__#/etc/nginx/ssl/arvados-${R}.key#g" \
964 ${P_DIR}/nginx_${R}_configuration.sls
965 grep -q ${R} ${P_DIR}/extra_custom_certs.sls || echo " - ${R}" >> ${P_DIR}/extra_custom_certs.sls
968 # We need to tweak the Nginx's pillar depending whether we want plain nginx or nginx+passenger
969 sed -i "s/__NGINX_INSTALL_SOURCE__/${NGINX_INSTALL_SOURCE}/g" ${P_DIR}/nginx_passenger.sls
973 echo " - extra.shell_sudo_passwordless" >> ${STATES_TOP}
974 echo " - extra.shell_cron_add_login_sync" >> ${STATES_TOP}
975 grep -q "docker" ${STATES_TOP} || echo " - docker.software" >> ${STATES_TOP}
976 grep -q "arvados.${R}" ${STATES_TOP} || echo " - arvados.${R}" >> ${STATES_TOP}
978 grep -q "docker" ${PILLARS_TOP} || echo " - docker" >> ${PILLARS_TOP}
980 "dispatcher" | "keepbalance" | "keepstore")
982 grep -q "arvados.${R}" ${STATES_TOP} || echo " - arvados.${R}" >> ${STATES_TOP}
984 # ATM, no specific pillar needed
987 echo "Unknown role ${R}"
994 if [ "${DUMP_CONFIG}" = "yes" ]; then
995 # We won't run the rest of the script because we're just dumping the config
999 # Now run the install
1000 salt-call --state-output=mixed --local state.apply -l ${LOG_LEVEL}
1002 # Finally, make sure that /etc/hosts is not overwritten on reboot
1003 if [ -d /etc/cloud/cloud.cfg.d ]; then
1004 # TODO: will this work on CentOS?
1005 sed -i 's/^manage_etc_hosts: true/#manage_etc_hosts: true/g' /etc/cloud/cloud.cfg.d/*
1008 # Leave a copy of the Arvados CA so the user can copy it where it's required
1009 if [ "${SSL_MODE}" = "self-signed" ]; then
1010 echo "Copying the Arvados CA certificate '${DOMAIN}-arvados-snakeoil-ca.crt' to the installer dir, so you can import it"
1011 if [ "x${VAGRANT:-}" = "xyes" ]; then
1012 cp /etc/ssl/certs/arvados-snakeoil-ca.pem /vagrant/${DOMAIN}-arvados-snakeoil-ca.pem
1014 cp /etc/ssl/certs/arvados-snakeoil-ca.pem ${SCRIPT_DIR}/${DOMAIN}-arvados-snakeoil-ca.crt
1018 if [ "x${VAGRANT:-}" = "xyes" ]; then
1019 # If running in a vagrant VM, also add default user to docker group
1020 echo "Adding the vagrant user to the docker group"
1021 usermod -a -G docker vagrant
1024 # Test that the installation finished correctly
1025 if [ "x${TEST:-}" = "xyes" ]; then
1027 # If we use RVM, we need to run this with it, or most ruby commands will fail
1029 if [ -x /usr/local/rvm/bin/rvm-exec ]; then
1030 RVM_EXEC="/usr/local/rvm/bin/rvm-exec"
1032 ${RVM_EXEC} ./run-test.sh