blob: 50a74d57f2cb453810970473211979e3e26250e5 [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
Richard Felkl4c4829d2017-11-11 00:12:20 +01008
9echo "Configuring network interfaces"
Dmitry Stremkouskif50ea262017-12-05 19:35:40 +030010find /etc/network/interfaces.d/ -type f -delete
11kill $(pidof /sbin/dhclient) || /bin/true
Richard Felkl4c4829d2017-11-11 00:12:20 +010012envsubst < /root/interfaces > /etc/network/interfaces
Dmitry Stremkouskia94b5f32017-12-02 00:41:54 +030013ip a flush dev ens3
Dmitry Stremkouskib43c4ee2017-12-02 02:21:05 +030014rm -f /var/run/network/ifstate.ens3
15if [[ $(grep -E '^\ *gateway\ ' /etc/network/interfaces) ]]; then
16(ip r s | grep ^default) && ip r d default || /bin/true
17fi;
Dmitry Stremkouskia94b5f32017-12-02 00:41:54 +030018ifup ens3
Richard Felkl4c4829d2017-11-11 00:12:20 +010019
20echo "Preparing metadata model"
21mount /dev/cdrom /mnt/
22cp -r /mnt/model/model/* /srv/salt/reclass/
Jiri Broulikff52d682017-11-22 14:39:08 +010023cp -r /mnt/model/model/.git /srv/salt/reclass/
24envsubst < /root/gitmodules > /srv/salt/reclass/.gitmodules
25cd /srv/salt/reclass/classes/system/
26git remote remove origin
27git remote add origin $SYSTEM_URL
28cd /srv/salt/reclass/
29git submodule update --init --recursive
Richard Felkl4c4829d2017-11-11 00:12:20 +010030chown -R root:root /srv/salt/reclass/*
Jiri Broulikff52d682017-11-22 14:39:08 +010031chown -R root:root /srv/salt/reclass/.git*
Richard Felkl4c4829d2017-11-11 00:12:20 +010032chmod -R 644 /srv/salt/reclass/classes/cluster/*
33chmod -R 644 /srv/salt/reclass/classes/system/*
34
35echo "updating git repos"
36cp -r /mnt/mk-pipelines/* /home/repo/mk/mk-pipelines/
37cp -r /mnt/mk-pipelines/.git* /home/repo/mk/mk-pipelines/
38cp -r /mnt/pipeline-library/* /home/repo/mcp-ci/pipeline-library/
39cp -r /mnt/pipeline-library/.git* /home/repo/mcp-ci/pipeline-library/
40chown -R git:www-data /home/repo/mk/mk-pipelines/*
41chown -R git:www-data /home/repo/mk/mk-pipelines/.git*
42chown -R git:www-data /home/repo/mcp-ci/pipeline-library/*
43chown -R git:www-data /home/repo/mcp-ci/pipeline-library/.git*
44umount /dev/cdrom
45
46echo "Configuring salt"
47#service salt-master restart
48envsubst < /root/minion.conf > /etc/salt/minion.d/minion.conf
49service salt-minion restart
50while true; do
51 salt-key | grep "$SALT_MASTER_MINION_ID" && break
52 sleep 5
53done
54sleep 5
55for i in `salt-key -l accepted | grep -v Accepted | grep -v "$SALT_MASTER_MINION_ID"`; do
56 salt-key -d $i -y
57done
58
59find /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'
60
61salt-call saltutil.refresh_pillar
62salt-call saltutil.sync_all
63salt-call state.sls linux.network,linux,openssh,salt
64salt-call state.sls maas.cluster,maas.region,reclass
65
66ssh-keyscan cfg01 > /var/lib/jenkins/.ssh/known_hosts
67
Dmitry Stremkouskia94b5f32017-12-02 00:41:54 +030068reboot