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