blob: a5a04f39830f4f4e25748c9adff89e4cbf4b1dae [file] [log] [blame]
azvyagintsev6d453852018-02-26 16:56:37 +02001#!/bin/bash -xe
2
azvyagintsev29410ee2018-07-12 20:02:30 +03003if [ -f '/done_ubuntu_salt_bootstrap' ]; then
azvyagintsevb0daab12018-06-18 12:35:25 +03004 echo "INFO: ubuntu_salt_bootstrap already finished! Skipping.."
5 exit 0
6fi
7#
azvyagintsevffa75b42018-06-06 20:38:54 +03008CLUSTER_NAME=${CLUSTER_NAME:-lost_cluster_name_variable}
9CLUSTER_MODEL=${CLUSTER_MODEL:-https://github.com/Mirantis/mcp-offline-model.git}
azvyagintsevc86fbaf2018-03-02 18:57:03 +020010CLUSTER_MODEL_REF=${CLUSTER_MODEL_REF:-master}
11FORMULA_VERSION=${FORMULA_VERSION:-testing}
azvyagintsev6d453852018-02-26 16:56:37 +020012SALTSTACK_GPG=${SALTSTACK_GPG:-"https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/SALTSTACK-GPG-KEY.pub"}
13SALTSTACK_REPO=${SALTSTACK_REPO:-"http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3 xenial main"}
14APT_MIRANTIS_GPG=${APT_MIRANTIS_GPG:-"http://apt.mirantis.com/public.gpg"}
Richard Felkl47757902018-03-02 22:44:43 +010015APT_MIRANTIS_SALT_REPO=${APT_MIRANTIS_SALT_REPO:-"http://apt.mirantis.com/xenial/ $FORMULA_VERSION salt"}
azvyagintsev6d453852018-02-26 16:56:37 +020016GIT_SALT_FORMULAS_SCRIPTS=${GIT_SALT_FORMULAS_SCRIPTS:-"https://github.com/salt-formulas/salt-formulas-scripts"}
alexz8c4cfc72018-03-23 13:56:10 +010017GIT_SALT_FORMULAS_SCRIPTS_REF=${GIT_SALT_FORMULAS_SCRIPTS_REF:-master}
azvyagintsev6d453852018-02-26 16:56:37 +020018
19wget -O - ${SALTSTACK_GPG} | sudo apt-key add -
20wget -O - ${APT_MIRANTIS_GPG} | apt-key add -
21echo "deb [arch=amd64] ${SALTSTACK_REPO}" > /etc/apt/sources.list.d/saltstack.list
22apt-get update
23apt-get install git-core -y
alexz8c4cfc72018-03-23 13:56:10 +010024
azvyagintsev6d453852018-02-26 16:56:37 +020025for g_host in ${CLUSTER_MODEL} ${GIT_SALT_FORMULAS_SCRIPTS} ; do
26 _tmp_host=$(echo ${g_host} | awk -F/ '{print $3}')
27 ssh-keyscan -T 1 -H ${_tmp_host} >> ~/.ssh/known_hosts || true
28done
29
alexz8c4cfc72018-03-23 13:56:10 +010030if [[ ! -d /srv/salt/reclass ]]; then
31 git clone --recursive ${CLUSTER_MODEL} /srv/salt/reclass
32 pushd /srv/salt/reclass/
33 git checkout ${CLUSTER_MODEL_REF}
34 popd
35fi
36
37if [[ ! -d /srv/salt/scripts ]]; then
38 git clone --recursive ${GIT_SALT_FORMULAS_SCRIPTS} /srv/salt/scripts
39 pushd /srv/salt/scripts/
40 git checkout ${GIT_SALT_FORMULAS_SCRIPTS_REF}
41 popd
42fi
43
azvyagintsev6d453852018-02-26 16:56:37 +020044# bootstrap.sh opts
45export FORMULAS_SOURCE=pkg
azvyagintsevffa75b42018-06-06 20:38:54 +030046export HOSTNAME=${BS_HOSTNAME:-lost_bs_hostname_variable}
azvyagintsev6d453852018-02-26 16:56:37 +020047export DOMAIN="${CLUSTER_NAME}.local"
azvyagintsevffa75b42018-06-06 20:38:54 +030048export EXTRA_FORMULAS=${EXTRA_FORMULAS:-"ntp aptly nginx iptables docker git maas jenkins"}
azvyagintsev6d453852018-02-26 16:56:37 +020049export APT_REPOSITORY=" deb [arch=amd64] ${APT_MIRANTIS_SALT_REPO} "
50export APT_REPOSITORY_GPG=${APT_MIRANTIS_GPG}
azvyagintsev0f697cf2018-06-22 11:44:13 +030051export SALT_STOPSTART_WAIT=${SALT_STOPSTART_WAIT:-10}
azvyagintsev6d453852018-02-26 16:56:37 +020052if [[ ! -z "${PACKER_OFFLINE_BUILD}" ]];then
azvyagintsevc86fbaf2018-03-02 18:57:03 +020053 echo "INFO: build in offline detected!"
54 export BOOTSTRAP_SALTSTACK_COM="file:///tmp/bootstrap.saltstack.com.sh"
55 # extra opts will push bootstrap script NOT install upstream repos.
azvyagintsev6d453852018-02-26 16:56:37 +020056 export BOOTSTRAP_SALTSTACK_OPTS=${BOOTSTRAP_SALTSTACK_OPTS:- -dXr $BOOTSTRAP_SALTSTACK_VERSION }
57fi
58#
alexz8c4cfc72018-03-23 13:56:10 +010059
60if [[ ! -f /srv/salt/scripts/bootstrap.sh ]]; then
61 echo "ERROR: File /srv/salt/scripts/bootstrap.sh not found"
62 exit 1
63fi
azvyagintsev6d453852018-02-26 16:56:37 +020064bash -x /srv/salt/scripts/bootstrap.sh || true
azvyagintsev29410ee2018-07-12 20:02:30 +030065touch /done_ubuntu_salt_bootstrap