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
15 # capture the directory that the script is running from
16 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
18 CONFIG_DIR="single_host"
22 POSTGRES_TAG="v0.41.3"
27 if [ -s ${SCRIPT_DIR}/local.params ]; then
28 source ${SCRIPT_DIR}/local.params
30 echo >&2 "Please create a '${SCRIPT_DIR}/local.params' file with initial values, as described in FIXME_URL_TO_DESCR"
36 echo >&2 "Usage: ${0} [-h] [-h]"
38 echo >&2 "${0} options:"
39 echo >&2 " -d, --debug Run salt installation in debug mode"
40 echo >&2 " -p <N>, --ssl-port <N> SSL port to use for the web applications"
41 echo >&2 " -t, --test Test installation running a CWL workflow"
42 echo >&2 " -r, --roles List of Arvados roles to apply to the host, comma separated"
43 echo >&2 " Possible values are:"
45 echo >&2 " controller"
49 echo >&2 " workbench2"
53 echo >&2 " dispatcher"
54 echo >&2 " Defaults to applying them all"
55 echo >&2 " -h, --help Display this help and exit"
56 echo >&2 " -v, --vagrant Run in vagrant and use the /vagrant shared dir"
61 # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
62 TEMP=$(getopt -o dhp:r:tv \
63 --long debug,help,ssl-port:,roles:,test,vagrant \
66 if [ ${?} != 0 ] ; then echo "GNU getopt missing? Use -h for help"; exit 1 ; fi
67 # Note the quotes around `$TEMP': they are essential!
70 while [ ${#} -ge 1 ]; do
83 # Verify the role exists
84 if [[ ! "api,controller,keepstore,websocket,keepweb,workbench2,keepproxy,shell,workbench,dispatcher" == *"$i"* ]]; then
85 echo "The role '${i}' is not a valid role"
123 F_DIR="/srv/formulas"
128 apt-get install -y curl git jq
130 dpkg -l |grep salt-minion
131 if [ ${?} -eq 0 ]; then
132 echo "Salt already installed"
134 curl -L https://bootstrap.saltstack.com -o /tmp/bootstrap_salt.sh
135 sh /tmp/bootstrap_salt.sh -XUdfP -x python3
136 /bin/systemctl disable salt-minion.service
139 # Set salt to masterless mode
140 cat > /etc/salt/minion << EOFSM
146 - ${F_DIR}/*/test/salt/states/examples
158 cat > ${S_DIR}/top.sls << EOFTSLS
161 - single_host.host_entries
162 - single_host.snakeoil_certs
169 # If we want specific roles for a node, just add those states
170 if [ -z "${ROLES}" ]; then
171 echo ' - arvados' >> ${S_DIR}/top.sls
173 for R in ${ROLES}; do
174 echo " - arvados.${R}" >> ${S_DIR}/top.sls
179 cat > ${P_DIR}/top.sls << EOFPSLS
185 - nginx_api_configuration
186 - nginx_controller_configuration
187 - nginx_keepproxy_configuration
188 - nginx_keepweb_configuration
190 - nginx_websocket_configuration
191 - nginx_webshell_configuration
192 - nginx_workbench2_configuration
193 - nginx_workbench_configuration
197 # Get the formula and dependencies
198 cd ${F_DIR} || exit 1
199 git clone --branch "${ARVADOS_TAG}" https://github.com/arvados/arvados-formula.git
200 git clone --branch "${DOCKER_TAG}" https://github.com/saltstack-formulas/docker-formula.git
201 git clone --branch "${LOCALE_TAG}" https://github.com/saltstack-formulas/locale-formula.git
202 git clone --branch "${NGINX_TAG}" https://github.com/saltstack-formulas/nginx-formula.git
203 git clone --branch "${POSTGRES_TAG}" https://github.com/saltstack-formulas/postgres-formula.git
205 if [ "x${BRANCH}" != "x" ]; then
206 cd ${F_DIR}/arvados-formula || exit 1
207 git checkout -t origin/"${BRANCH}"
211 if [ "x${VAGRANT}" = "xyes" ]; then
212 SOURCE_PILLARS_DIR="/vagrant/${CONFIG_DIR}"
213 TESTS_DIR="/vagrant/${TESTS_DIR}"
215 SOURCE_PILLARS_DIR="${SCRIPT_DIR}/${CONFIG_DIR}"
216 TESTS_DIR="${SCRIPT_DIR}/${TESTS_DIR}"
219 # Replace cluster and domain name in the example pillars and test files
220 for f in "${SOURCE_PILLARS_DIR}"/*; do
221 sed "s/__CLUSTER__/${CLUSTER}/g;
222 s/__DOMAIN__/${DOMAIN}/g;
223 s/__RELEASE__/${RELEASE}/g;
224 s/__HOST_SSL_PORT__/${HOST_SSL_PORT}/g;
225 s/__GUEST_SSL_PORT__/${GUEST_SSL_PORT}/g;
226 s/__INITIAL_USER__/${INITIAL_USER}/g;
227 s/__INITIAL_USER_EMAIL__/${INITIAL_USER_EMAIL}/g;
228 s/__INITIAL_USER_PASSWORD__/${INITIAL_USER_PASSWORD}/g;
229 s/__VERSION__/${VERSION}/g" \
230 "${f}" > "${P_DIR}"/$(basename "${f}")
233 mkdir -p /tmp/cluster_tests
234 # Replace cluster and domain name in the example pillars and test files
235 for f in "${TESTS_DIR}"/*; do
236 sed "s/__CLUSTER__/${CLUSTER}/g;
237 s/__DOMAIN__/${DOMAIN}/g;
238 s/__HOST_SSL_PORT__/${HOST_SSL_PORT}/g;
239 s/__INITIAL_USER__/${INITIAL_USER}/g;
240 s/__INITIAL_USER_EMAIL__/${INITIAL_USER_EMAIL}/g;
241 s/__INITIAL_USER_PASSWORD__/${INITIAL_USER_PASSWORD}/g" \
242 ${f} > /tmp/cluster_tests/$(basename ${f})
244 chmod 755 /tmp/cluster_tests/run-test.sh
246 # FIXME! #16992 Temporary fix for psql call in arvados-api-server
247 if [ -e /root/.psqlrc ]; then
248 if ! ( grep 'pset pager off' /root/.psqlrc ); then
250 cp /root/.psqlrc /root/.psqlrc.provision.backup
256 echo '\pset pager off' >> /root/.psqlrc
257 # END FIXME! #16992 Temporary fix for psql call in arvados-api-server
259 # Now run the install
260 salt-call --local state.apply -l ${LOG_LEVEL}
262 # FIXME! #16992 Temporary fix for psql call in arvados-api-server
263 if [ "x${DELETE_PSQL}" = "xyes" ]; then
264 echo "Removing .psql file"
268 if [ "x${RESTORE_PSQL}" = "xyes" ]; then
269 echo "Restoring .psql file"
270 mv -v /root/.psqlrc.provision.backup /root/.psqlrc
272 # END FIXME! #16992 Temporary fix for psql call in arvados-api-server
274 # Leave a copy of the Arvados CA so the user can copy it where it's required
275 echo "Copying the Arvados CA certificate to the installer dir, so you can import it"
276 # If running in a vagrant VM, also add default user to docker group
277 if [ "x${VAGRANT}" = "xyes" ]; then
278 cp /etc/ssl/certs/arvados-snakeoil-ca.pem /vagrant
280 echo "Adding the vagrant user to the docker group"
281 usermod -a -G docker vagrant
283 cp /etc/ssl/certs/arvados-snakeoil-ca.pem ${SCRIPT_DIR}
286 # Test that the installation finished correctly
287 if [ "x${TEST}" = "xyes" ]; then
288 cd /tmp/cluster_tests