blob: 3211b27f316e56b09b4d9bb9ae2deeb5d302b978 [file] [log] [blame]
Richard Felkl4c4829d2017-11-11 00:12:20 +01001#!/bin/bash -xe
2export SALT_MASTER_DEPLOY_IP=172.16.164.15
3export SALT_MASTER_MINION_ID=cfg01.deploy-name.local
4export DEPLOY_NETWORK_GW=172.16.164.1
5export DEPLOY_NETWORK_NETMASK=255.255.255.192
6export DNS_SERVERS=8.8.8.8
Jiri Broulikff52d682017-11-22 14:39:08 +01007export SYSTEM_URL=https://github.com/Mirantis/reclass-system-salt-model.git
Jiri Broulikcee20532018-01-08 13:30:15 +01008export http_proxy=
9export https_proxy=
10export PIPELINES_FROM_ISO=true
11export PIPELINE_REPO_URL=https://github.com/Mirantis
12#for cloning from aptly image use port 8088
13#export PIPELINE_REPO_URL=http://172.16.47.182:8088
Richard Felkl4c4829d2017-11-11 00:12:20 +010014
Jiri Broulikfd84eeb2017-12-13 11:22:00 +010015rm -vf /etc/update-motd.d/52-info
Richard Felkl4c4829d2017-11-11 00:12:20 +010016echo "Configuring network interfaces"
Dmitry Stremkouskif50ea262017-12-05 19:35:40 +030017find /etc/network/interfaces.d/ -type f -delete
18kill $(pidof /sbin/dhclient) || /bin/true
Richard Felkl4c4829d2017-11-11 00:12:20 +010019envsubst < /root/interfaces > /etc/network/interfaces
Dmitry Stremkouskia94b5f32017-12-02 00:41:54 +030020ip a flush dev ens3
Dmitry Stremkouskib43c4ee2017-12-02 02:21:05 +030021rm -f /var/run/network/ifstate.ens3
22if [[ $(grep -E '^\ *gateway\ ' /etc/network/interfaces) ]]; then
23(ip r s | grep ^default) && ip r d default || /bin/true
24fi;
Dmitry Stremkouskia94b5f32017-12-02 00:41:54 +030025ifup ens3
Richard Felkl4c4829d2017-11-11 00:12:20 +010026
27echo "Preparing metadata model"
28mount /dev/cdrom /mnt/
29cp -r /mnt/model/model/* /srv/salt/reclass/
Jiri Broulikff52d682017-11-22 14:39:08 +010030cp -r /mnt/model/model/.git /srv/salt/reclass/
31envsubst < /root/gitmodules > /srv/salt/reclass/.gitmodules
32cd /srv/salt/reclass/classes/system/
33git remote remove origin
34git remote add origin $SYSTEM_URL
35cd /srv/salt/reclass/
36git submodule update --init --recursive
Richard Felkl4c4829d2017-11-11 00:12:20 +010037chown -R root:root /srv/salt/reclass/*
Jiri Broulikff52d682017-11-22 14:39:08 +010038chown -R root:root /srv/salt/reclass/.git*
Richard Felkl4c4829d2017-11-11 00:12:20 +010039chmod -R 644 /srv/salt/reclass/classes/cluster/*
40chmod -R 644 /srv/salt/reclass/classes/system/*
41
Richard Felkl4c4829d2017-11-11 00:12:20 +010042echo "Configuring salt"
43#service salt-master restart
44envsubst < /root/minion.conf > /etc/salt/minion.d/minion.conf
45service salt-minion restart
46while true; do
47 salt-key | grep "$SALT_MASTER_MINION_ID" && break
48 sleep 5
49done
50sleep 5
51for i in `salt-key -l accepted | grep -v Accepted | grep -v "$SALT_MASTER_MINION_ID"`; do
52 salt-key -d $i -y
53done
54
55find /var/lib/jenkins/jenkins.model.JenkinsLocationConfiguration.xml -type f -print0 | xargs -0 sed -i -e 's/10.167.4.15/'$SALT_MASTER_DEPLOY_IP'/g'
56
Jiri Broulikcee20532018-01-08 13:30:15 +010057echo "updating git repos"
58if [ "$PIPELINES_FROM_ISO" = true ] ; then
59 cp -r /mnt/mk-pipelines/* /home/repo/mk/mk-pipelines/
60 cp -r /mnt/pipeline-library/* /home/repo/mcp-ci/pipeline-library/
61 chown -R git:www-data /home/repo/mk/mk-pipelines/*
62 chown -R git:www-data /home/repo/mcp-ci/pipeline-library/*
63else
64 git clone --mirror $PIPELINE_REPO_URL/mk-pipelines.git /home/repo/mk/mk-pipelines/
65 git clone --mirror $PIPELINE_REPO_URL/pipeline-library.git /home/repo/mcp-ci/pipeline-library/
66 chown -R git:www-data /home/repo/mk/mk-pipelines/*
67 chown -R git:www-data /home/repo/mcp-ci/pipeline-library/*
68fi
69
70umount /dev/cdrom
71
Richard Felkl4c4829d2017-11-11 00:12:20 +010072salt-call saltutil.refresh_pillar
73salt-call saltutil.sync_all
74salt-call state.sls linux.network,linux,openssh,salt
75salt-call state.sls maas.cluster,maas.region,reclass
76
77ssh-keyscan cfg01 > /var/lib/jenkins/.ssh/known_hosts
78
Dmitry Stremkouskia94b5f32017-12-02 00:41:54 +030079reboot