Jiri Broulik | 4ea221c | 2018-04-10 13:48:06 +0200 | [diff] [blame^] | 1 | #!/bin/bash -xe |
| 2 | CLUSTER_NAME=${CLUSTER_NAME:-mcp-day01} |
| 3 | CLUSTER_MODEL=${CLUSTER_MODEL:-https://github.com/jiribroulik/day01.git} |
| 4 | CLUSTER_MODEL_REF=${CLUSTER_MODEL_REF:-master} |
| 5 | FORMULA_VERSION=${FORMULA_VERSION:-testing} |
| 6 | SALTSTACK_GPG=${SALTSTACK_GPG:-"https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3/SALTSTACK-GPG-KEY.pub"} |
| 7 | SALTSTACK_REPO=${SALTSTACK_REPO:-"http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2016.3 xenial main"} |
| 8 | APT_MIRANTIS_GPG=${APT_MIRANTIS_GPG:-"http://apt.mirantis.com/public.gpg"} |
| 9 | APT_MIRANTIS_SALT_REPO=${APT_MIRANTIS_SALT_REPO:-"http://apt.mirantis.com/xenial/ $FORMULA_VERSION salt"} |
| 10 | GIT_SALT_FORMULAS_SCRIPTS=${GIT_SALT_FORMULAS_SCRIPTS:-"https://github.com/salt-formulas/salt-formulas-scripts"} |
| 11 | GIT_SALT_FORMULAS_SCRIPTS_REF=${GIT_SALT_FORMULAS_SCRIPTS_REF:-master} |
| 12 | |
| 13 | wget -O - ${SALTSTACK_GPG} | sudo apt-key add - |
| 14 | wget -O - ${APT_MIRANTIS_GPG} | apt-key add - |
| 15 | echo "deb [arch=amd64] ${SALTSTACK_REPO}" > /etc/apt/sources.list.d/saltstack.list |
| 16 | apt-get update |
| 17 | apt-get install git-core -y |
| 18 | |
| 19 | for 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 |
| 22 | done |
| 23 | |
| 24 | if [[ ! -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 |
| 29 | fi |
| 30 | |
| 31 | if [[ ! -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 |
| 36 | fi |
| 37 | |
| 38 | # bootstrap.sh opts |
| 39 | export FORMULAS_SOURCE=pkg |
| 40 | export HOSTNAME=cfg01 |
| 41 | export DOMAIN="${CLUSTER_NAME}.local" |
| 42 | export EXTRA_FORMULAS="git ntp maas jenkins" |
| 43 | export APT_REPOSITORY=" deb [arch=amd64] ${APT_MIRANTIS_SALT_REPO} " |
| 44 | export APT_REPOSITORY_GPG=${APT_MIRANTIS_GPG} |
| 45 | |
| 46 | if [[ ! -f /srv/salt/scripts/bootstrap.sh ]]; then |
| 47 | echo "ERROR: File /srv/salt/scripts/bootstrap.sh not found" |
| 48 | exit 1 |
| 49 | fi |
| 50 | bash -x /srv/salt/scripts/bootstrap.sh || true |