blob: 73622d03b1f964466bdbd2dbea987e1ad5f2b09f [file] [log] [blame]
Jiri Broulik4ea221c2018-04-10 13:48:06 +02001#!/bin/bash -xe
2CLUSTER_NAME=${CLUSTER_NAME:-mcp-day01}
3CLUSTER_MODEL=${CLUSTER_MODEL:-https://github.com/jiribroulik/day01.git}
4CLUSTER_MODEL_REF=${CLUSTER_MODEL_REF:-master}
5FORMULA_VERSION=${FORMULA_VERSION:-testing}
6SALTSTACK_GPG=${SALTSTACK_GPG:-"https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/SALTSTACK-GPG-KEY.pub"}
7SALTSTACK_REPO=${SALTSTACK_REPO:-"http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3 xenial main"}
8APT_MIRANTIS_GPG=${APT_MIRANTIS_GPG:-"http://apt.mirantis.com/public.gpg"}
9APT_MIRANTIS_SALT_REPO=${APT_MIRANTIS_SALT_REPO:-"http://apt.mirantis.com/xenial/ $FORMULA_VERSION salt"}
10GIT_SALT_FORMULAS_SCRIPTS=${GIT_SALT_FORMULAS_SCRIPTS:-"https://github.com/salt-formulas/salt-formulas-scripts"}
11GIT_SALT_FORMULAS_SCRIPTS_REF=${GIT_SALT_FORMULAS_SCRIPTS_REF:-master}
12
13wget -O - ${SALTSTACK_GPG} | sudo apt-key add -
14wget -O - ${APT_MIRANTIS_GPG} | apt-key add -
15echo "deb [arch=amd64] ${SALTSTACK_REPO}" > /etc/apt/sources.list.d/saltstack.list
16apt-get update
17apt-get install git-core -y
18
19for g_host in ${CLUSTER_MODEL} ${GIT_SALT_FORMULAS_SCRIPTS} ; do
20 _tmp_host=$(echo ${g_host} | awk -F/ '{print $3}')
21 ssh-keyscan -T 1 -H ${_tmp_host} >> ~/.ssh/known_hosts || true
22done
23
24if [[ ! -d /srv/salt/reclass ]]; then
25 git clone --recursive ${CLUSTER_MODEL} /srv/salt/reclass
26 pushd /srv/salt/reclass/
27 git checkout ${CLUSTER_MODEL_REF}
28 popd
29fi
30
31if [[ ! -d /srv/salt/scripts ]]; then
32 git clone --recursive ${GIT_SALT_FORMULAS_SCRIPTS} /srv/salt/scripts
33 pushd /srv/salt/scripts/
34 git checkout ${GIT_SALT_FORMULAS_SCRIPTS_REF}
35 popd
36fi
37
38# bootstrap.sh opts
39export FORMULAS_SOURCE=pkg
40export HOSTNAME=cfg01
41export DOMAIN="${CLUSTER_NAME}.local"
42export EXTRA_FORMULAS="git ntp maas jenkins"
43export APT_REPOSITORY=" deb [arch=amd64] ${APT_MIRANTIS_SALT_REPO} "
44export APT_REPOSITORY_GPG=${APT_MIRANTIS_GPG}
45
46if [[ ! -f /srv/salt/scripts/bootstrap.sh ]]; then
47 echo "ERROR: File /srv/salt/scripts/bootstrap.sh not found"
48 exit 1
49fi
50bash -x /srv/salt/scripts/bootstrap.sh || true