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