X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/b287377976ce841cd99d9f8ef1c881722a0dc0b4..117b803d691b10b9ff2181fc2fbc2df23af9e347:/tools/salt-install/provision.sh diff --git a/tools/salt-install/provision.sh b/tools/salt-install/provision.sh index 11acf839e0..91865ef5d5 100755 --- a/tools/salt-install/provision.sh +++ b/tools/salt-install/provision.sh @@ -141,8 +141,19 @@ copy_custom_cert() { cert_name=${2} mkdir -p /srv/salt/certs - cp -v ${cert_dir}/${cert_name}.crt /srv/salt/certs/arvados-${cert_name}.pem - cp -v ${cert_dir}/${cert_name}.key /srv/salt/certs/arvados-${cert_name}.key + + if [ -f ${cert_dir}/${cert_name}.crt ]; then + cp -v ${cert_dir}/${cert_name}.crt /srv/salt/certs/arvados-${cert_name}.pem + else + echo "${cert_dir}/${cert_name}.crt does not exist. Exiting" + exit 1 + fi + if [ -f ${cert_dir}/${cert_name}.key ]; then + cp -v ${cert_dir}/${cert_name}.key /srv/salt/certs/arvados-${cert_name}.key + else + echo "${cert_dir}/${cert_name}.key does not exist. Exiting" + exit 1 + fi } DEV_MODE="no" @@ -174,7 +185,7 @@ WEBSOCKET_EXT_SSL_PORT=8002 WORKBENCH1_EXT_SSL_PORT=443 WORKBENCH2_EXT_SSL_PORT=3001 -USE_LETSENCRYPT="no" +SSL_MODE="self-signed" CUSTOM_CERTS_DIR="${SCRIPT_DIR}/certs" ## These are ARVADOS-related parameters @@ -193,7 +204,7 @@ VERSION="2.3.2-1" BRANCH="2.3-release" # Other formula versions we depend on -POSTGRES_TAG="v0.41.6" +POSTGRES_TAG="v0.43.0" NGINX_TAG="temp-fix-missing-statements-in-pillar" DOCKER_TAG="v2.0.7" LOCALE_TAG="v0.3.4" @@ -467,18 +478,19 @@ EOFPSLS # States, extra states if [ -d "${F_DIR}"/extra/extra ]; then - if [ "$DEV_MODE" = "yes" ]; then + SKIP_SNAKE_OIL="snakeoil_certs" + + if [[ "$DEV_MODE" = "yes" || "${SSL_MODE}" == "self-signed" ]] ; then # In dev mode, we create some snake oil certs that we'll - # use as CUSTOM_CERTS, so we don't skip the states file + # use as CUSTOM_CERTS, so we don't skip the states file. + # Same when using self-signed certificates. SKIP_SNAKE_OIL="dont_snakeoil_certs" - else - SKIP_SNAKE_OIL="snakeoil_certs" fi for f in $(ls "${F_DIR}"/extra/extra/*.sls | grep -v ${SKIP_SNAKE_OIL}); do echo " - extra.$(basename ${f} | sed 's/.sls$//g')" >> ${S_DIR}/top.sls done - # Use custom certs - if [ "x${USE_LETSENCRYPT}" != "xyes" ]; then + # Use byo or self-signed certificates + if [ "${SSL_MODE}" != "lets-encrypt" ]; then mkdir -p "${F_DIR}"/extra/extra/files fi fi @@ -489,8 +501,8 @@ if [ -z "${ROLES}" ]; then # States echo " - nginx.passenger" >> ${S_DIR}/top.sls # Currently, only available on config_examples/multi_host/aws - if [ "x${USE_LETSENCRYPT}" = "xyes" ]; then - if [ "x${USE_LETSENCRYPT_IAM_USER}" != "xyes" ]; then + if [ "${SSL_MODE}" = "lets-encrypt" ]; then + if [ "${USE_LETSENCRYPT_IAM_USER}" != "yes" ]; then grep -q "aws_credentials" ${S_DIR}/top.sls || echo " - extra.aws_credentials" >> ${S_DIR}/top.sls fi grep -q "letsencrypt" ${S_DIR}/top.sls || echo " - letsencrypt" >> ${S_DIR}/top.sls @@ -523,8 +535,8 @@ if [ -z "${ROLES}" ]; then echo " - postgresql" >> ${P_DIR}/top.sls # Currently, only available on config_examples/multi_host/aws - if [ "x${USE_LETSENCRYPT}" = "xyes" ]; then - if [ "x${USE_LETSENCRYPT_IAM_USER}" != "xyes" ]; then + if [ "${SSL_MODE}" = "lets-encrypt" ]; then + if [ "${USE_LETSENCRYPT_IAM_USER}" != "yes" ]; then grep -q "aws_credentials" ${P_DIR}/top.sls || echo " - aws_credentials" >> ${P_DIR}/top.sls fi grep -q "letsencrypt" ${P_DIR}/top.sls || echo " - letsencrypt" >> ${P_DIR}/top.sls @@ -544,6 +556,7 @@ if [ -z "${ROLES}" ]; then echo "extra_custom_certs:" >> ${P_DIR}/extra_custom_certs.sls for c in controller websocket workbench workbench2 webshell download collections keepproxy; do + copy_custom_cert ${CUSTOM_CERTS_DIR} $c grep -q ${c} ${P_DIR}/extra_custom_certs.sls || echo " - ${c}" >> ${P_DIR}/extra_custom_certs.sls # As the pillar differ whether we use LE or custom certs, we need to do a final edition on them @@ -560,7 +573,7 @@ else grep -q "custom_certs" ${S_DIR}/top.sls || echo " - extra.custom_certs" >> ${S_DIR}/top.sls # And we add the basic part for the certs pillar - if [ "x${USE_LETSENCRYPT}" != "xyes" ]; then + if [ "${SSL_MODE}" != "lets-encrypt" ]; then # And add the certs in the custom_certs pillar echo "extra_custom_certs_dir: /srv/salt/certs" > ${P_DIR}/extra_custom_certs.sls echo "extra_custom_certs:" >> ${P_DIR}/extra_custom_certs.sls @@ -583,8 +596,8 @@ else ### If we don't install and run LE before arvados-api-server, it fails and breaks everything ### after it. So we add this here as we are, after all, sharing the host for api and controller # Currently, only available on config_examples/multi_host/aws - if [ "x${USE_LETSENCRYPT}" = "xyes" ]; then - if [ "x${USE_LETSENCRYPT_IAM_USER}" != "xyes" ]; then + if [ "${SSL_MODE}" = "lets-encrypt" ]; then + if [ "${USE_LETSENCRYPT_IAM_USER}" != "yes" ]; then grep -q "aws_credentials" ${S_DIR}/top.sls || echo " - aws_credentials" >> ${S_DIR}/top.sls fi grep -q "letsencrypt" ${S_DIR}/top.sls || echo " - letsencrypt" >> ${S_DIR}/top.sls @@ -596,7 +609,6 @@ else grep -q "arvados.${R}" ${S_DIR}/top.sls || echo " - arvados.${R}" >> ${S_DIR}/top.sls # Pillars grep -q "aws_credentials" ${P_DIR}/top.sls || echo " - aws_credentials" >> ${P_DIR}/top.sls - grep -q "docker" ${P_DIR}/top.sls || echo " - docker" >> ${P_DIR}/top.sls grep -q "postgresql" ${P_DIR}/top.sls || echo " - postgresql" >> ${P_DIR}/top.sls grep -q "nginx_passenger" ${P_DIR}/top.sls || echo " - nginx_passenger" >> ${P_DIR}/top.sls grep -q "nginx_${R}_configuration" ${P_DIR}/top.sls || echo " - nginx_${R}_configuration" >> ${P_DIR}/top.sls @@ -605,7 +617,7 @@ else # States grep -q "nginx.passenger" ${S_DIR}/top.sls || echo " - nginx.passenger" >> ${S_DIR}/top.sls # Currently, only available on config_examples/multi_host/aws - if [ "x${USE_LETSENCRYPT}" = "xyes" ]; then + if [ "${SSL_MODE}" = "lets-encrypt" ]; then if [ "x${USE_LETSENCRYPT_IAM_USER}" != "xyes" ]; then grep -q "aws_credentials" ${S_DIR}/top.sls || echo " - aws_credentials" >> ${S_DIR}/top.sls fi @@ -633,8 +645,8 @@ else fi # Currently, only available on config_examples/multi_host/aws - if [ "x${USE_LETSENCRYPT}" = "xyes" ]; then - if [ "x${USE_LETSENCRYPT_IAM_USER}" != "xyes" ]; then + if [ "${SSL_MODE}" = "lets-encrypt" ]; then + if [ "${USE_LETSENCRYPT_IAM_USER}" != "yes" ]; then grep -q "aws_credentials" ${P_DIR}/top.sls || echo " - aws_credentials" >> ${P_DIR}/top.sls fi grep -q "letsencrypt" ${P_DIR}/top.sls || echo " - letsencrypt" >> ${P_DIR}/top.sls @@ -680,11 +692,10 @@ else grep -q "docker" ${S_DIR}/top.sls || echo " - docker.software" >> ${S_DIR}/top.sls grep -q "arvados.${R}" ${S_DIR}/top.sls || echo " - arvados.${R}" >> ${S_DIR}/top.sls # Pillars - grep -q "" ${P_DIR}/top.sls || echo " - docker" >> ${P_DIR}/top.sls + grep -q "docker" ${P_DIR}/top.sls || echo " - docker" >> ${P_DIR}/top.sls ;; "dispatcher") # States - grep -q "docker" ${S_DIR}/top.sls || echo " - docker.software" >> ${S_DIR}/top.sls grep -q "arvados.${R}" ${S_DIR}/top.sls || echo " - arvados.${R}" >> ${S_DIR}/top.sls # Pillars # ATM, no specific pillar needed