blob: 446ead9cb2841f76cb78ecb65457b4743c2282f8 [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}
Petr Ruzicka9138b182018-08-22 17:38:30 +020012SALTSTACK_GPG=${SALTSTACK_GPG:-"https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/SALTSTACK-GPG-KEY.pub"}
13SALTSTACK_REPO=${SALTSTACK_REPO:-"http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7 xenial main"}
azvyagintsev6d453852018-02-26 16:56:37 +020014APT_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 -
azvyagintsev4b5603e2018-09-14 16:33:14 +030021echo "deb [arch=amd64] ${SALTSTACK_REPO}" > /etc/apt/sources.list.d/mcp_saltstack.list
22# This Pin-Priority fil should be always aligned with
23# https://github.com/Mirantis/reclass-system-salt-model/blob/master/linux/system/repo/mcp/apt_mirantis/saltstack.yml
24cat <<EOF >> /etc/apt/preferences.d/mcp_saltstack
25Package: libsodium18
26Pin: release o=SaltStack
27Pin-Priority: 50
28
29Package: *
30Pin: release o=SaltStack
31Pin-Priority: 1100
32EOF
azvyagintsev6d453852018-02-26 16:56:37 +020033apt-get update
34apt-get install git-core -y
alexz8c4cfc72018-03-23 13:56:10 +010035
azvyagintsev6d453852018-02-26 16:56:37 +020036for g_host in ${CLUSTER_MODEL} ${GIT_SALT_FORMULAS_SCRIPTS} ; do
37 _tmp_host=$(echo ${g_host} | awk -F/ '{print $3}')
38 ssh-keyscan -T 1 -H ${_tmp_host} >> ~/.ssh/known_hosts || true
39done
40
alexz8c4cfc72018-03-23 13:56:10 +010041if [[ ! -d /srv/salt/reclass ]]; then
42 git clone --recursive ${CLUSTER_MODEL} /srv/salt/reclass
43 pushd /srv/salt/reclass/
44 git checkout ${CLUSTER_MODEL_REF}
45 popd
46fi
47
48if [[ ! -d /srv/salt/scripts ]]; then
49 git clone --recursive ${GIT_SALT_FORMULAS_SCRIPTS} /srv/salt/scripts
50 pushd /srv/salt/scripts/
51 git checkout ${GIT_SALT_FORMULAS_SCRIPTS_REF}
52 popd
53fi
54
azvyagintsev6d453852018-02-26 16:56:37 +020055# bootstrap.sh opts
56export FORMULAS_SOURCE=pkg
azvyagintsevffa75b42018-06-06 20:38:54 +030057export HOSTNAME=${BS_HOSTNAME:-lost_bs_hostname_variable}
azvyagintsev6d453852018-02-26 16:56:37 +020058export DOMAIN="${CLUSTER_NAME}.local"
azvyagintsevbf6d3fd2018-07-31 16:08:43 +030059export EXTRA_FORMULAS=${EXTRA_FORMULAS:-"ntp aptly nginx iptables docker git maas jenkins logrotate"}
azvyagintsev6d453852018-02-26 16:56:37 +020060export APT_REPOSITORY=" deb [arch=amd64] ${APT_MIRANTIS_SALT_REPO} "
61export APT_REPOSITORY_GPG=${APT_MIRANTIS_GPG}
azvyagintsev0f697cf2018-06-22 11:44:13 +030062export SALT_STOPSTART_WAIT=${SALT_STOPSTART_WAIT:-10}
azvyagintsev4b5603e2018-09-14 16:33:14 +030063echo "INFO: build in offline build!"
64export BOOTSTRAP_SALTSTACK_COM="file:///tmp/bootstrap.saltstack.com.sh"
65# extra opts will push bootstrap script NOT install upstream repos.
66export BOOTSTRAP_SALTSTACK_OPTS=${BOOTSTRAP_SALTSTACK_OPTS:- -dXr $BOOTSTRAP_SALTSTACK_VERSION }
azvyagintsev6d453852018-02-26 16:56:37 +020067#
alexz8c4cfc72018-03-23 13:56:10 +010068
69if [[ ! -f /srv/salt/scripts/bootstrap.sh ]]; then
70 echo "ERROR: File /srv/salt/scripts/bootstrap.sh not found"
71 exit 1
72fi
azvyagintsev6d453852018-02-26 16:56:37 +020073bash -x /srv/salt/scripts/bootstrap.sh || true
azvyagintsev29410ee2018-07-12 20:02:30 +030074touch /done_ubuntu_salt_bootstrap