blob: 4b24c27bb1b5614a0b2684c1ae41031e4aa158d3 [file] [log] [blame]
azvyagintsev6d453852018-02-26 16:56:37 +02001#!/bin/bash -xe
2
azvyagintsev29410ee2018-07-12 20:02:30 +03003if [ -f '/done_ubuntu_salt_bootstrap' ]; then
azvyagintsevb0daab12018-06-18 12:35:25 +03004 echo "INFO: ubuntu_salt_bootstrap already finished! Skipping.."
5 exit 0
6fi
7#
azvyagintsevffa75b42018-06-06 20:38:54 +03008CLUSTER_NAME=${CLUSTER_NAME:-lost_cluster_name_variable}
Ivan Berezovskiybd80ff42018-11-30 14:38:02 +04009MCP_VERSION=${MCP_VERSION:-testing}
Petr Ruzicka9138b182018-08-22 17:38:30 +020010SALTSTACK_GPG=${SALTSTACK_GPG:-"https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/SALTSTACK-GPG-KEY.pub"}
11SALTSTACK_REPO=${SALTSTACK_REPO:-"http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7 xenial main"}
Ivan Berezovskiy7630eaf2018-12-17 16:33:14 +040012APT_MIRANTIS_SALT_GPG=${APT_MIRANTIS_SALT_GPG:-"http://mirror.mirantis.com/${MCP_VERSION}/salt-formulas/xenial/archive-salt-formulas.key"}
13APT_MIRANTIS_SALT_REPO=${APT_MIRANTIS_SALT_REPO:-"deb [arch=amd64] http://mirror.mirantis.com/${MCP_VERSION}/salt-formulas/xenial xenial main"}
azvyagintsev6d453852018-02-26 16:56:37 +020014
azvyagintsev22dfc862018-09-25 13:20:05 +030015function process_repos(){
azvyagintsev2397e552018-10-04 11:25:18 +030016# TODO: those should be unhardcoded and re-writed, using CC model
azvyagintsev6d453852018-02-26 16:56:37 +020017wget -O - ${SALTSTACK_GPG} | sudo apt-key add -
Ivan Berezovskiy7630eaf2018-12-17 16:33:14 +040018wget -O - ${APT_MIRANTIS_SALT_GPG} | apt-key add -
Ivan Berezovskiybd80ff42018-11-30 14:38:02 +040019wget -O - http://mirror.mirantis.com/${MCP_VERSION}/extra/xenial/archive-extra.key | apt-key add -
azvyagintsevb1bcb8d2018-09-26 18:03:14 +030020
azvyagintsev4b5603e2018-09-14 16:33:14 +030021echo "deb [arch=amd64] ${SALTSTACK_REPO}" > /etc/apt/sources.list.d/mcp_saltstack.list
Ivan Berezovskiybd80ff42018-11-30 14:38:02 +040022echo "deb [arch=amd64] http://mirror.mirantis.com/${MCP_VERSION}/extra/xenial xenial main" > /etc/apt/sources.list.d/mcp_extra.list
azvyagintsevb1bcb8d2018-09-26 18:03:14 +030023
azvyagintsev22dfc862018-09-25 13:20:05 +030024# This Pin-Priority fix should be always aligned with
azvyagintsev4b5603e2018-09-14 16:33:14 +030025# https://github.com/Mirantis/reclass-system-salt-model/blob/master/linux/system/repo/mcp/apt_mirantis/saltstack.yml
azvyagintsev22dfc862018-09-25 13:20:05 +030026# saltstack
azvyagintsev4b5603e2018-09-14 16:33:14 +030027cat <<EOF >> /etc/apt/preferences.d/mcp_saltstack
28Package: libsodium18
29Pin: release o=SaltStack
30Pin-Priority: 50
31
32Package: *
33Pin: release o=SaltStack
34Pin-Priority: 1100
35EOF
azvyagintsev22dfc862018-09-25 13:20:05 +030036# reclass
37cat <<EOF >> /etc/apt/preferences.d/mcp_extra
38Package: *
39Pin: release o=Mirantis
40Pin-Priority: 1100
41EOF
42}
43
44process_repos
azvyagintsev6d453852018-02-26 16:56:37 +020045apt-get update
azvyagintsev22dfc862018-09-25 13:20:05 +030046apt-get install git-core reclass -y
alexz8c4cfc72018-03-23 13:56:10 +010047
azvyagintsevb1bcb8d2018-09-26 18:03:14 +030048rm -v /etc/apt/sources.list.d/mcp_extra.list /etc/apt/preferences.d/mcp_extra
49
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040050[ ! -d /srv/salt ] && mkdir -p /srv/salt
51mount /dev/cdrom /mnt
alexz8c4cfc72018-03-23 13:56:10 +010052if [[ ! -d /srv/salt/reclass ]]; then
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040053 cp -r /mnt/model /srv/salt/reclass
alexz8c4cfc72018-03-23 13:56:10 +010054fi
55
56if [[ ! -d /srv/salt/scripts ]]; then
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040057 cp -r /mnt/salt_scripts /srv/salt/scripts
alexz8c4cfc72018-03-23 13:56:10 +010058fi
Ivan Berezovskiy23035a22018-11-14 13:25:51 +040059umount /mnt
alexz8c4cfc72018-03-23 13:56:10 +010060
azvyagintsev6d453852018-02-26 16:56:37 +020061# bootstrap.sh opts
62export FORMULAS_SOURCE=pkg
azvyagintsevffa75b42018-06-06 20:38:54 +030063export HOSTNAME=${BS_HOSTNAME:-lost_bs_hostname_variable}
azvyagintsev6d453852018-02-26 16:56:37 +020064export DOMAIN="${CLUSTER_NAME}.local"
Ivan Berezovskiyc46e7c02018-10-29 18:22:09 +040065export EXTRA_FORMULAS=${EXTRA_FORMULAS:-"aptly docker gerrit git iptables jenkins keycloak logrotate maas ntp nginx openldap sphinx"}
azvyagintsev6d453852018-02-26 16:56:37 +020066export APT_REPOSITORY=" deb [arch=amd64] ${APT_MIRANTIS_SALT_REPO} "
Ivan Berezovskiy7630eaf2018-12-17 16:33:14 +040067export APT_REPOSITORY_GPG=${APT_MIRANTIS_SALT_GPG}
azvyagintsev0f697cf2018-06-22 11:44:13 +030068export SALT_STOPSTART_WAIT=${SALT_STOPSTART_WAIT:-10}
azvyagintsev4b5603e2018-09-14 16:33:14 +030069echo "INFO: build in offline build!"
Ivan Berezovskiyc46e7c02018-10-29 18:22:09 +040070export BOOTSTRAP_SALTSTACK_COM=${BOOTSTRAP_SALTSTACK_COM:-"file:///tmp/bootstrap.saltstack.com.sh"}
azvyagintsev4b5603e2018-09-14 16:33:14 +030071# extra opts will push bootstrap script NOT install upstream repos.
72export BOOTSTRAP_SALTSTACK_OPTS=${BOOTSTRAP_SALTSTACK_OPTS:- -dXr $BOOTSTRAP_SALTSTACK_VERSION }
azvyagintsev6d453852018-02-26 16:56:37 +020073#
alexz8c4cfc72018-03-23 13:56:10 +010074
75if [[ ! -f /srv/salt/scripts/bootstrap.sh ]]; then
76 echo "ERROR: File /srv/salt/scripts/bootstrap.sh not found"
77 exit 1
78fi
azvyagintsev6d453852018-02-26 16:56:37 +020079bash -x /srv/salt/scripts/bootstrap.sh || true
azvyagintsev29410ee2018-07-12 20:02:30 +030080touch /done_ubuntu_salt_bootstrap