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"
29 echo >&2 "Usage: ${0} [-h] [-h]"
31 echo >&2 "${0} options:"
32 echo >&2 " -d, --debug Run salt installation in debug mode"
33 echo >&2 " -p <N>, --ssl-port <N> SSL port to use for the web applications"
34 echo >&2 " -c <local.params>, --config <local.params> Path to the local.params config file"
35 echo >&2 " -t, --test Test installation running a CWL workflow"
36 echo >&2 " -r, --roles List of Arvados roles to apply to the host, comma separated"
37 echo >&2 " Possible values are:"
39 echo >&2 " controller"
43 echo >&2 " workbench2"
47 echo >&2 " dispatcher"
48 echo >&2 " Defaults to applying them all"
49 echo >&2 " -h, --help Display this help and exit"
50 echo >&2 " -v, --vagrant Run in vagrant and use the /vagrant shared dir"
55 # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
56 TEMP=$(getopt -o c:dhp:r:tv \
57 --long config:,debug,help,ssl-port:,roles:,test,vagrant \
60 if [ ${?} != 0 ] ; then echo "GNU getopt missing? Use -h for help"; exit 1 ; fi
61 # Note the quotes around `$TEMP': they are essential!
64 while [ ${#} -ge 1 ]; do
81 # Verify the role exists
82 if [[ ! "api,controller,keepstore,websocket,keepweb,workbench2,keepproxy,shell,workbench,dispatcher" == *"$i"* ]]; then
83 echo "The role '${i}' is not a valid role"
111 CONFIG="${SCRIPT_DIR}/local.params"
118 if [ -s ${CONFIG} ]; then
121 echo >&2 "Please create a '${CONFIG}' file with initial values, as described in FIXME_URL_TO_DESCR"
129 F_DIR="/srv/formulas"
134 apt-get install -y curl git jq
136 dpkg -l |grep salt-minion
137 if [ ${?} -eq 0 ]; then
138 echo "Salt already installed"
140 curl -L https://bootstrap.saltstack.com -o /tmp/bootstrap_salt.sh
141 sh /tmp/bootstrap_salt.sh -XUdfP -x python3
142 /bin/systemctl disable salt-minion.service
145 # Set salt to masterless mode
146 cat > /etc/salt/minion << EOFSM
152 - ${F_DIR}/*/test/salt/states/examples
164 cat > ${S_DIR}/top.sls << EOFTSLS
167 - single_host.host_entries
168 - single_host.snakeoil_certs
175 # If we want specific roles for a node, just add those states
176 if [ -z "${ROLES}" ]; then
177 echo ' - arvados' >> ${S_DIR}/top.sls
179 for R in ${ROLES}; do
180 echo " - arvados.${R}" >> ${S_DIR}/top.sls
185 cat > ${P_DIR}/top.sls << EOFPSLS
191 - nginx_api_configuration
192 - nginx_controller_configuration
193 - nginx_keepproxy_configuration
194 - nginx_keepweb_configuration
196 - nginx_websocket_configuration
197 - nginx_webshell_configuration
198 - nginx_workbench2_configuration
199 - nginx_workbench_configuration
203 # Get the formula and dependencies
204 cd ${F_DIR} || exit 1
205 git clone --branch "${ARVADOS_TAG}" https://github.com/arvados/arvados-formula.git
206 git clone --branch "${DOCKER_TAG}" https://github.com/saltstack-formulas/docker-formula.git
207 git clone --branch "${LOCALE_TAG}" https://github.com/saltstack-formulas/locale-formula.git
208 git clone --branch "${NGINX_TAG}" https://github.com/saltstack-formulas/nginx-formula.git
209 git clone --branch "${POSTGRES_TAG}" https://github.com/saltstack-formulas/postgres-formula.git
211 if [ "x${BRANCH}" != "x" ]; then
212 cd ${F_DIR}/arvados-formula || exit 1
213 git checkout -t origin/"${BRANCH}"
217 if [ "x${VAGRANT}" = "xyes" ]; then
218 SOURCE_PILLARS_DIR="/vagrant/${CONFIG_DIR}"
219 TESTS_DIR="/vagrant/${TESTS_DIR}"
221 SOURCE_PILLARS_DIR="${SCRIPT_DIR}/${CONFIG_DIR}"
222 TESTS_DIR="${SCRIPT_DIR}/${TESTS_DIR}"
225 # Replace cluster and domain name in the example pillars and test files
226 for f in "${SOURCE_PILLARS_DIR}"/*; do
227 sed "s/__CLUSTER__/${CLUSTER}/g;
228 s/__DOMAIN__/${DOMAIN}/g;
229 s/__RELEASE__/${RELEASE}/g;
230 s/__HOST_SSL_PORT__/${HOST_SSL_PORT}/g;
231 s/__GUEST_SSL_PORT__/${GUEST_SSL_PORT}/g;
232 s/__INITIAL_USER__/${INITIAL_USER}/g;
233 s/__INITIAL_USER_EMAIL__/${INITIAL_USER_EMAIL}/g;
234 s/__INITIAL_USER_PASSWORD__/${INITIAL_USER_PASSWORD}/g;
235 s/__VERSION__/${VERSION}/g" \
236 "${f}" > "${P_DIR}"/$(basename "${f}")
239 mkdir -p /tmp/cluster_tests
240 # Replace cluster and domain name in the example pillars and test files
241 for f in "${TESTS_DIR}"/*; do
242 sed "s/__CLUSTER__/${CLUSTER}/g;
243 s/__DOMAIN__/${DOMAIN}/g;
244 s/__HOST_SSL_PORT__/${HOST_SSL_PORT}/g;
245 s/__INITIAL_USER__/${INITIAL_USER}/g;
246 s/__INITIAL_USER_EMAIL__/${INITIAL_USER_EMAIL}/g;
247 s/__INITIAL_USER_PASSWORD__/${INITIAL_USER_PASSWORD}/g" \
248 ${f} > /tmp/cluster_tests/$(basename ${f})
250 chmod 755 /tmp/cluster_tests/run-test.sh
252 # FIXME! #16992 Temporary fix for psql call in arvados-api-server
253 if [ -e /root/.psqlrc ]; then
254 if ! ( grep 'pset pager off' /root/.psqlrc ); then
256 cp /root/.psqlrc /root/.psqlrc.provision.backup
262 echo '\pset pager off' >> /root/.psqlrc
263 # END FIXME! #16992 Temporary fix for psql call in arvados-api-server
265 # Now run the install
266 salt-call --local state.apply -l ${LOG_LEVEL}
268 # FIXME! #16992 Temporary fix for psql call in arvados-api-server
269 if [ "x${DELETE_PSQL}" = "xyes" ]; then
270 echo "Removing .psql file"
274 if [ "x${RESTORE_PSQL}" = "xyes" ]; then
275 echo "Restoring .psql file"
276 mv -v /root/.psqlrc.provision.backup /root/.psqlrc
278 # END FIXME! #16992 Temporary fix for psql call in arvados-api-server
280 # Leave a copy of the Arvados CA so the user can copy it where it's required
281 echo "Copying the Arvados CA certificate to the installer dir, so you can import it"
282 # If running in a vagrant VM, also add default user to docker group
283 if [ "x${VAGRANT}" = "xyes" ]; then
284 cp /etc/ssl/certs/arvados-snakeoil-ca.pem /vagrant
286 echo "Adding the vagrant user to the docker group"
287 usermod -a -G docker vagrant
289 cp /etc/ssl/certs/arvados-snakeoil-ca.pem ${SCRIPT_DIR}
292 # Test that the installation finished correctly
293 if [ "x${TEST}" = "xyes" ]; then
294 cd /tmp/cluster_tests