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