blob: ad3757eebf3dc285110c7aff4d6cd630a72cd559 [file] [log] [blame]
azvyagintsev6d453852018-02-26 16:56:37 +02001#!/bin/bash -xe
2
azvyagintsevffa75b42018-06-06 20:38:54 +03003CLUSTER_NAME=${CLUSTER_NAME:-lost_cluster_name_variable}
4CLUSTER_MODEL=${CLUSTER_MODEL:-https://github.com/Mirantis/mcp-offline-model.git}
azvyagintsevc86fbaf2018-03-02 18:57:03 +02005CLUSTER_MODEL_REF=${CLUSTER_MODEL_REF:-master}
6FORMULA_VERSION=${FORMULA_VERSION:-testing}
azvyagintsev6d453852018-02-26 16:56:37 +02007SALTSTACK_GPG=${SALTSTACK_GPG:-"https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/SALTSTACK-GPG-KEY.pub"}
8SALTSTACK_REPO=${SALTSTACK_REPO:-"http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3 xenial main"}
9APT_MIRANTIS_GPG=${APT_MIRANTIS_GPG:-"http://apt.mirantis.com/public.gpg"}
Richard Felkl47757902018-03-02 22:44:43 +010010APT_MIRANTIS_SALT_REPO=${APT_MIRANTIS_SALT_REPO:-"http://apt.mirantis.com/xenial/ $FORMULA_VERSION salt"}
azvyagintsev6d453852018-02-26 16:56:37 +020011GIT_SALT_FORMULAS_SCRIPTS=${GIT_SALT_FORMULAS_SCRIPTS:-"https://github.com/salt-formulas/salt-formulas-scripts"}
alexz8c4cfc72018-03-23 13:56:10 +010012GIT_SALT_FORMULAS_SCRIPTS_REF=${GIT_SALT_FORMULAS_SCRIPTS_REF:-master}
azvyagintsev6d453852018-02-26 16:56:37 +020013
14wget -O - ${SALTSTACK_GPG} | sudo apt-key add -
15wget -O - ${APT_MIRANTIS_GPG} | apt-key add -
16echo "deb [arch=amd64] ${SALTSTACK_REPO}" > /etc/apt/sources.list.d/saltstack.list
17apt-get update
18apt-get install git-core -y
alexz8c4cfc72018-03-23 13:56:10 +010019
azvyagintsev6d453852018-02-26 16:56:37 +020020for g_host in ${CLUSTER_MODEL} ${GIT_SALT_FORMULAS_SCRIPTS} ; do
21 _tmp_host=$(echo ${g_host} | awk -F/ '{print $3}')
22 ssh-keyscan -T 1 -H ${_tmp_host} >> ~/.ssh/known_hosts || true
23done
24
alexz8c4cfc72018-03-23 13:56:10 +010025if [[ ! -d /srv/salt/reclass ]]; then
26 git clone --recursive ${CLUSTER_MODEL} /srv/salt/reclass
27 pushd /srv/salt/reclass/
28 git checkout ${CLUSTER_MODEL_REF}
29 popd
30fi
31
32if [[ ! -d /srv/salt/scripts ]]; then
33 git clone --recursive ${GIT_SALT_FORMULAS_SCRIPTS} /srv/salt/scripts
34 pushd /srv/salt/scripts/
35 git checkout ${GIT_SALT_FORMULAS_SCRIPTS_REF}
36 popd
37fi
38
azvyagintsev6d453852018-02-26 16:56:37 +020039# bootstrap.sh opts
40export FORMULAS_SOURCE=pkg
azvyagintsevffa75b42018-06-06 20:38:54 +030041export HOSTNAME=${BS_HOSTNAME:-lost_bs_hostname_variable}
azvyagintsev6d453852018-02-26 16:56:37 +020042export DOMAIN="${CLUSTER_NAME}.local"
azvyagintsevffa75b42018-06-06 20:38:54 +030043export EXTRA_FORMULAS=${EXTRA_FORMULAS:-"ntp aptly nginx iptables docker git maas jenkins"}
azvyagintsev6d453852018-02-26 16:56:37 +020044export APT_REPOSITORY=" deb [arch=amd64] ${APT_MIRANTIS_SALT_REPO} "
45export APT_REPOSITORY_GPG=${APT_MIRANTIS_GPG}
46if [[ ! -z "${PACKER_OFFLINE_BUILD}" ]];then
azvyagintsevc86fbaf2018-03-02 18:57:03 +020047 echo "INFO: build in offline detected!"
48 export BOOTSTRAP_SALTSTACK_COM="file:///tmp/bootstrap.saltstack.com.sh"
49 # extra opts will push bootstrap script NOT install upstream repos.
azvyagintsev6d453852018-02-26 16:56:37 +020050 export BOOTSTRAP_SALTSTACK_OPTS=${BOOTSTRAP_SALTSTACK_OPTS:- -dXr $BOOTSTRAP_SALTSTACK_VERSION }
51fi
52#
alexz8c4cfc72018-03-23 13:56:10 +010053
54if [[ ! -f /srv/salt/scripts/bootstrap.sh ]]; then
55 echo "ERROR: File /srv/salt/scripts/bootstrap.sh not found"
56 exit 1
57fi
azvyagintsev6d453852018-02-26 16:56:37 +020058bash -x /srv/salt/scripts/bootstrap.sh || true