blob: fb941c4096fb8370b8d731b41bacf4adfc8d524b [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
7
8echo "Configuring network interfaces"
9envsubst < /root/interfaces > /etc/network/interfaces
10ifdown ens3; ifup ens3
11
12echo "Preparing metadata model"
13mount /dev/cdrom /mnt/
14cp -r /mnt/model/model/* /srv/salt/reclass/
15chown -R root:root /srv/salt/reclass/*
16chmod -R 644 /srv/salt/reclass/classes/cluster/*
17chmod -R 644 /srv/salt/reclass/classes/system/*
18
19echo "updating git repos"
20cp -r /mnt/mk-pipelines/* /home/repo/mk/mk-pipelines/
21cp -r /mnt/mk-pipelines/.git* /home/repo/mk/mk-pipelines/
22cp -r /mnt/pipeline-library/* /home/repo/mcp-ci/pipeline-library/
23cp -r /mnt/pipeline-library/.git* /home/repo/mcp-ci/pipeline-library/
24chown -R git:www-data /home/repo/mk/mk-pipelines/*
25chown -R git:www-data /home/repo/mk/mk-pipelines/.git*
26chown -R git:www-data /home/repo/mcp-ci/pipeline-library/*
27chown -R git:www-data /home/repo/mcp-ci/pipeline-library/.git*
28umount /dev/cdrom
29
30echo "Configuring salt"
31#service salt-master restart
32envsubst < /root/minion.conf > /etc/salt/minion.d/minion.conf
33service salt-minion restart
34while true; do
35 salt-key | grep "$SALT_MASTER_MINION_ID" && break
36 sleep 5
37done
38sleep 5
39for i in `salt-key -l accepted | grep -v Accepted | grep -v "$SALT_MASTER_MINION_ID"`; do
40 salt-key -d $i -y
41done
42
43find /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'
44
45salt-call saltutil.refresh_pillar
46salt-call saltutil.sync_all
47salt-call state.sls linux.network,linux,openssh,salt
48salt-call state.sls maas.cluster,maas.region,reclass
49
50ssh-keyscan cfg01 > /var/lib/jenkins/.ssh/known_hosts
51
52reboot