azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 1 | #!/bin/bash -xe |
| 2 | |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 3 | if [ -f '/done_ubuntu_salt_bootstrap' ]; then |
azvyagintsev | b0daab1 | 2018-06-18 12:35:25 +0300 | [diff] [blame] | 4 | echo "INFO: ubuntu_salt_bootstrap already finished! Skipping.." |
| 5 | exit 0 |
| 6 | fi |
| 7 | # |
azvyagintsev | ffa75b4 | 2018-06-06 20:38:54 +0300 | [diff] [blame] | 8 | CLUSTER_NAME=${CLUSTER_NAME:-lost_cluster_name_variable} |
| 9 | CLUSTER_MODEL=${CLUSTER_MODEL:-https://github.com/Mirantis/mcp-offline-model.git} |
azvyagintsev | c86fbaf | 2018-03-02 18:57:03 +0200 | [diff] [blame] | 10 | CLUSTER_MODEL_REF=${CLUSTER_MODEL_REF:-master} |
| 11 | FORMULA_VERSION=${FORMULA_VERSION:-testing} |
Petr Ruzicka | 9138b18 | 2018-08-22 17:38:30 +0200 | [diff] [blame] | 12 | SALTSTACK_GPG=${SALTSTACK_GPG:-"https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/SALTSTACK-GPG-KEY.pub"} |
| 13 | SALTSTACK_REPO=${SALTSTACK_REPO:-"http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7 xenial main"} |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 14 | APT_MIRANTIS_GPG=${APT_MIRANTIS_GPG:-"http://apt.mirantis.com/public.gpg"} |
Richard Felkl | 4775790 | 2018-03-02 22:44:43 +0100 | [diff] [blame] | 15 | 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] | 16 | 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] | 17 | GIT_SALT_FORMULAS_SCRIPTS_REF=${GIT_SALT_FORMULAS_SCRIPTS_REF:-master} |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 18 | |
| 19 | wget -O - ${SALTSTACK_GPG} | sudo apt-key add - |
| 20 | wget -O - ${APT_MIRANTIS_GPG} | apt-key add - |
azvyagintsev | 4b5603e | 2018-09-14 16:33:14 +0300 | [diff] [blame^] | 21 | echo "deb [arch=amd64] ${SALTSTACK_REPO}" > /etc/apt/sources.list.d/mcp_saltstack.list |
| 22 | # This Pin-Priority fil should be always aligned with |
| 23 | # https://github.com/Mirantis/reclass-system-salt-model/blob/master/linux/system/repo/mcp/apt_mirantis/saltstack.yml |
| 24 | cat <<EOF >> /etc/apt/preferences.d/mcp_saltstack |
| 25 | Package: libsodium18 |
| 26 | Pin: release o=SaltStack |
| 27 | Pin-Priority: 50 |
| 28 | |
| 29 | Package: * |
| 30 | Pin: release o=SaltStack |
| 31 | Pin-Priority: 1100 |
| 32 | EOF |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 33 | apt-get update |
| 34 | apt-get install git-core -y |
alexz | 8c4cfc7 | 2018-03-23 13:56:10 +0100 | [diff] [blame] | 35 | |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 36 | for g_host in ${CLUSTER_MODEL} ${GIT_SALT_FORMULAS_SCRIPTS} ; do |
| 37 | _tmp_host=$(echo ${g_host} | awk -F/ '{print $3}') |
| 38 | ssh-keyscan -T 1 -H ${_tmp_host} >> ~/.ssh/known_hosts || true |
| 39 | done |
| 40 | |
alexz | 8c4cfc7 | 2018-03-23 13:56:10 +0100 | [diff] [blame] | 41 | if [[ ! -d /srv/salt/reclass ]]; then |
| 42 | git clone --recursive ${CLUSTER_MODEL} /srv/salt/reclass |
| 43 | pushd /srv/salt/reclass/ |
| 44 | git checkout ${CLUSTER_MODEL_REF} |
| 45 | popd |
| 46 | fi |
| 47 | |
| 48 | if [[ ! -d /srv/salt/scripts ]]; then |
| 49 | git clone --recursive ${GIT_SALT_FORMULAS_SCRIPTS} /srv/salt/scripts |
| 50 | pushd /srv/salt/scripts/ |
| 51 | git checkout ${GIT_SALT_FORMULAS_SCRIPTS_REF} |
| 52 | popd |
| 53 | fi |
| 54 | |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 55 | # bootstrap.sh opts |
| 56 | export FORMULAS_SOURCE=pkg |
azvyagintsev | ffa75b4 | 2018-06-06 20:38:54 +0300 | [diff] [blame] | 57 | export HOSTNAME=${BS_HOSTNAME:-lost_bs_hostname_variable} |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 58 | export DOMAIN="${CLUSTER_NAME}.local" |
azvyagintsev | bf6d3fd | 2018-07-31 16:08:43 +0300 | [diff] [blame] | 59 | export EXTRA_FORMULAS=${EXTRA_FORMULAS:-"ntp aptly nginx iptables docker git maas jenkins logrotate"} |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 60 | export APT_REPOSITORY=" deb [arch=amd64] ${APT_MIRANTIS_SALT_REPO} " |
| 61 | export APT_REPOSITORY_GPG=${APT_MIRANTIS_GPG} |
azvyagintsev | 0f697cf | 2018-06-22 11:44:13 +0300 | [diff] [blame] | 62 | export SALT_STOPSTART_WAIT=${SALT_STOPSTART_WAIT:-10} |
azvyagintsev | 4b5603e | 2018-09-14 16:33:14 +0300 | [diff] [blame^] | 63 | echo "INFO: build in offline build!" |
| 64 | export BOOTSTRAP_SALTSTACK_COM="file:///tmp/bootstrap.saltstack.com.sh" |
| 65 | # extra opts will push bootstrap script NOT install upstream repos. |
| 66 | export BOOTSTRAP_SALTSTACK_OPTS=${BOOTSTRAP_SALTSTACK_OPTS:- -dXr $BOOTSTRAP_SALTSTACK_VERSION } |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 67 | # |
alexz | 8c4cfc7 | 2018-03-23 13:56:10 +0100 | [diff] [blame] | 68 | |
| 69 | if [[ ! -f /srv/salt/scripts/bootstrap.sh ]]; then |
| 70 | echo "ERROR: File /srv/salt/scripts/bootstrap.sh not found" |
| 71 | exit 1 |
| 72 | fi |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 73 | bash -x /srv/salt/scripts/bootstrap.sh || true |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 74 | touch /done_ubuntu_salt_bootstrap |