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
13 ##########################################################
14 # This section are the basic parameters to configure the installation
16 # The 5 letters name you want to give your cluster
22 # If not specified, the initial user email will be composed as
23 # INITIAL_USER@CLUSTER.DOMAIN
24 INITIAL_USER_EMAIL="${INITIAL_USER}@${CLUSTER}.${DOMAIN}"
25 INITIAL_USER_PASSWORD="password"
27 # The example config you want to use. Currently, only "single_host" is
29 CONFIG_DIR="single_host"
31 # Which release of Arvados repo you want to use
33 # Which version of Arvados you want to install. Defaults to 'latest'
37 # Host SSL port where you want to point your browser to access Arvados
38 # Defaults to 443 for regular runs, and to 8443 when called in Vagrant.
39 # You can point it to another port if desired
40 # In Vagrant, make sure it matches what you set in the Vagrantfile
43 # This is a arvados-formula setting.
44 # If branch is set, the script will switch to it before running salt
45 # Usually not needed, only used for testing
48 ##########################################################
49 # Usually there's no need to modify things below this line
53 # capture the directory that the script is running from
54 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
58 echo >&2 "Usage: $0 [-h] [-h]"
60 echo >&2 "$0 options:"
61 echo >&2 " -d, --debug Run salt installation in debug mode"
62 echo >&2 " -p <N>, --ssl-port <N> SSL port to use for the web applications"
63 echo >&2 " -t, --test Test installation running a CWL workflow"
64 echo >&2 " -h, --help Display this help and exit"
65 echo >&2 " -v, --vagrant Run in vagrant and use the /vagrant shared dir"
70 # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
71 TEMP=`getopt -o dhp:tv \
72 --long debug,help,ssl-port:,test,vagrant \
75 if [ $? != 0 ] ; then echo "GNU getopt missing? Use -h for help"; exit 1 ; fi
76 # Note the quotes around `$TEMP': they are essential!
79 while [ $# -ge 1 ]; do
119 F_DIR="/srv/formulas"
124 apt-get install -y curl git jq
126 dpkg -l |grep salt-minion
127 if [ ${?} -eq 0 ]; then
128 echo "Salt already installed"
130 curl -L https://bootstrap.saltstack.com -o /tmp/bootstrap_salt.sh
131 sh /tmp/bootstrap_salt.sh -XUdfP -x python3
132 /bin/systemctl disable salt-minion.service
135 # Set salt to masterless mode
136 cat > /etc/salt/minion << EOFSM
142 - ${F_DIR}/*/test/salt/states
154 cat > ${S_DIR}/top.sls << EOFTSLS
157 - example_single_host_host_entries
158 - example_add_snakeoil_certs
167 cat > ${P_DIR}/top.sls << EOFPSLS
172 - nginx_api_configuration
173 - nginx_controller_configuration
174 - nginx_keepproxy_configuration
175 - nginx_keepweb_configuration
177 - nginx_websocket_configuration
178 - nginx_webshell_configuration
179 - nginx_workbench2_configuration
180 - nginx_workbench_configuration
185 # Get the formula and dependencies
186 cd ${F_DIR} || exit 1
187 for f in postgres arvados nginx docker locale; do
188 git clone https://github.com/netmanagers/${f}-formula.git
191 if [ "x${BRANCH}" != "x" ]; then
192 cd ${F_DIR}/arvados-formula
193 git checkout -t origin/${BRANCH}
197 # sed "s/__DOMAIN__/${DOMAIN}/g; s/__CLUSTER__/${CLUSTER}/g; s/__RELEASE__/${RELEASE}/g; s/__VERSION__/${VERSION}/g" \
198 # ${CONFIG_DIR}/arvados_dev.sls > ${P_DIR}/arvados.sls
200 if [ "x${VAGRANT}" = "xyes" ]; then
201 SOURCE_PILLARS_DIR="/vagrant/${CONFIG_DIR}"
202 TESTS_DIR="/vagrant/${TESTS_DIR}"
204 SOURCE_PILLARS_DIR="${SCRIPT_DIR}/${CONFIG_DIR}"
205 TESTS_DIR="${SCRIPT_DIR}/${TESTS_DIR}"
208 # Replace cluster and domain name in the example pillars and test files
209 for f in ${SOURCE_PILLARS_DIR}/*; do
210 sed "s/__CLUSTER__/${CLUSTER}/g;
211 s/__DOMAIN__/${DOMAIN}/g;
212 s/__RELEASE__/${RELEASE}/g;
213 s/__HOST_SSL_PORT__/${HOST_SSL_PORT}/g;
214 s/__GUEST_SSL_PORT__/${GUEST_SSL_PORT}/g;
215 s/__INITIAL_USER__/${INITIAL_USER}/g;
216 s/__INITIAL_USER_EMAIL__/${INITIAL_USER_EMAIL}/g;
217 s/__INITIAL_USER_PASSWORD__/${INITIAL_USER_PASSWORD}/g;
218 s/__VERSION__/${VERSION}/g" \
219 ${f} > ${P_DIR}/$(basename ${f})
222 mkdir -p /tmp/cluster_tests
223 # Replace cluster and domain name in the example pillars and test files
224 for f in ${TESTS_DIR}/*; do
225 sed "s/__CLUSTER__/${CLUSTER}/g;
226 s/__DOMAIN__/${DOMAIN}/g;
227 s/__HOST_SSL_PORT__/${HOST_SSL_PORT}/g;
228 s/__INITIAL_USER__/${INITIAL_USER}/g;
229 s/__INITIAL_USER_EMAIL__/${INITIAL_USER_EMAIL}/g;
230 s/__INITIAL_USER_PASSWORD__/${INITIAL_USER_PASSWORD}/g" \
231 ${f} > /tmp/cluster_tests/$(basename ${f})
233 chmod 755 /tmp/cluster_tests/run-test.sh
235 # FIXME! #16992 Temporary fix for psql call in arvados-api-server
236 if [ -e /root/.psqlrc ]; then
237 if ! ( grep 'pset pager off' /root/.psqlrc ); then
239 cp /root/.psqlrc /root/.psqlrc.provision.backup
245 echo '\pset pager off' >> /root/.psqlrc
246 # END FIXME! #16992 Temporary fix for psql call in arvados-api-server
248 # Now run the install
249 salt-call --local state.apply -l ${LOG_LEVEL}
251 # FIXME! #16992 Temporary fix for psql call in arvados-api-server
252 if [ "x${DELETE_PSQL}" = "xyes" ]; then
253 echo "Removing .psql file"
257 if [ "x${RESTORE_PSQL}" = "xyes" ]; then
258 echo "Restoring .psql file"
259 mv -v /root/.psqlrc.provision.backup /root/.psqlrc
261 # END FIXME! #16992 Temporary fix for psql call in arvados-api-server
263 # If running in a vagrant VM, add default user to docker group
264 if [ "x${VAGRANT}" = "xyes" ]; then
265 usermod -a -G docker vagrant
268 # Test that the installation finished correctly
269 if [ "x${TEST}" = "xyes" ]; then
270 cd /tmp/cluster_tests