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