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 cluster by running \`arvados-client diagnostics\`"
27 echo >&2 " and a simple workflow"
28 echo >&2 " -r, --roles List of Arvados roles to apply to the host, comma separated"
29 echo >&2 " Possible values are:"
31 echo >&2 " controller"
32 echo >&2 " dispatcher"
34 echo >&2 " keepbalance"
37 echo >&2 " monitoring"
42 echo >&2 " workbench2"
43 echo >&2 " Defaults to applying them all"
44 echo >&2 " -h, --help Display this help and exit"
45 echo >&2 " --dump-config <dest_dir> Dumps the pillars and states to a directory"
46 echo >&2 " This parameter does not perform any installation at all. It's"
47 echo >&2 " intended to give you a parsed set of configuration files so"
48 echo >&2 " you can inspect them or use them in you Saltstack infrastructure."
50 echo >&2 " - parses the pillar and states templates,"
51 echo >&2 " - downloads the helper formulas with their desired versions,"
52 echo >&2 " - prepares the 'top.sls' files both for pillars and states"
53 echo >&2 " for the selected role(s)"
54 echo >&2 " - writes the resulting files into <dest_dir>"
55 echo >&2 " -v, --vagrant Run in vagrant and use the /vagrant shared dir"
56 echo >&2 " --development Run in dev mode, using snakeoil certs"
61 # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
62 if ! which getopt > /dev/null; then
63 echo >&2 "GNU getopt is required to run this script. Please install it and re-reun it"
67 TEMP=$(getopt -o c:dhp:r:tv \
68 --long config:,debug,development,dump-config:,help,roles:,test,vagrant \
72 then echo "Please check the parameters you entered and re-run again"
75 # Note the quotes around `$TEMP': they are essential!
78 while [ ${#} -ge 1 ]; do
90 if [[ ${2} = /* ]]; then
91 DUMP_SALT_CONFIG_DIR=${2}
93 DUMP_SALT_CONFIG_DIR=${PWD}/${2}
96 S_DIR="${DUMP_SALT_CONFIG_DIR}/salt"
98 F_DIR="${DUMP_SALT_CONFIG_DIR}/formulas"
100 P_DIR="${DUMP_SALT_CONFIG_DIR}/pillars"
102 T_DIR="${DUMP_SALT_CONFIG_DIR}/tests"
113 # Verify the role exists
114 if [[ ! "database,balancer,controller,keepstore,websocket,keepweb,workbench2,webshell,keepbalance,keepproxy,shell,workbench,dispatcher,monitoring" == *"$i"* ]]; then
115 echo "The role '${i}' is not a valid role"
119 ROLES="${ROLES:-} ${i}"
147 mkdir -p --mode=0700 /srv/salt/certs
149 if [ -f ${cert_dir}/${cert_name}.crt ]; then
150 install --mode=0600 ${cert_dir}/${cert_name}.crt /srv/salt/certs/arvados-${cert_name}.pem
152 echo "${cert_dir}/${cert_name}.crt does not exist. Exiting"
155 if [ -f ${cert_dir}/${cert_name}.key ]; then
156 install --mode=0600 ${cert_dir}/${cert_name}.key /srv/salt/certs/arvados-${cert_name}.key
158 echo "${cert_dir}/${cert_name}.key does not exist. Exiting"
163 apply_var_substitutions() {
166 sed "s#__ANONYMOUS_USER_TOKEN__#${ANONYMOUS_USER_TOKEN}#g;
167 s#__BLOB_SIGNING_KEY__#${BLOB_SIGNING_KEY}#g;
168 s#__CONTROLLER_EXT_SSL_PORT__#${CONTROLLER_EXT_SSL_PORT}#g;
169 s#__CLUSTER__#${CLUSTER}#g;
170 s#__DOMAIN__#${DOMAIN}#g;
171 s#__HOSTNAME_EXT__#${HOSTNAME_EXT}#g;
172 s#__IP_INT__#${IP_INT}#g;
173 s#__INITIAL_USER_EMAIL__#${INITIAL_USER_EMAIL}#g;
174 s#__INITIAL_USER_PASSWORD__#${INITIAL_USER_PASSWORD}#g;
175 s#__INITIAL_USER__#${INITIAL_USER}#g;
176 s#__LE_AWS_REGION__#${LE_AWS_REGION:-}#g;
177 s#__LE_AWS_SECRET_ACCESS_KEY__#${LE_AWS_SECRET_ACCESS_KEY:-}#g;
178 s#__LE_AWS_ACCESS_KEY_ID__#${LE_AWS_ACCESS_KEY_ID:-}#g;
179 s#__DATABASE_NAME__#${DATABASE_NAME}#g;
180 s#__DATABASE_USER__#${DATABASE_USER}#g;
181 s#__DATABASE_PASSWORD__#${DATABASE_PASSWORD}#g;
182 s#__DATABASE_INT_IP__#${DATABASE_INT_IP:-}#g;
183 s#__DATABASE_EXTERNAL_SERVICE_HOST_OR_IP__#${DATABASE_EXTERNAL_SERVICE_HOST_OR_IP:-}#g;
184 s#__DATABASE_POSTGRESQL_VERSION__#${DATABASE_POSTGRESQL_VERSION}#g;
185 s#__KEEPWEB_EXT_SSL_PORT__#${KEEPWEB_EXT_SSL_PORT}#g;
186 s#__KEEP_EXT_SSL_PORT__#${KEEP_EXT_SSL_PORT}#g;
187 s#__MANAGEMENT_TOKEN__#${MANAGEMENT_TOKEN}#g;
188 s#__RELEASE__#${RELEASE}#g;
189 s#__SYSTEM_ROOT_TOKEN__#${SYSTEM_ROOT_TOKEN}#g;
190 s#__VERSION__#${VERSION}#g;
191 s#__WEBSHELL_EXT_SSL_PORT__#${WEBSHELL_EXT_SSL_PORT}#g;
192 s#__WEBSOCKET_EXT_SSL_PORT__#${WEBSOCKET_EXT_SSL_PORT}#g;
193 s#__WORKBENCH1_EXT_SSL_PORT__#${WORKBENCH1_EXT_SSL_PORT}#g;
194 s#__WORKBENCH2_EXT_SSL_PORT__#${WORKBENCH2_EXT_SSL_PORT}#g;
195 s#__CLUSTER_INT_CIDR__#${CLUSTER_INT_CIDR}#g;
196 s#__CONTROLLER_INT_IP__#${CONTROLLER_INT_IP}#g;
197 s#__WEBSOCKET_INT_IP__#${WEBSOCKET_INT_IP}#g;
198 s#__KEEP_INT_IP__#${KEEP_INT_IP}#g;
199 s#__KEEPSTORE0_INT_IP__#${KEEPSTORE0_INT_IP}#g;
200 s#__KEEPWEB_INT_IP__#${KEEPWEB_INT_IP}#g;
201 s#__WEBSHELL_INT_IP__#${WEBSHELL_INT_IP}#g;
202 s#__SHELL_INT_IP__#${SHELL_INT_IP}#g;
203 s#__WORKBENCH1_INT_IP__#${WORKBENCH1_INT_IP}#g;
204 s#__WORKBENCH2_INT_IP__#${WORKBENCH2_INT_IP}#g;
205 s#__SSL_KEY_ENCRYPTED__#${SSL_KEY_ENCRYPTED}#g;
206 s#__SSL_KEY_AWS_REGION__#${SSL_KEY_AWS_REGION:-}#g;
207 s#__SSL_KEY_AWS_SECRET_NAME__#${SSL_KEY_AWS_SECRET_NAME}#g;
208 s#__CONTROLLER_MAX_WORKERS__#${CONTROLLER_MAX_WORKERS:-}#g;
209 s#__CONTROLLER_MAX_QUEUED_REQUESTS__#${CONTROLLER_MAX_QUEUED_REQUESTS:-128}#g;
210 s#__CONTROLLER_MAX_GATEWAY_TUNNELS__#${CONTROLLER_MAX_GATEWAY_TUNNELS:-1000}#g;
211 s#__MONITORING_USERNAME__#${MONITORING_USERNAME}#g;
212 s#__MONITORING_EMAIL__#${MONITORING_EMAIL}#g;
213 s#__MONITORING_PASSWORD__#${MONITORING_PASSWORD}#g;
214 s#__DISPATCHER_SSH_PRIVKEY__#${DISPATCHER_SSH_PRIVKEY//$'\n'/\\n}#g;
215 s#__ENABLE_BALANCER__#${ENABLE_BALANCER}#g;
216 s#__DISABLED_CONTROLLER__#${DISABLED_CONTROLLER}#g;
217 s#__BALANCER_NODENAME__#${ROLE2NODES['balancer']:-}#g;
218 s#__PROMETHEUS_NODENAME__#${ROLE2NODES['monitoring']:-}#g;
219 s#__PROMETHEUS_DATA_RETENTION_TIME__#${PROMETHEUS_DATA_RETENTION_TIME:-15d}#g;
220 s#__LOKI_AWS_S3_ACCESS_KEY_ID__#${LOKI_AWS_S3_ACCESS_KEY_ID:-}#g;
221 s#__LOKI_AWS_S3_SECRET_ACCESS_KEY__#${LOKI_AWS_S3_SECRET_ACCESS_KEY:-}#g;
222 s#__LOKI_AWS_S3_BUCKET__#${LOKI_AWS_S3_BUCKET:-}#g;
223 s#__LOKI_LOG_RETENTION_TIME__#${LOKI_LOG_RETENTION_TIME:-15d}#g;
224 s#__LOKI_AWS_REGION__#${LOKI_AWS_REGION:-}#g;
225 s#__CONTROLLER_NODES__#${ROLE2NODES['controller']:-}#g;
226 s#__NODELIST__#${NODELIST}#g;
227 s#__DISPATCHER_INT_IP__#${DISPATCHER_INT_IP}#g;
228 s#__KEEPBALANCE_INT_IP__#${KEEPBALANCE_INT_IP}#g;
229 s#__COMPUTE_AMI__#${COMPUTE_AMI:-}#g;
230 s#__COMPUTE_SG__#${COMPUTE_SG:-}#g;
231 s#__COMPUTE_SUBNET__#${COMPUTE_SUBNET:-}#g;
232 s#__COMPUTE_AWS_REGION__#${COMPUTE_AWS_REGION:-}#g;
233 s#__COMPUTE_USER__#${COMPUTE_USER:-}#g;
234 s#__KEEP_AWS_S3_BUCKET__#${KEEP_AWS_S3_BUCKET:-}#g;
235 s#__KEEP_AWS_IAM_ROLE__#${KEEP_AWS_IAM_ROLE:-}#g;
236 s#__KEEP_AWS_REGION__#${KEEP_AWS_REGION:-}#g" \
237 "${SRCFILE}" > "${DSTFILE}"
241 CONFIG_FILE="${SCRIPT_DIR}/local.params"
242 CONFIG_DIR="local_config_dir"
245 CONTROLLER_EXT_SSL_PORT=443
248 NGINX_INSTALL_SOURCE="install_from_repo"
253 # Hostnames/IPs used for single-host deploys
258 INITIAL_USER_EMAIL=""
259 INITIAL_USER_PASSWORD=""
261 CONTROLLER_EXT_SSL_PORT=8000
262 KEEP_EXT_SSL_PORT=25101
263 # Both for collections and downloads
264 KEEPWEB_EXT_SSL_PORT=9002
265 WEBSHELL_EXT_SSL_PORT=4202
266 WEBSOCKET_EXT_SSL_PORT=8002
267 WORKBENCH1_EXT_SSL_PORT=443
268 WORKBENCH2_EXT_SSL_PORT=3001
270 SSL_MODE="self-signed"
271 USE_LETSENCRYPT_ROUTE53="no"
272 CUSTOM_CERTS_DIR="${SCRIPT_DIR}/local_config_dir/certs"
274 GRAFANA_DASHBOARDS_DIR="${SCRIPT_DIR}/local_config_dir/dashboards"
276 ## These are ARVADOS-related parameters
277 # For a stable release, change RELEASE "production" and VERSION to the
278 # package version (including the iteration, e.g. X.Y.Z-1) of the
280 # The "local.params.example.*" files already set "RELEASE=production"
281 # to deploy production-ready packages
282 RELEASE="development"
285 # We pin the salt version to avoid potential incompatibilities when a new
286 # stable version is released.
289 # Other formula versions we depend on
290 ARVADOS_TAG="eed69116c1bcaf46474b7ff7c93383eb855695b4"
291 POSTGRES_TAG="a809e03bad115bbdf24ad347e2dc9a52e144c31f"
292 POSTGRES_URL="https://github.com/arvados/postgres-formula.git"
296 LETSENCRYPT_TAG="v3.2.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 # Read the variables of /etc/os-release but prefix their names with `_OS_`
365 # to avoid name conflicts.
366 eval "$(awk '(/^[A-Z_]+=/) { print "_OS_" $0 }' /etc/os-release)"
367 echo "Detected distro families: ${_OS_ID:-} ${_OS_ID_LIKE:-}"
369 # Several of our formulas use the cron module, which requires the crontab
370 # command. We install systemd-cron to ensure we have that.
371 # The rest of these packages are required by the rest of the script.
372 for OS_ID in ${_OS_ID:-} ${_OS_ID_LIKE:-}; do
375 echo "WARNING! Disabling SELinux, see https://dev.arvados.org/issues/18019"
376 sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/sysconfig/selinux
377 setenforce permissive
378 yum install -y curl git jq systemd-cron
379 if command -v salt-call >/dev/null; then
380 echo "Salt already installed"
383 curl -L https://bootstrap.saltstack.com -o /tmp/bootstrap_salt.sh
384 sh /tmp/bootstrap_salt.sh -XdfP -x python3 stable ${SALT_VERSION}
388 DEBIAN_FRONTEND=noninteractive apt-get -o DPkg::Lock::Timeout=120 update
389 # This list includes our own dependencies, plus depdencies necessary
390 # to retrieve the Salt apt repository.
391 DEBIAN_FRONTEND=noninteractive apt-get install -y \
392 apt-transport-https ca-certificates curl git gnupg jq systemd-cron
393 if command -v salt-call >/dev/null; then
394 echo "Salt already installed"
397 salt_apt_key=/etc/apt/keyrings/SALT-PROJECT-GPG-PUBKEY-2023.asc
398 install -d -m 755 /etc/apt/keyrings /etc/apt/preferences.d
399 curl -fsSL -o "$salt_apt_key" \
400 "https://packages.broadcom.com/artifactory/api/security/keypair/SaltProjectKey/public"
401 chmod go+r "$salt_apt_key"
402 install -b -m 644 /dev/stdin "/etc/apt/preferences.d/salt.pref" <<EOFPREFS
403 Explanation: Salt $SALT_VERSION has been tested to successfully install Arvados.
405 Pin: version $SALT_VERSION.*
408 install -b -m 644 /dev/stdin "/etc/apt/sources.list.d/salt.sources" <<EOFSOURCES
410 URIs: https://packages.broadcom.com/artifactory/saltproject-deb/
414 Signed-by: $salt_apt_key
416 DEBIAN_FRONTEND=noninteractive apt-get -o DPkg::Lock::Timeout=120 update
417 DEBIAN_FRONTEND=noninteractive apt-get install -y salt-minion
423 # Set salt to masterless mode
424 systemctl disable --now salt-minion.service
425 cat > /etc/salt/minion << EOFSM
440 mkdir -p ${S_DIR} ${F_DIR} ${P_DIR} ${T_DIR}
442 # Get the formula and dependencies
443 cd ${F_DIR} || exit 1
444 echo "Cloning formulas"
445 test -d docker && ( cd docker && git fetch ) \
446 || git clone --quiet https://github.com/saltstack-formulas/docker-formula.git ${F_DIR}/docker
447 ( cd docker && git checkout --quiet tags/"${DOCKER_TAG}" )
450 test -d locale && ( cd locale && git fetch ) \
451 || git clone --quiet https://github.com/saltstack-formulas/locale-formula.git ${F_DIR}/locale
452 ( cd locale && git checkout --quiet tags/"${LOCALE_TAG}" )
455 test -d nginx && ( cd nginx && git fetch ) \
456 || git clone --quiet https://github.com/saltstack-formulas/nginx-formula.git ${F_DIR}/nginx
457 ( cd nginx && git checkout --quiet tags/"${NGINX_TAG}" )
460 test -d postgres && ( cd postgres && git fetch ) \
461 || git clone --quiet ${POSTGRES_URL} ${F_DIR}/postgres
462 ( cd postgres && git checkout --quiet "${POSTGRES_TAG}" )
465 test -d prometheus && ( cd prometheus && git fetch ) \
466 || git clone --quiet https://github.com/saltstack-formulas/prometheus-formula.git ${F_DIR}/prometheus
467 ( cd prometheus && git checkout --quiet tags/"${PROMETHEUS_TAG}" )
470 test -d grafana && ( cd grafana && git fetch ) \
471 || git clone --quiet https://github.com/saltstack-formulas/grafana-formula.git ${F_DIR}/grafana
472 ( cd grafana && git checkout --quiet "${GRAFANA_TAG}" )
474 echo "...letsencrypt"
475 test -d letsencrypt && ( cd letsencrypt && git fetch ) \
476 || git clone --quiet https://github.com/saltstack-formulas/letsencrypt-formula.git ${F_DIR}/letsencrypt
477 ( cd letsencrypt && git checkout --quiet tags/"${LETSENCRYPT_TAG}" )
480 test -d logrotate && ( cd logrotate && git fetch ) \
481 || git clone --quiet https://github.com/saltstack-formulas/logrotate-formula.git ${F_DIR}/logrotate
482 ( cd logrotate && git checkout --quiet tags/"${LOGROTATE_TAG}" )
485 test -d arvados && ( cd arvados && git fetch ) \
486 || git clone --quiet https://git.arvados.org/arvados-formula.git ${F_DIR}/arvados
487 ( cd arvados && git checkout --quiet "${ARVADOS_TAG}" )
489 if [ "x${VAGRANT:-}" = "xyes" ]; then
490 EXTRA_STATES_DIR="/home/vagrant/${CONFIG_DIR}/states"
491 SOURCE_PILLARS_DIR="/home/vagrant/${CONFIG_DIR}/pillars"
492 SOURCE_TOFS_DIR="/home/vagrant/${CONFIG_DIR}/tofs"
493 SOURCE_TESTS_DIR="/home/vagrant/${TESTS_DIR}"
495 EXTRA_STATES_DIR="${SCRIPT_DIR}/${CONFIG_DIR}/states"
496 SOURCE_PILLARS_DIR="${SCRIPT_DIR}/${CONFIG_DIR}/pillars"
497 SOURCE_TOFS_DIR="${SCRIPT_DIR}/${CONFIG_DIR}/tofs"
498 SOURCE_TESTS_DIR="${SCRIPT_DIR}/${TESTS_DIR}"
501 SOURCE_STATES_DIR="${EXTRA_STATES_DIR}"
503 echo "Writing pillars and states"
505 # Replace variables (cluster, domain, etc) in the pillars, states and tests
506 # to ease deployment for newcomers
507 if [ ! -d "${SOURCE_PILLARS_DIR}" ]; then
508 echo "${SOURCE_PILLARS_DIR} does not exist or is not a directory. Exiting."
511 for f in $(ls "${SOURCE_PILLARS_DIR}"/*); do
512 apply_var_substitutions "${f}" "${P_DIR}"/$(basename "${f}")
515 if [ ! -d "${SOURCE_TESTS_DIR}" ]; then
516 echo "WARNING: The tests directory was not copied to \"${SOURCE_TESTS_DIR}\"."
517 if [ "x${TEST:-}" = "xyes" ]; then
518 echo "WARNING: Disabling tests for this installation."
523 # Replace cluster and domain name in the test files
524 for f in $(ls "${SOURCE_TESTS_DIR}"/*); do
525 FILTERS="s#__CLUSTER__#${CLUSTER}#g;
526 s#__CONTROLLER_EXT_SSL_PORT__#${CONTROLLER_EXT_SSL_PORT}#g;
527 s#__DOMAIN__#${DOMAIN}#g;
528 s#__IP_INT__#${IP_INT}#g;
529 s#__INITIAL_USER_EMAIL__#${INITIAL_USER_EMAIL}#g;
530 s#__INITIAL_USER_PASSWORD__#${INITIAL_USER_PASSWORD}#g
531 s#__INITIAL_USER__#${INITIAL_USER}#g;
532 s#__DATABASE_PASSWORD__#${DATABASE_PASSWORD}#g;
533 s#__SYSTEM_ROOT_TOKEN__#${SYSTEM_ROOT_TOKEN}#g"
534 if [ "$USE_SINGLE_HOSTNAME" = "yes" ]; then
535 FILTERS="s#__CLUSTER__.__DOMAIN__#${HOSTNAME_EXT}#g;
539 "${f}" > ${T_DIR}/$(basename "${f}")
541 chmod 755 ${T_DIR}/run-test.sh
544 # Replace helper state files that differ from the formula's examples
545 if [ -d "${SOURCE_STATES_DIR}" ]; then
546 mkdir -p "${F_DIR}"/extra/extra
547 rm -rf "${F_DIR}"/extra/extra/*
549 for f in $(ls "${SOURCE_STATES_DIR}"/*); do
550 apply_var_substitutions "${f}" "${F_DIR}/extra/extra"/$(basename "${f}")
554 # Now, we build the SALT states/pillars trees
555 # As we need to separate both states and pillars in case we want specific
556 # roles, we iterate on both at the same time
558 # Formula template overrides (TOFS)
559 # See: https://template-formula.readthedocs.io/en/latest/TOFS_pattern.html#template-override
560 if [ -d ${SOURCE_TOFS_DIR} ]; then
561 find ${SOURCE_TOFS_DIR} -mindepth 1 -maxdepth 1 -type d -exec cp -r "{}" ${S_DIR} \;
565 cat > ${STATES_TOP} << EOFTSLS
572 cat > ${PILLARS_TOP} << EOFPSLS
579 # States, extra states
580 if [ -d "${F_DIR}"/extra/extra ]; then
581 SKIP_SNAKE_OIL="snakeoil_certs"
583 if [[ "$DEV_MODE" = "yes" || "${SSL_MODE}" == "self-signed" ]] ; then
584 # In dev mode, we create some snake oil certs that we'll
585 # use as CUSTOM_CERTS, so we don't skip the states file.
586 # Same when using self-signed certificates.
587 SKIP_SNAKE_OIL="dont_add_snakeoil_certs"
589 for f in $(ls "${F_DIR}"/extra/extra/*.sls | egrep -v "${SKIP_SNAKE_OIL}|shell_"); do
590 echo " - extra.$(basename ${f} | sed 's/.sls$//g')" >> ${STATES_TOP}
592 # Use byo or self-signed certificates
593 if [ "${SSL_MODE}" != "lets-encrypt" ]; then
594 mkdir -p "${F_DIR}"/extra/extra/files
598 # If we want specific roles for a node, just add the desired states
599 # and its dependencies
600 if [ -z "${ROLES:-}" ]; then
602 echo " - nginx.passenger" >> ${STATES_TOP}
603 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
604 if [ "${USE_LETSENCRYPT_ROUTE53}" = "yes" ]; then
605 grep -q "aws_credentials" ${STATES_TOP} || echo " - extra.aws_credentials" >> ${STATES_TOP}
607 grep -q "letsencrypt" ${STATES_TOP} || echo " - letsencrypt" >> ${STATES_TOP}
609 mkdir -p --mode=0700 /srv/salt/certs
610 if [ "${SSL_MODE}" = "bring-your-own" ]; then
611 # Copy certs to formula extra/files
612 install --mode=0600 ${CUSTOM_CERTS_DIR}/* /srv/salt/certs/
613 # We add the custom_certs state
614 grep -q "custom_certs" ${STATES_TOP} || echo " - extra.custom_certs" >> ${STATES_TOP}
615 if [ "${SSL_KEY_ENCRYPTED}" = "yes" ]; then
616 grep -q "ssl_key_encrypted" ${STATES_TOP} || echo " - extra.ssl_key_encrypted" >> ${STATES_TOP}
619 # In self-signed mode, the certificate files will be created and put in the
620 # destination directory by the snakeoil_certs.sls state file
623 echo " - postgres" >> ${STATES_TOP}
624 echo " - logrotate" >> ${STATES_TOP}
625 echo " - docker.software" >> ${STATES_TOP}
626 echo " - arvados.repo" >> ${STATES_TOP}
627 echo " - arvados.config" >> ${STATES_TOP}
628 echo " - arvados.ruby" >> ${STATES_TOP}
629 echo " - arvados.api" >> ${STATES_TOP}
630 echo " - arvados.controller" >> ${STATES_TOP}
631 echo " - arvados.keepstore" >> ${STATES_TOP}
632 echo " - arvados.websocket" >> ${STATES_TOP}
633 echo " - arvados.keepweb" >> ${STATES_TOP}
634 echo " - arvados.workbench2" >> ${STATES_TOP}
635 echo " - arvados.keepproxy" >> ${STATES_TOP}
636 echo " - arvados.shell" >> ${STATES_TOP}
637 echo " - arvados.dispatcher" >> ${STATES_TOP}
638 echo " - extra.shell_sudo_passwordless" >> ${STATES_TOP}
639 echo " - extra.shell_cron_add_login_sync" >> ${STATES_TOP}
640 echo " - extra.passenger_rvm" >> ${STATES_TOP}
641 echo " - extra.workbench1_uninstall" >> ${STATES_TOP}
644 echo " - docker" >> ${PILLARS_TOP}
645 echo " - nginx_api_configuration" >> ${PILLARS_TOP}
646 echo " - logrotate" >> ${PILLARS_TOP}
647 echo " - logrotate_api" >> ${PILLARS_TOP}
648 echo " - nginx_controller_configuration" >> ${PILLARS_TOP}
649 echo " - nginx_keepproxy_configuration" >> ${PILLARS_TOP}
650 echo " - nginx_keepweb_configuration" >> ${PILLARS_TOP}
651 echo " - nginx_passenger" >> ${PILLARS_TOP}
652 echo " - nginx_websocket_configuration" >> ${PILLARS_TOP}
653 echo " - nginx_webshell_configuration" >> ${PILLARS_TOP}
654 echo " - nginx_workbench2_configuration" >> ${PILLARS_TOP}
655 echo " - nginx_workbench_configuration" >> ${PILLARS_TOP}
656 echo " - logrotate_wb1" >> ${PILLARS_TOP}
657 echo " - postgresql" >> ${PILLARS_TOP}
659 # We need to tweak the Nginx's pillar depending whether we want plan nginx or nginx+passenger
660 NGINX_INSTALL_SOURCE="install_from_phusionpassenger"
661 sed -i "s/__NGINX_INSTALL_SOURCE__/${NGINX_INSTALL_SOURCE}/g" ${P_DIR}/nginx_passenger.sls
663 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
664 if [ "${USE_LETSENCRYPT_ROUTE53}" = "yes" ]; then
665 grep -q "aws_credentials" ${PILLARS_TOP} || echo " - aws_credentials" >> ${PILLARS_TOP}
667 grep -q "letsencrypt" ${PILLARS_TOP} || echo " - letsencrypt" >> ${PILLARS_TOP}
669 hosts=("controller" "websocket" "workbench" "workbench2" "webshell" "keepproxy")
670 if [ ${USE_SINGLE_HOSTNAME} = "no" ]; then
671 hosts+=("download" "collections")
676 for c in "${hosts[@]}"; do
677 # Are we in a single-host-single-hostname env?
678 if [ "${USE_SINGLE_HOSTNAME}" = "yes" ]; then
679 # Are we in a single-host-single-hostname env?
680 CERT_NAME=${HOSTNAME_EXT}
682 # We are in a multiple-hostnames env
683 CERT_NAME=${c}.${DOMAIN}
686 # As the pillar differs whether we use LE or custom certs, we need to do a final edition on them
687 sed -i "s/__CERT_REQUIRES__/cmd: create-initial-cert-${CERT_NAME}*/g;
688 s#__CERT_PEM__#/etc/letsencrypt/live/${CERT_NAME}/fullchain.pem#g;
689 s#__CERT_KEY__#/etc/letsencrypt/live/${CERT_NAME}/privkey.pem#g" \
690 ${P_DIR}/nginx_${c}_configuration.sls
693 # Use custom certs (either dev mode or prod)
694 grep -q "extra_custom_certs" ${PILLARS_TOP} || echo " - extra_custom_certs" >> ${PILLARS_TOP}
695 # And add the certs in the custom_certs pillar
696 echo "extra_custom_certs_dir: /srv/salt/certs" > ${P_DIR}/extra_custom_certs.sls
697 echo "extra_custom_certs:" >> ${P_DIR}/extra_custom_certs.sls
699 for c in controller websocket workbench workbench2 webshell keepweb keepproxy; do
700 # Are we in a single-host-single-hostname env?
701 if [ "${USE_SINGLE_HOSTNAME}" = "yes" ]; then
702 # Are we in a single-host-single-hostname env?
703 CERT_NAME=${HOSTNAME_EXT}
705 # We are in a multiple-hostnames env
709 if [[ "$SSL_MODE" == "bring-your-own" ]]; then
710 copy_custom_cert ${CUSTOM_CERTS_DIR} ${CERT_NAME}
713 grep -q ${CERT_NAME} ${P_DIR}/extra_custom_certs.sls || echo " - ${CERT_NAME}" >> ${P_DIR}/extra_custom_certs.sls
715 # As the pillar differs whether we use LE or custom certs, we need to do a final edition on them
716 sed -i "s/__CERT_REQUIRES__/file: extra_custom_certs_${CERT_NAME}_cert_file_copy/g;
717 s#__CERT_PEM__#/etc/nginx/ssl/arvados-${CERT_NAME}.pem#g;
718 s#__CERT_KEY__#/etc/nginx/ssl/arvados-${CERT_NAME}.key#g" \
719 ${P_DIR}/nginx_${c}_configuration.sls
723 # If we add individual roles, make sure we add the repo first
724 echo " - arvados.repo" >> ${STATES_TOP}
725 # We add the extra_custom_certs state
726 grep -q "extra.custom_certs" ${STATES_TOP} || echo " - extra.custom_certs" >> ${STATES_TOP}
727 if [ "${SSL_KEY_ENCRYPTED}" = "yes" ]; then
728 grep -q "ssl_key_encrypted" ${STATES_TOP} || echo " - extra.ssl_key_encrypted" >> ${STATES_TOP}
731 # And we add the basic part for the certs pillar
732 if [ "${SSL_MODE}" != "lets-encrypt" ]; then
733 # And add the certs in the custom_certs pillar
734 echo "extra_custom_certs_dir: /srv/salt/certs" > ${P_DIR}/extra_custom_certs.sls
735 echo "extra_custom_certs:" >> ${P_DIR}/extra_custom_certs.sls
736 grep -q "extra_custom_certs" ${PILLARS_TOP} || echo " - extra_custom_certs" >> ${PILLARS_TOP}
739 # Prometheus state on all nodes due to the node exporter below
740 grep -q "\- prometheus$" ${STATES_TOP} || echo " - prometheus" >> ${STATES_TOP}
741 # Prometheus node exporter pillar
742 grep -q "prometheus_node_exporter" ${PILLARS_TOP} || echo " - prometheus_node_exporter" >> ${PILLARS_TOP}
743 # Grafana Alloy OpenTelemetry client state & pillar on all nodes
744 grep -q "extra.alloy_install" ${STATES_TOP} || echo " - extra.alloy_install" >> ${STATES_TOP}
745 grep -q "alloy" ${PILLARS_TOP} || echo " - alloy" >> ${PILLARS_TOP}
747 for R in ${ROLES:-}; do
750 # Skip if using an external service
751 if [[ "${DATABASE_EXTERNAL_SERVICE_HOST_OR_IP:-}" != "" ]]; then
755 grep -q "\- postgres$" ${STATES_TOP} || echo " - postgres" >> ${STATES_TOP}
756 grep -q "extra.prometheus_pg_exporter" ${STATES_TOP} || echo " - extra.prometheus_pg_exporter" >> ${STATES_TOP}
758 grep -q "postgresql" ${PILLARS_TOP} || echo " - postgresql" >> ${PILLARS_TOP}
759 grep -q "prometheus_pg_exporter" ${PILLARS_TOP} || echo " - prometheus_pg_exporter" >> ${PILLARS_TOP}
762 ### Support files ###
763 GRAFANA_DASHBOARDS_DEST_DIR=/srv/salt/dashboards
764 mkdir -p "${GRAFANA_DASHBOARDS_DEST_DIR}"
765 rm -f "${GRAFANA_DASHBOARDS_DEST_DIR}"/*
766 # "ArvadosPromDataSource" is the hardcoded UID for Prometheus' datasource
768 # "ArvadosLokiDataSource" if Loki's UID in Grafana
769 for f in $(ls "${GRAFANA_DASHBOARDS_DIR}"/*.json); do
770 sed "s#__TLS_EXPIRATION_YELLOW__#${TLS_EXPIRATION_YELLOW}#g;
771 s#__TLS_EXPIRATION_GREEN__#${TLS_EXPIRATION_GREEN}#g;
772 s#\${DS_PROMETHEUS}#ArvadosPromDataSource#g;
773 s#\${DS_LOKI}#ArvadosLokiDataSource#g" \
774 "${f}" > "${GRAFANA_DASHBOARDS_DEST_DIR}"/$(basename "${f}")
778 grep -q "\- nginx$" ${STATES_TOP} || echo " - nginx" >> ${STATES_TOP}
779 grep -q "extra.nginx_prometheus_configuration" ${STATES_TOP} || echo " - extra.nginx_prometheus_configuration" >> ${STATES_TOP}
781 grep -q "\- grafana$" ${STATES_TOP} || echo " - grafana" >> ${STATES_TOP}
782 grep -q "extra.grafana_datasource" ${STATES_TOP} || echo " - extra.grafana_datasource" >> ${STATES_TOP}
783 grep -q "extra.grafana_dashboards" ${STATES_TOP} || echo " - extra.grafana_dashboards" >> ${STATES_TOP}
784 grep -q "extra.grafana_admin_user" ${STATES_TOP} || echo " - extra.grafana_admin_user" >> ${STATES_TOP}
786 grep -q "extra.loki_install" ${STATES_TOP} || echo " - extra.loki_install" >> ${STATES_TOP}
788 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
789 grep -q "letsencrypt" ${STATES_TOP} || echo " - letsencrypt" >> ${STATES_TOP}
790 if [ "x${USE_LETSENCRYPT_ROUTE53:-}" = "xyes" ]; then
791 grep -q "aws_credentials" ${STATES_TOP} || echo " - aws_credentials" >> ${STATES_TOP}
793 elif [ "${SSL_MODE}" = "bring-your-own" ]; then
794 for SVC in grafana prometheus loki; do
795 copy_custom_cert ${CUSTOM_CERTS_DIR} ${SVC}
799 grep -q "prometheus_server" ${PILLARS_TOP} || echo " - prometheus_server" >> ${PILLARS_TOP}
800 grep -q "grafana" ${PILLARS_TOP} || echo " - grafana" >> ${PILLARS_TOP}
801 grep -q "loki" ${PILLARS_TOP} || echo " - loki" >> ${PILLARS_TOP}
802 for SVC in grafana prometheus loki; do
803 grep -q "nginx_${SVC}_configuration" ${PILLARS_TOP} || echo " - nginx_${SVC}_configuration" >> ${PILLARS_TOP}
805 grep -q "nginx_snippets" ${PILLARS_TOP} || echo " - nginx_snippets" >> ${PILLARS_TOP}
806 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
807 grep -q "letsencrypt" ${PILLARS_TOP} || echo " - letsencrypt" >> ${PILLARS_TOP}
808 for SVC in grafana prometheus loki; do
809 grep -q "letsencrypt_${SVC}_configuration" ${PILLARS_TOP} || echo " - letsencrypt_${SVC}_configuration" >> ${PILLARS_TOP}
810 sed -i "s/__CERT_REQUIRES__/cmd: create-initial-cert-${SVC}.${DOMAIN}*/g;
811 s#__CERT_PEM__#/etc/letsencrypt/live/${SVC}.${DOMAIN}/fullchain.pem#g;
812 s#__CERT_KEY__#/etc/letsencrypt/live/${SVC}.${DOMAIN}/privkey.pem#g" \
813 ${P_DIR}/nginx_${SVC}_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 for SVC in grafana prometheus loki; do
821 sed -i "s/__CERT_REQUIRES__/file: extra_custom_certs_${SVC}_cert_file_copy/g;
822 s#__CERT_PEM__#/etc/nginx/ssl/arvados-${SVC}.pem#g;
823 s#__CERT_KEY__#/etc/nginx/ssl/arvados-${SVC}.key#g" \
824 ${P_DIR}/nginx_${SVC}_configuration.sls
825 grep -q ${SVC} ${P_DIR}/extra_custom_certs.sls || echo " - ${SVC}" >> ${P_DIR}/extra_custom_certs.sls
831 grep -q "\- nginx$" ${STATES_TOP} || echo " - nginx" >> ${STATES_TOP}
833 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
834 grep -q "letsencrypt" ${STATES_TOP} || echo " - letsencrypt" >> ${STATES_TOP}
835 if [ "x${USE_LETSENCRYPT_ROUTE53:-}" = "xyes" ]; then
836 grep -q "aws_credentials" ${STATES_TOP} || echo " - aws_credentials" >> ${STATES_TOP}
838 elif [ "${SSL_MODE}" = "bring-your-own" ]; then
839 copy_custom_cert ${CUSTOM_CERTS_DIR} ${R}
843 grep -q "nginx_${R}_configuration" ${PILLARS_TOP} || echo " - nginx_${R}_configuration" >> ${PILLARS_TOP}
845 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
846 grep -q "letsencrypt" ${PILLARS_TOP} || echo " - letsencrypt" >> ${PILLARS_TOP}
848 grep -q "letsencrypt_${R}_configuration" ${PILLARS_TOP} || echo " - letsencrypt_${R}_configuration" >> ${PILLARS_TOP}
849 sed -i "s/__CERT_REQUIRES__/cmd: create-initial-cert-${ROLE2NODES['balancer']}*/g;
850 s#__CERT_PEM__#/etc/letsencrypt/live/${ROLE2NODES['balancer']}/fullchain.pem#g;
851 s#__CERT_KEY__#/etc/letsencrypt/live/${ROLE2NODES['balancer']}/privkey.pem#g" \
852 ${P_DIR}/nginx_${R}_configuration.sls
854 if [ "${USE_LETSENCRYPT_ROUTE53}" = "yes" ]; then
855 grep -q "aws_credentials" ${PILLARS_TOP} || echo " - aws_credentials" >> ${PILLARS_TOP}
857 elif [ "${SSL_MODE}" = "bring-your-own" ]; then
858 grep -q "ssl_key_encrypted" ${PILLARS_TOP} || echo " - ssl_key_encrypted" >> ${PILLARS_TOP}
859 sed -i "s/__CERT_REQUIRES__/file: extra_custom_certs_${R}_cert_file_copy/g;
860 s#__CERT_PEM__#/etc/nginx/ssl/arvados-${R}.pem#g;
861 s#__CERT_KEY__#/etc/nginx/ssl/arvados-${R}.key#g" \
862 ${P_DIR}/nginx_${R}_configuration.sls
863 grep -q "${R}" ${P_DIR}/extra_custom_certs.sls || echo " - ${R}" >> ${P_DIR}/extra_custom_certs.sls
868 grep -q " - logrotate" ${STATES_TOP} || echo " - logrotate" >> ${STATES_TOP}
869 if grep -q " - nginx.*$" ${STATES_TOP}; then
870 sed -i s/"^ - nginx.*$"/" - nginx.passenger"/g ${STATES_TOP}
872 echo " - nginx.passenger" >> ${STATES_TOP}
874 echo " - extra.passenger_rvm" >> ${STATES_TOP}
875 grep -q "^ - postgres\\.client$" ${STATES_TOP} || echo " - postgres.client" >> ${STATES_TOP}
876 if [[ "${DATABASE_EXTERNAL_SERVICE_HOST_OR_IP:-}" != "" ]]; then
877 grep -q " - extra.postgresql_external" ${STATES_TOP} || echo " - extra.postgresql_external" >> ${STATES_TOP}
880 ### If we don't install and run LE before arvados-api-server, it fails and breaks everything
881 ### after it. So we add this here as we are, after all, sharing the host for api and controller
882 if [ "${ENABLE_BALANCER}" == "no" ]; then
883 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
884 if [ "x${USE_LETSENCRYPT_ROUTE53:-}" = "xyes" ]; then
885 grep -q "aws_credentials" ${STATES_TOP} || echo " - aws_credentials" >> ${STATES_TOP}
887 grep -q "letsencrypt" ${STATES_TOP} || echo " - letsencrypt" >> ${STATES_TOP}
888 elif [ "${SSL_MODE}" = "bring-your-own" ]; then
889 copy_custom_cert ${CUSTOM_CERTS_DIR} ${R}
890 grep -q controller ${P_DIR}/extra_custom_certs.sls || echo " - controller" >> ${P_DIR}/extra_custom_certs.sls
893 grep -q "arvados.api" ${STATES_TOP} || echo " - arvados.api" >> ${STATES_TOP}
894 grep -q "arvados.controller" ${STATES_TOP} || echo " - arvados.controller" >> ${STATES_TOP}
897 grep -q "logrotate" ${PILLARS_TOP} || echo " - logrotate" >> ${PILLARS_TOP}
898 grep -q "logrotate_api" ${PILLARS_TOP} || echo " - logrotate_api" >> ${PILLARS_TOP}
899 grep -q "aws_credentials" ${PILLARS_TOP} || echo " - aws_credentials" >> ${PILLARS_TOP}
900 grep -q "postgresql" ${PILLARS_TOP} || echo " - postgresql" >> ${PILLARS_TOP}
901 grep -q "nginx_passenger" ${PILLARS_TOP} || echo " - nginx_passenger" >> ${PILLARS_TOP}
902 grep -q "nginx_snippets" ${PILLARS_TOP} || echo " - nginx_snippets" >> ${PILLARS_TOP}
903 grep -q "nginx_api_configuration" ${PILLARS_TOP} || echo " - nginx_api_configuration" >> ${PILLARS_TOP}
904 grep -q "nginx_controller_configuration" ${PILLARS_TOP} || echo " - nginx_controller_configuration" >> ${PILLARS_TOP}
906 if [[ "${DATABASE_EXTERNAL_SERVICE_HOST_OR_IP:-}" != "" ]]; then
907 grep -q " - postgresql_external" ${PILLARS_TOP} || echo " - postgresql_external" >> ${PILLARS_TOP}
910 if [ "${ENABLE_BALANCER}" == "no" ]; then
911 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
912 if [ "${USE_LETSENCRYPT_ROUTE53}" = "yes" ]; then
913 grep -q "aws_credentials" ${PILLARS_TOP} || echo " - aws_credentials" >> ${PILLARS_TOP}
916 grep -q "letsencrypt" ${PILLARS_TOP} || echo " - letsencrypt" >> ${PILLARS_TOP}
917 grep -q "letsencrypt_${R}_configuration" ${PILLARS_TOP} || echo " - letsencrypt_${R}_configuration" >> ${PILLARS_TOP}
918 sed -i "s/__CERT_REQUIRES__/cmd: create-initial-cert-${R}.${DOMAIN}*/g;
919 s#__CERT_PEM__#/etc/letsencrypt/live/${R}.${DOMAIN}/fullchain.pem#g;
920 s#__CERT_KEY__#/etc/letsencrypt/live/${R}.${DOMAIN}/privkey.pem#g" \
921 ${P_DIR}/nginx_${R}_configuration.sls
923 grep -q "ssl_key_encrypted" ${PILLARS_TOP} || echo " - ssl_key_encrypted" >> ${PILLARS_TOP}
924 sed -i "s/__CERT_REQUIRES__/file: extra_custom_certs_${R}_cert_file_copy/g;
925 s#__CERT_PEM__#/etc/nginx/ssl/arvados-${R}.pem#g;
926 s#__CERT_KEY__#/etc/nginx/ssl/arvados-${R}.key#g" \
927 ${P_DIR}/nginx_${R}_configuration.sls
928 grep -q ${R} ${P_DIR}/extra_custom_certs.sls || echo " - ${R}" >> ${P_DIR}/extra_custom_certs.sls
931 # We need to tweak the Nginx's pillar depending whether we want plain nginx or nginx+passenger
932 NGINX_INSTALL_SOURCE="install_from_phusionpassenger"
933 sed -i "s/__NGINX_INSTALL_SOURCE__/${NGINX_INSTALL_SOURCE}/g" ${P_DIR}/nginx_passenger.sls
935 "websocket" | "workbench" | "workbench2" | "webshell" | "keepweb" | "keepproxy")
937 grep -q "\- nginx$" ${STATES_TOP} || echo " - nginx" >> ${STATES_TOP}
939 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
940 if [ "x${USE_LETSENCRYPT_ROUTE53:-}" = "xyes" ]; then
941 grep -q "aws_credentials" ${STATES_TOP} || echo " - aws_credentials" >> ${STATES_TOP}
943 grep -q "letsencrypt" ${STATES_TOP} || echo " - letsencrypt" >> ${STATES_TOP}
945 # Use custom certs, special case for keepweb
946 if [ ${R} = "keepweb" ]; then
947 if [ "${SSL_MODE}" = "bring-your-own" ]; then
948 copy_custom_cert ${CUSTOM_CERTS_DIR} download
949 copy_custom_cert ${CUSTOM_CERTS_DIR} collections
952 if [ "${SSL_MODE}" = "bring-your-own" ]; then
953 copy_custom_cert ${CUSTOM_CERTS_DIR} ${R}
958 # webshell role is just a nginx vhost, so it has no state
959 # workbench role is deprecated since 2.7.0
960 if [[ "${R}" != "webshell" && "${R}" != "workbench" ]]; then
961 grep -q "arvados.${R}" ${STATES_TOP} || echo " - arvados.${R}" >> ${STATES_TOP}
963 # Make sure wb1's package get uninstalled
964 if [[ "${R}" == "workbench" ]]; then
965 grep -q "workbench1_uninstall" ${STATES_TOP} || echo " - extra.workbench1_uninstall" >> ${STATES_TOP}
969 grep -q "nginx_${R}_configuration" ${PILLARS_TOP} || echo " - nginx_${R}_configuration" >> ${PILLARS_TOP}
970 grep -q "nginx_snippets" ${PILLARS_TOP} || echo " - nginx_snippets" >> ${PILLARS_TOP}
971 # Special case for keepweb
972 if [ ${R} = "keepweb" ]; then
973 grep -q "nginx_download_configuration" ${PILLARS_TOP} || echo " - nginx_download_configuration" >> ${PILLARS_TOP}
974 grep -q "nginx_collections_configuration" ${PILLARS_TOP} || echo " - nginx_collections_configuration" >> ${PILLARS_TOP}
977 if [ "${SSL_MODE}" = "lets-encrypt" ]; then
978 if [ "${USE_LETSENCRYPT_ROUTE53}" = "yes" ]; then
979 grep -q "aws_credentials" ${PILLARS_TOP} || echo " - aws_credentials" >> ${PILLARS_TOP}
981 grep -q "letsencrypt" ${PILLARS_TOP} || echo " - letsencrypt" >> ${PILLARS_TOP}
982 grep -q "letsencrypt_${R}_configuration" ${PILLARS_TOP} || echo " - letsencrypt_${R}_configuration" >> ${PILLARS_TOP}
984 # As the pillar differ whether we use LE or custom certs, we need to do a final edition on them
985 # Special case for keepweb
986 if [ ${R} = "keepweb" ]; then
987 for kwsub in download collections; do
988 sed -i "s/__CERT_REQUIRES__/cmd: create-initial-cert-${kwsub}.${DOMAIN}*/g;
989 s#__CERT_PEM__#/etc/letsencrypt/live/${kwsub}.${DOMAIN}/fullchain.pem#g;
990 s#__CERT_KEY__#/etc/letsencrypt/live/${kwsub}.${DOMAIN}/privkey.pem#g" \
991 ${P_DIR}/nginx_${kwsub}_configuration.sls
994 sed -i "s/__CERT_REQUIRES__/cmd: create-initial-cert-${R}.${DOMAIN}*/g;
995 s#__CERT_PEM__#/etc/letsencrypt/live/${R}.${DOMAIN}/fullchain.pem#g;
996 s#__CERT_KEY__#/etc/letsencrypt/live/${R}.${DOMAIN}/privkey.pem#g" \
997 ${P_DIR}/nginx_${R}_configuration.sls
1000 grep -q "ssl_key_encrypted" ${PILLARS_TOP} || echo " - ssl_key_encrypted" >> ${PILLARS_TOP}
1001 # As the pillar differ whether we use LE or custom certs, we need to do a final edition on them
1002 # Special case for keepweb
1003 if [ ${R} = "keepweb" ]; then
1004 for kwsub in download collections; do
1005 sed -i "s/__CERT_REQUIRES__/file: extra_custom_certs_${kwsub}_cert_file_copy/g;
1006 s#__CERT_PEM__#/etc/nginx/ssl/arvados-${kwsub}.pem#g;
1007 s#__CERT_KEY__#/etc/nginx/ssl/arvados-${kwsub}.key#g" \
1008 ${P_DIR}/nginx_${kwsub}_configuration.sls
1009 grep -q ${kwsub} ${P_DIR}/extra_custom_certs.sls || echo " - ${kwsub}" >> ${P_DIR}/extra_custom_certs.sls
1012 sed -i "s/__CERT_REQUIRES__/file: extra_custom_certs_${R}_cert_file_copy/g;
1013 s#__CERT_PEM__#/etc/nginx/ssl/arvados-${R}.pem#g;
1014 s#__CERT_KEY__#/etc/nginx/ssl/arvados-${R}.key#g" \
1015 ${P_DIR}/nginx_${R}_configuration.sls
1016 grep -q ${R} ${P_DIR}/extra_custom_certs.sls || echo " - ${R}" >> ${P_DIR}/extra_custom_certs.sls
1019 # We need to tweak the Nginx's pillar depending whether we want plain nginx or nginx+passenger
1020 sed -i "s/__NGINX_INSTALL_SOURCE__/${NGINX_INSTALL_SOURCE}/g" ${P_DIR}/nginx_passenger.sls
1024 echo " - extra.shell_sudo_passwordless" >> ${STATES_TOP}
1025 echo " - extra.shell_cron_add_login_sync" >> ${STATES_TOP}
1026 grep -q "docker" ${STATES_TOP} || echo " - docker.software" >> ${STATES_TOP}
1027 grep -q "arvados.${R}" ${STATES_TOP} || echo " - arvados.${R}" >> ${STATES_TOP}
1029 grep -q "docker" ${PILLARS_TOP} || echo " - docker" >> ${PILLARS_TOP}
1031 "dispatcher" | "keepbalance" | "keepstore")
1033 grep -q "arvados.${R}" ${STATES_TOP} || echo " - arvados.${R}" >> ${STATES_TOP}
1035 # ATM, no specific pillar needed
1038 echo "Unknown role ${R}"
1045 if [ "${DUMP_CONFIG}" = "yes" ]; then
1046 # We won't run the rest of the script because we're just dumping the config
1050 # Now run the install
1051 salt-call --state-output=mixed --local state.apply -l ${LOG_LEVEL}
1053 # Finally, make sure that /etc/hosts is not overwritten on reboot
1054 if [ -d /etc/cloud/cloud.cfg.d ]; then
1055 # TODO: will this work on CentOS?
1056 sed -i 's/^manage_etc_hosts: true/#manage_etc_hosts: true/g' /etc/cloud/cloud.cfg.d/*
1059 # Leave a copy of the Arvados CA so the user can copy it where it's required
1060 if [ "${SSL_MODE}" = "self-signed" ]; then
1061 echo "Copying the Arvados CA certificate '${DOMAIN}-arvados-snakeoil-ca.crt' to the installer dir, so you can import it"
1062 if [ "x${VAGRANT:-}" = "xyes" ]; then
1063 cp /etc/ssl/certs/arvados-snakeoil-ca.pem /vagrant/${DOMAIN}-arvados-snakeoil-ca.pem
1065 cp /etc/ssl/certs/arvados-snakeoil-ca.pem ${SCRIPT_DIR}/${DOMAIN}-arvados-snakeoil-ca.crt
1069 if [ "x${VAGRANT:-}" = "xyes" ]; then
1070 # If running in a vagrant VM, also add default user to docker group
1071 echo "Adding the vagrant user to the docker group"
1072 usermod -a -G docker vagrant
1075 # Test that the installation finished correctly
1076 if [ "x${TEST:-}" = "xyes" ]; then