azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 1 | #!/bin/bash -xe |
| 2 | |
azvyagintsev | c86fbaf | 2018-03-02 18:57:03 +0200 | [diff] [blame] | 3 | CLUSTER_MODEL_REF=${CLUSTER_MODEL_REF:-master} |
| 4 | FORMULA_VERSION=${FORMULA_VERSION:-testing} |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 5 | SALTSTACK_GPG=${SALTSTACK_GPG:-"https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/SALTSTACK-GPG-KEY.pub"} |
| 6 | SALTSTACK_REPO=${SALTSTACK_REPO:-"http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3 xenial main"} |
| 7 | APT_MIRANTIS_GPG=${APT_MIRANTIS_GPG:-"http://apt.mirantis.com/public.gpg"} |
Richard Felkl | 4775790 | 2018-03-02 22:44:43 +0100 | [diff] [blame] | 8 | APT_MIRANTIS_SALT_REPO=${APT_MIRANTIS_SALT_REPO:-"http://apt.mirantis.com/xenial/ $FORMULA_VERSION salt"} |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 9 | GIT_SALT_FORMULAS_SCRIPTS=${GIT_SALT_FORMULAS_SCRIPTS:-"https://github.com/salt-formulas/salt-formulas-scripts"} |
alexz | 8c4cfc7 | 2018-03-23 13:56:10 +0100 | [diff] [blame^] | 10 | GIT_SALT_FORMULAS_SCRIPTS_REF=${GIT_SALT_FORMULAS_SCRIPTS_REF:-master} |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 11 | |
| 12 | wget -O - ${SALTSTACK_GPG} | sudo apt-key add - |
| 13 | wget -O - ${APT_MIRANTIS_GPG} | apt-key add - |
| 14 | echo "deb [arch=amd64] ${SALTSTACK_REPO}" > /etc/apt/sources.list.d/saltstack.list |
| 15 | apt-get update |
| 16 | apt-get install git-core -y |
alexz | 8c4cfc7 | 2018-03-23 13:56:10 +0100 | [diff] [blame^] | 17 | |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 18 | for g_host in ${CLUSTER_MODEL} ${GIT_SALT_FORMULAS_SCRIPTS} ; do |
| 19 | _tmp_host=$(echo ${g_host} | awk -F/ '{print $3}') |
| 20 | ssh-keyscan -T 1 -H ${_tmp_host} >> ~/.ssh/known_hosts || true |
| 21 | done |
| 22 | |
alexz | 8c4cfc7 | 2018-03-23 13:56:10 +0100 | [diff] [blame^] | 23 | if [[ ! -d /srv/salt/reclass ]]; then |
| 24 | git clone --recursive ${CLUSTER_MODEL} /srv/salt/reclass |
| 25 | pushd /srv/salt/reclass/ |
| 26 | git checkout ${CLUSTER_MODEL_REF} |
| 27 | popd |
| 28 | fi |
| 29 | |
| 30 | if [[ ! -d /srv/salt/scripts ]]; then |
| 31 | git clone --recursive ${GIT_SALT_FORMULAS_SCRIPTS} /srv/salt/scripts |
| 32 | pushd /srv/salt/scripts/ |
| 33 | git checkout ${GIT_SALT_FORMULAS_SCRIPTS_REF} |
| 34 | popd |
| 35 | fi |
| 36 | |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 37 | # bootstrap.sh opts |
| 38 | export FORMULAS_SOURCE=pkg |
| 39 | export HOSTNAME=apt01 |
| 40 | export DOMAIN="${CLUSTER_NAME}.local" |
| 41 | export EXTRA_FORMULAS="ntp aptly nginx iptables docker" |
| 42 | export APT_REPOSITORY=" deb [arch=amd64] ${APT_MIRANTIS_SALT_REPO} " |
| 43 | export APT_REPOSITORY_GPG=${APT_MIRANTIS_GPG} |
| 44 | if [[ ! -z "${PACKER_OFFLINE_BUILD}" ]];then |
azvyagintsev | c86fbaf | 2018-03-02 18:57:03 +0200 | [diff] [blame] | 45 | echo "INFO: build in offline detected!" |
| 46 | export BOOTSTRAP_SALTSTACK_COM="file:///tmp/bootstrap.saltstack.com.sh" |
| 47 | # extra opts will push bootstrap script NOT install upstream repos. |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 48 | export BOOTSTRAP_SALTSTACK_OPTS=${BOOTSTRAP_SALTSTACK_OPTS:- -dXr $BOOTSTRAP_SALTSTACK_VERSION } |
| 49 | fi |
| 50 | # |
alexz | 8c4cfc7 | 2018-03-23 13:56:10 +0100 | [diff] [blame^] | 51 | |
| 52 | if [[ ! -f /srv/salt/scripts/bootstrap.sh ]]; then |
| 53 | echo "ERROR: File /srv/salt/scripts/bootstrap.sh not found" |
| 54 | exit 1 |
| 55 | fi |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 56 | bash -x /srv/salt/scripts/bootstrap.sh || true |