blob: a131f3e8246f95ef28b691f4c70f39a5d6ee126f [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
12rm /var/run/network/ifstate.ens3
13ifup ens3
Richard Felkl4c4829d2017-11-11 00:12:20 +010014
15echo "Preparing metadata model"
16mount /dev/cdrom /mnt/
17cp -r /mnt/model/model/* /srv/salt/reclass/
Jiri Broulikff52d682017-11-22 14:39:08 +010018cp -r /mnt/model/model/.git /srv/salt/reclass/
19envsubst < /root/gitmodules > /srv/salt/reclass/.gitmodules
20cd /srv/salt/reclass/classes/system/
21git remote remove origin
22git remote add origin $SYSTEM_URL
23cd /srv/salt/reclass/
24git submodule update --init --recursive
Richard Felkl4c4829d2017-11-11 00:12:20 +010025chown -R root:root /srv/salt/reclass/*
Jiri Broulikff52d682017-11-22 14:39:08 +010026chown -R root:root /srv/salt/reclass/.git*
Richard Felkl4c4829d2017-11-11 00:12:20 +010027chmod -R 644 /srv/salt/reclass/classes/cluster/*
28chmod -R 644 /srv/salt/reclass/classes/system/*
29
30echo "updating git repos"
31cp -r /mnt/mk-pipelines/* /home/repo/mk/mk-pipelines/
32cp -r /mnt/mk-pipelines/.git* /home/repo/mk/mk-pipelines/
33cp -r /mnt/pipeline-library/* /home/repo/mcp-ci/pipeline-library/
34cp -r /mnt/pipeline-library/.git* /home/repo/mcp-ci/pipeline-library/
35chown -R git:www-data /home/repo/mk/mk-pipelines/*
36chown -R git:www-data /home/repo/mk/mk-pipelines/.git*
37chown -R git:www-data /home/repo/mcp-ci/pipeline-library/*
38chown -R git:www-data /home/repo/mcp-ci/pipeline-library/.git*
39umount /dev/cdrom
40
41echo "Configuring salt"
42#service salt-master restart
43envsubst < /root/minion.conf > /etc/salt/minion.d/minion.conf
44service salt-minion restart
45while true; do
46 salt-key | grep "$SALT_MASTER_MINION_ID" && break
47 sleep 5
48done
49sleep 5
50for i in `salt-key -l accepted | grep -v Accepted | grep -v "$SALT_MASTER_MINION_ID"`; do
51 salt-key -d $i -y
52done
53
54find /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'
55
56salt-call saltutil.refresh_pillar
57salt-call saltutil.sync_all
58salt-call state.sls linux.network,linux,openssh,salt
59salt-call state.sls maas.cluster,maas.region,reclass
60
61ssh-keyscan cfg01 > /var/lib/jenkins/.ssh/known_hosts
62
Dmitry Stremkouskia94b5f32017-12-02 00:41:54 +030063reboot