3 # Copyright (C) The Arvados Authors. All rights reserved.
5 # SPDX-License-Identifier: CC-BY-SA-3.0
10 # Helps manage the configuration in a git repository, and then deploy
11 # nodes by pushing a copy of the git repository to each node and
12 # running the provision script to do the actual installation and
19 declare CONFIG_FILE=local.params
21 # The salt template directory
22 declare CONFIG_DIR=local_config_dir
24 # The 5-character Arvados cluster id
25 # This will be populated by loadconfig()
28 # The parent domain (not including the cluster id)
29 # This will be populated by loadconfig()
32 # A bash associative array listing each node and mapping to the roles
33 # that should be provisioned on those nodes.
34 # This will be populated by loadconfig()
37 # The ssh user we'll use
38 # This will be populated by loadconfig()
41 # The git repository that we'll push to on all the nodes
42 # This will be populated by loadconfig()
49 # Synchronizes the configuration by creating a git repository on
50 # each node, pushing our branch, and updating the checkout.
52 if [[ "$NODE" != localhost ]] ; then
53 if ! ssh $NODE test -d ${GITTARGET}.git ; then
55 # Initialize the git repository (1st time case). We're
56 # actually going to make two repositories here because git
57 # will complain if you try to push to a repository with a
58 # checkout. So we're going to create a "bare" repository
59 # and then clone a regular repository (with a checkout)
62 ssh $NODE git init --bare ${GITTARGET}.git
63 if ! git remote add $NODE $DEPLOY_USER@$NODE:${GITTARGET}.git ; then
64 git remote set-url $NODE $DEPLOY_USER@$NODE:${GITTARGET}.git
66 git push $NODE $BRANCH
67 ssh $NODE git clone ${GITTARGET}.git ${GITTARGET}
72 # Push to the bare repository on the remote node, then in the
73 # remote node repository with the checkout, pull the branch
74 # from the bare repository.
76 git push $NODE $BRANCH
77 ssh $NODE "git -C ${GITTARGET} checkout ${BRANCH} && git -C ${GITTARGET} pull"
85 # Deploy a node. This runs the provision script on the node, with
86 # the appropriate roles.
88 if [[ -z "$ROLES" ]] ; then
89 echo "No roles declared for '$NODE' in ${CONFIG_FILE}"
93 if [[ "$NODE" = localhost ]] ; then
94 sudo ./provision.sh --config ${CONFIG_FILE} --roles ${ROLES}
96 ssh $DEPLOY_USER@$NODE "cd ${GITTARGET} && sudo ./provision.sh --config ${CONFIG_FILE} --roles ${ROLES}"
101 if [[ ! -s $CONFIG_FILE ]] ; then
102 echo "Must be run from initialized setup dir, maybe you need to 'initialize' first?"
104 source ${CONFIG_FILE}
105 GITTARGET=arvados-deploy-config-${CLUSTER}
109 if [[ -n "$subcmd" ]] ; then
114 if [[ ! -f provision.sh ]] ; then
115 echo "Must be run from arvados/tools/salt-install"
126 if [[ -z "$PARAMS" || ! -f local.params.example.$PARAMS ]] ; then
127 echo "Not found: local.params.example.$PARAMS"
128 echo "Expected one of multiple_hosts, single_host_multiple_hostnames, single_host_single_hostname"
132 if [[ -z "$SLS" || ! -d config_examples/$SLS ]] ; then
133 echo "Not found: config_examples/$SLS"
134 echo "Expected one of multi_host/aws, single_host/multiple_hostnames, single_host/single_hostname"
138 if [[ -z "$SETUPDIR" || -z "$PARAMS" || -z "$SLS" ]]; then
139 echo "installer.sh <setup dir to initialize> <params template> <config template>"
143 if [[ -n "$err" ]] ; then
147 echo "Initializing $SETUPDIR"
149 cp -r *.sh tests $SETUPDIR
151 cp local.params.example.$PARAMS $SETUPDIR/${CONFIG_FILE}
152 cp -r config_examples/$SLS $SETUPDIR/${CONFIG_DIR}
155 git add *.sh ${CONFIG_FILE} ${CONFIG_DIR} tests
156 git commit -m"initial commit"
158 echo "setup directory initialized, now go to $SETUPDIR, edit '${CONFIG_FILE}' and '${CONFIG_DIR}' as needed, then run 'installer.sh deploy'"
167 if grep -rni 'fixme' ${CONFIG_FILE} ${CONFIG_DIR} ; then
169 echo "Some parameters still need to be updated. Please fix them and then re-run deploy."
173 BRANCH=$(git branch --show-current)
178 if ! git diff --cached --exit-code ; then
179 git commit -m"prepare for deploy"
182 if [[ -z "$NODE" ]]; then
183 for NODE in "${!NODES[@]}"
185 # First, push the git repo to each node. This also
186 # confirms that we have git and can log into each
191 for NODE in "${!NODES[@]}"
193 # Do 'database' role first,
194 if [[ "${NODES[$NODE]}" =~ database ]] ; then
195 deploynode $NODE ${NODES[$NODE]}
200 for NODE in "${!NODES[@]}"
202 # then 'api' or 'controller' roles
203 if [[ "${NODES[$NODE]}" =~ (api|controller) ]] ; then
204 deploynode $NODE ${NODES[$NODE]}
209 for NODE in "${!NODES[@]}"
211 # Everything else (we removed the nodes that we
212 # already deployed from the list)
213 deploynode $NODE ${NODES[$NODE]}
216 # Just deploy the node that was supplied on the command line.
222 echo "Completed deploy, run 'installer.sh diagnostics' to verify the install"
232 if ! which arvados-client ; then
233 echo "arvados-client not found, install 'arvados-client' package with 'apt-get' or 'yum'"
237 if [[ -z "$LOCATION" ]] ; then
238 echo "Need to provide '-internal-client' or '-external-client'"
240 echo "-internal-client You are running this on the same private network as the Arvados cluster (e.g. on one of the Arvados nodes)"
241 echo "-external-client You are running this outside the private network of the Arvados cluster (e.g. your workstation)"
245 export ARVADOS_API_HOST="${CLUSTER}.${DOMAIN}"
246 export ARVADOS_API_TOKEN="$SYSTEM_ROOT_TOKEN"
248 arvados-client diagnostics $LOCATION
251 echo "Arvados installer"
253 echo "initialize initialize the setup directory for configuration"
254 echo "deploy deploy the configuration from the setup directory"
255 echo "diagnostics check your install using diagnostics"