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} |
Ivan Berezovskiy | bd80ff4 | 2018-11-30 14:38:02 +0400 | [diff] [blame] | 9 | MCP_VERSION=${MCP_VERSION:-testing} |
Petr Ruzicka | 9138b18 | 2018-08-22 17:38:30 +0200 | [diff] [blame] | 10 | SALTSTACK_GPG=${SALTSTACK_GPG:-"https://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7/SALTSTACK-GPG-KEY.pub"} |
| 11 | SALTSTACK_REPO=${SALTSTACK_REPO:-"http://repo.saltstack.com/apt/ubuntu/16.04/amd64/2017.7 xenial main"} |
Ivan Berezovskiy | 7630eaf | 2018-12-17 16:33:14 +0400 | [diff] [blame] | 12 | APT_MIRANTIS_SALT_GPG=${APT_MIRANTIS_SALT_GPG:-"http://mirror.mirantis.com/${MCP_VERSION}/salt-formulas/xenial/archive-salt-formulas.key"} |
| 13 | APT_MIRANTIS_SALT_REPO=${APT_MIRANTIS_SALT_REPO:-"deb [arch=amd64] http://mirror.mirantis.com/${MCP_VERSION}/salt-formulas/xenial xenial main"} |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 14 | |
azvyagintsev | 22dfc86 | 2018-09-25 13:20:05 +0300 | [diff] [blame] | 15 | function process_repos(){ |
azvyagintsev | 2397e55 | 2018-10-04 11:25:18 +0300 | [diff] [blame] | 16 | # TODO: those should be unhardcoded and re-writed, using CC model |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 17 | wget -O - ${SALTSTACK_GPG} | sudo apt-key add - |
Ivan Berezovskiy | 7630eaf | 2018-12-17 16:33:14 +0400 | [diff] [blame] | 18 | wget -O - ${APT_MIRANTIS_SALT_GPG} | apt-key add - |
Ivan Berezovskiy | bd80ff4 | 2018-11-30 14:38:02 +0400 | [diff] [blame] | 19 | wget -O - http://mirror.mirantis.com/${MCP_VERSION}/extra/xenial/archive-extra.key | apt-key add - |
azvyagintsev | b1bcb8d | 2018-09-26 18:03:14 +0300 | [diff] [blame] | 20 | |
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 |
Ivan Berezovskiy | bd80ff4 | 2018-11-30 14:38:02 +0400 | [diff] [blame] | 22 | echo "deb [arch=amd64] http://mirror.mirantis.com/${MCP_VERSION}/extra/xenial xenial main" > /etc/apt/sources.list.d/mcp_extra.list |
azvyagintsev | b1bcb8d | 2018-09-26 18:03:14 +0300 | [diff] [blame] | 23 | |
azvyagintsev | 22dfc86 | 2018-09-25 13:20:05 +0300 | [diff] [blame] | 24 | # This Pin-Priority fix should be always aligned with |
azvyagintsev | 4b5603e | 2018-09-14 16:33:14 +0300 | [diff] [blame] | 25 | # https://github.com/Mirantis/reclass-system-salt-model/blob/master/linux/system/repo/mcp/apt_mirantis/saltstack.yml |
azvyagintsev | 22dfc86 | 2018-09-25 13:20:05 +0300 | [diff] [blame] | 26 | # saltstack |
azvyagintsev | 4b5603e | 2018-09-14 16:33:14 +0300 | [diff] [blame] | 27 | cat <<EOF >> /etc/apt/preferences.d/mcp_saltstack |
| 28 | Package: libsodium18 |
| 29 | Pin: release o=SaltStack |
| 30 | Pin-Priority: 50 |
| 31 | |
| 32 | Package: * |
| 33 | Pin: release o=SaltStack |
| 34 | Pin-Priority: 1100 |
| 35 | EOF |
azvyagintsev | 22dfc86 | 2018-09-25 13:20:05 +0300 | [diff] [blame] | 36 | # reclass |
| 37 | cat <<EOF >> /etc/apt/preferences.d/mcp_extra |
| 38 | Package: * |
| 39 | Pin: release o=Mirantis |
| 40 | Pin-Priority: 1100 |
| 41 | EOF |
| 42 | } |
| 43 | |
| 44 | process_repos |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 45 | apt-get update |
azvyagintsev | 22dfc86 | 2018-09-25 13:20:05 +0300 | [diff] [blame] | 46 | apt-get install git-core reclass -y |
alexz | 8c4cfc7 | 2018-03-23 13:56:10 +0100 | [diff] [blame] | 47 | |
azvyagintsev | b1bcb8d | 2018-09-26 18:03:14 +0300 | [diff] [blame] | 48 | rm -v /etc/apt/sources.list.d/mcp_extra.list /etc/apt/preferences.d/mcp_extra |
| 49 | |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 50 | [ ! -d /srv/salt ] && mkdir -p /srv/salt |
| 51 | mount /dev/cdrom /mnt |
alexz | 8c4cfc7 | 2018-03-23 13:56:10 +0100 | [diff] [blame] | 52 | if [[ ! -d /srv/salt/reclass ]]; then |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 53 | cp -r /mnt/model /srv/salt/reclass |
alexz | 8c4cfc7 | 2018-03-23 13:56:10 +0100 | [diff] [blame] | 54 | fi |
| 55 | |
| 56 | if [[ ! -d /srv/salt/scripts ]]; then |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 57 | cp -r /mnt/salt_scripts /srv/salt/scripts |
alexz | 8c4cfc7 | 2018-03-23 13:56:10 +0100 | [diff] [blame] | 58 | fi |
Ivan Berezovskiy | 23035a2 | 2018-11-14 13:25:51 +0400 | [diff] [blame] | 59 | umount /mnt |
alexz | 8c4cfc7 | 2018-03-23 13:56:10 +0100 | [diff] [blame] | 60 | |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 61 | # bootstrap.sh opts |
| 62 | export FORMULAS_SOURCE=pkg |
azvyagintsev | ffa75b4 | 2018-06-06 20:38:54 +0300 | [diff] [blame] | 63 | export HOSTNAME=${BS_HOSTNAME:-lost_bs_hostname_variable} |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 64 | export DOMAIN="${CLUSTER_NAME}.local" |
Ivan Berezovskiy | c46e7c0 | 2018-10-29 18:22:09 +0400 | [diff] [blame] | 65 | export EXTRA_FORMULAS=${EXTRA_FORMULAS:-"aptly docker gerrit git iptables jenkins keycloak logrotate maas ntp nginx openldap sphinx"} |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 66 | export APT_REPOSITORY=" deb [arch=amd64] ${APT_MIRANTIS_SALT_REPO} " |
Ivan Berezovskiy | 7630eaf | 2018-12-17 16:33:14 +0400 | [diff] [blame] | 67 | export APT_REPOSITORY_GPG=${APT_MIRANTIS_SALT_GPG} |
azvyagintsev | 0f697cf | 2018-06-22 11:44:13 +0300 | [diff] [blame] | 68 | export SALT_STOPSTART_WAIT=${SALT_STOPSTART_WAIT:-10} |
azvyagintsev | 4b5603e | 2018-09-14 16:33:14 +0300 | [diff] [blame] | 69 | echo "INFO: build in offline build!" |
Ivan Berezovskiy | c46e7c0 | 2018-10-29 18:22:09 +0400 | [diff] [blame] | 70 | export BOOTSTRAP_SALTSTACK_COM=${BOOTSTRAP_SALTSTACK_COM:-"file:///tmp/bootstrap.saltstack.com.sh"} |
azvyagintsev | 4b5603e | 2018-09-14 16:33:14 +0300 | [diff] [blame] | 71 | # extra opts will push bootstrap script NOT install upstream repos. |
| 72 | export BOOTSTRAP_SALTSTACK_OPTS=${BOOTSTRAP_SALTSTACK_OPTS:- -dXr $BOOTSTRAP_SALTSTACK_VERSION } |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 73 | # |
alexz | 8c4cfc7 | 2018-03-23 13:56:10 +0100 | [diff] [blame] | 74 | |
| 75 | if [[ ! -f /srv/salt/scripts/bootstrap.sh ]]; then |
| 76 | echo "ERROR: File /srv/salt/scripts/bootstrap.sh not found" |
| 77 | exit 1 |
| 78 | fi |
azvyagintsev | 6d45385 | 2018-02-26 16:56:37 +0200 | [diff] [blame] | 79 | bash -x /srv/salt/scripts/bootstrap.sh || true |
azvyagintsev | 29410ee | 2018-07-12 20:02:30 +0300 | [diff] [blame] | 80 | touch /done_ubuntu_salt_bootstrap |