Jiri Broulik | 4ea221c | 2018-04-10 13:48:06 +0200 | [diff] [blame] | 1 | #!/bin/bash -xe |
Jiri Broulik | 4ea221c | 2018-04-10 13:48:06 +0200 | [diff] [blame] | 2 | CLUSTER_MODEL_REF=${CLUSTER_MODEL_REF:-master} |
Jiri Broulik | 4ea221c | 2018-04-10 13:48:06 +0200 | [diff] [blame] | 3 | GIT_SALT_FORMULAS_SCRIPTS_REF=${GIT_SALT_FORMULAS_SCRIPTS_REF:-master} |
| 4 | |
| 5 | wget -O - ${SALTSTACK_GPG} | sudo apt-key add - |
| 6 | wget -O - ${APT_MIRANTIS_GPG} | apt-key add - |
| 7 | echo "deb [arch=amd64] ${SALTSTACK_REPO}" > /etc/apt/sources.list.d/saltstack.list |
| 8 | apt-get update |
| 9 | apt-get install git-core -y |
| 10 | |
| 11 | for g_host in ${CLUSTER_MODEL} ${GIT_SALT_FORMULAS_SCRIPTS} ; do |
| 12 | _tmp_host=$(echo ${g_host} | awk -F/ '{print $3}') |
| 13 | ssh-keyscan -T 1 -H ${_tmp_host} >> ~/.ssh/known_hosts || true |
| 14 | done |
| 15 | |
| 16 | if [[ ! -d /srv/salt/reclass ]]; then |
| 17 | git clone --recursive ${CLUSTER_MODEL} /srv/salt/reclass |
| 18 | pushd /srv/salt/reclass/ |
| 19 | git checkout ${CLUSTER_MODEL_REF} |
| 20 | popd |
| 21 | fi |
| 22 | |
| 23 | if [[ ! -d /srv/salt/scripts ]]; then |
| 24 | git clone --recursive ${GIT_SALT_FORMULAS_SCRIPTS} /srv/salt/scripts |
| 25 | pushd /srv/salt/scripts/ |
| 26 | git checkout ${GIT_SALT_FORMULAS_SCRIPTS_REF} |
| 27 | popd |
| 28 | fi |
| 29 | |
| 30 | # bootstrap.sh opts |
| 31 | export FORMULAS_SOURCE=pkg |
| 32 | export HOSTNAME=cfg01 |
| 33 | export DOMAIN="${CLUSTER_NAME}.local" |
| 34 | export EXTRA_FORMULAS="git ntp maas jenkins" |
| 35 | export APT_REPOSITORY=" deb [arch=amd64] ${APT_MIRANTIS_SALT_REPO} " |
| 36 | export APT_REPOSITORY_GPG=${APT_MIRANTIS_GPG} |
| 37 | |
| 38 | if [[ ! -f /srv/salt/scripts/bootstrap.sh ]]; then |
| 39 | echo "ERROR: File /srv/salt/scripts/bootstrap.sh not found" |
| 40 | exit 1 |
| 41 | fi |
| 42 | bash -x /srv/salt/scripts/bootstrap.sh || true |