blob: 9e76b5be9e2e808687e1da77611d2d89676e488c [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 Broulikcee20532018-01-08 13:30:15 +01007export http_proxy=
8export https_proxy=
9export PIPELINES_FROM_ISO=true
10export PIPELINE_REPO_URL=https://github.com/Mirantis
11#for cloning from aptly image use port 8088
12#export PIPELINE_REPO_URL=http://172.16.47.182:8088
Richard Felkl4c4829d2017-11-11 00:12:20 +010013
Jiri Broulikfd84eeb2017-12-13 11:22:00 +010014rm -vf /etc/update-motd.d/52-info
Richard Felkl4c4829d2017-11-11 00:12:20 +010015echo "Configuring network interfaces"
Dmitry Stremkouskif50ea262017-12-05 19:35:40 +030016find /etc/network/interfaces.d/ -type f -delete
17kill $(pidof /sbin/dhclient) || /bin/true
Richard Felkl4c4829d2017-11-11 00:12:20 +010018envsubst < /root/interfaces > /etc/network/interfaces
Dmitry Stremkouskia94b5f32017-12-02 00:41:54 +030019ip a flush dev ens3
Dmitry Stremkouskib43c4ee2017-12-02 02:21:05 +030020rm -f /var/run/network/ifstate.ens3
21if [[ $(grep -E '^\ *gateway\ ' /etc/network/interfaces) ]]; then
22(ip r s | grep ^default) && ip r d default || /bin/true
23fi;
Dmitry Stremkouskia94b5f32017-12-02 00:41:54 +030024ifup ens3
Richard Felkl4c4829d2017-11-11 00:12:20 +010025
26echo "Preparing metadata model"
27mount /dev/cdrom /mnt/
Leontii Istomine2532062018-02-21 13:00:47 +010028cp -rT /mnt/model/model/* /srv/salt/reclass/
Richard Felkl4c4829d2017-11-11 00:12:20 +010029chown -R root:root /srv/salt/reclass/*
Jiri Broulikff52d682017-11-22 14:39:08 +010030chown -R root:root /srv/salt/reclass/.git*
Richard Felkl4c4829d2017-11-11 00:12:20 +010031chmod -R 644 /srv/salt/reclass/classes/cluster/*
32chmod -R 644 /srv/salt/reclass/classes/system/*
33
Richard Felkl4c4829d2017-11-11 00:12:20 +010034echo "Configuring salt"
35#service salt-master restart
36envsubst < /root/minion.conf > /etc/salt/minion.d/minion.conf
37service salt-minion restart
38while true; do
39 salt-key | grep "$SALT_MASTER_MINION_ID" && break
40 sleep 5
41done
42sleep 5
43for i in `salt-key -l accepted | grep -v Accepted | grep -v "$SALT_MASTER_MINION_ID"`; do
44 salt-key -d $i -y
45done
46
47find /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'
48
Jiri Broulikcee20532018-01-08 13:30:15 +010049echo "updating git repos"
50if [ "$PIPELINES_FROM_ISO" = true ] ; then
51 cp -r /mnt/mk-pipelines/* /home/repo/mk/mk-pipelines/
52 cp -r /mnt/pipeline-library/* /home/repo/mcp-ci/pipeline-library/
Jiri Broulik739bd352018-01-09 15:26:15 +010053 umount /dev/cdrom
Jiri Broulikcee20532018-01-08 13:30:15 +010054 chown -R git:www-data /home/repo/mk/mk-pipelines/*
55 chown -R git:www-data /home/repo/mcp-ci/pipeline-library/*
56else
Jiri Broulik739bd352018-01-09 15:26:15 +010057 umount /dev/cdrom
Jiri Broulikcee20532018-01-08 13:30:15 +010058 git clone --mirror $PIPELINE_REPO_URL/mk-pipelines.git /home/repo/mk/mk-pipelines/
59 git clone --mirror $PIPELINE_REPO_URL/pipeline-library.git /home/repo/mcp-ci/pipeline-library/
60 chown -R git:www-data /home/repo/mk/mk-pipelines/*
61 chown -R git:www-data /home/repo/mcp-ci/pipeline-library/*
62fi
63
Richard Felkl4c4829d2017-11-11 00:12:20 +010064salt-call saltutil.refresh_pillar
65salt-call saltutil.sync_all
66salt-call state.sls linux.network,linux,openssh,salt
67salt-call state.sls maas.cluster,maas.region,reclass
68
Jiri Broulik1261ca32018-01-18 15:30:25 +010069ssh-keyscan cfg01 > /var/lib/jenkins/.ssh/known_hosts
70
Jiri Broulike40813f2018-01-16 13:35:19 +010071pillar=`salt-call pillar.data jenkins:client`
72
73if [[ $pillar == *"job"* ]]; then
74 salt-call state.sls jenkins.client
75fi
Richard Felkl4c4829d2017-11-11 00:12:20 +010076
Dmitry Stremkouskia94b5f32017-12-02 00:41:54 +030077reboot