blob: 10699f4ee7e0d09dbfeaf1b359f00e9f8661919e [file] [log] [blame]
#!/bin/bash -xe
export SALT_MASTER_DEPLOY_IP=172.16.164.15
export SALT_MASTER_MINION_ID=cfg01.deploy-name.local
export DEPLOY_NETWORK_GW=172.16.164.1
export DEPLOY_NETWORK_NETMASK=255.255.255.192
export DNS_SERVERS=8.8.8.8
export SYSTEM_URL=https://github.com/Mirantis/reclass-system-salt-model.git
rm -vf /etc/update-motd.d/52-info
echo "Configuring network interfaces"
find /etc/network/interfaces.d/ -type f -delete
kill $(pidof /sbin/dhclient) || /bin/true
envsubst < /root/interfaces > /etc/network/interfaces
ip a flush dev ens3
rm -f /var/run/network/ifstate.ens3
if [[ $(grep -E '^\ *gateway\ ' /etc/network/interfaces) ]]; then
(ip r s | grep ^default) && ip r d default || /bin/true
fi;
ifup ens3
echo "Preparing metadata model"
mount /dev/cdrom /mnt/
cp -r /mnt/model/model/* /srv/salt/reclass/
cp -r /mnt/model/model/.git /srv/salt/reclass/
envsubst < /root/gitmodules > /srv/salt/reclass/.gitmodules
cd /srv/salt/reclass/classes/system/
git remote remove origin
git remote add origin $SYSTEM_URL
cd /srv/salt/reclass/
git submodule update --init --recursive
chown -R root:root /srv/salt/reclass/*
chown -R root:root /srv/salt/reclass/.git*
chmod -R 644 /srv/salt/reclass/classes/cluster/*
chmod -R 644 /srv/salt/reclass/classes/system/*
echo "updating git repos"
cp -r /mnt/mk-pipelines/* /home/repo/mk/mk-pipelines/
cp -r /mnt/mk-pipelines/.git* /home/repo/mk/mk-pipelines/
cp -r /mnt/pipeline-library/* /home/repo/mcp-ci/pipeline-library/
cp -r /mnt/pipeline-library/.git* /home/repo/mcp-ci/pipeline-library/
chown -R git:www-data /home/repo/mk/mk-pipelines/*
chown -R git:www-data /home/repo/mk/mk-pipelines/.git*
chown -R git:www-data /home/repo/mcp-ci/pipeline-library/*
chown -R git:www-data /home/repo/mcp-ci/pipeline-library/.git*
umount /dev/cdrom
echo "Configuring salt"
#service salt-master restart
envsubst < /root/minion.conf > /etc/salt/minion.d/minion.conf
service salt-minion restart
while true; do
salt-key | grep "$SALT_MASTER_MINION_ID" && break
sleep 5
done
sleep 5
for i in `salt-key -l accepted | grep -v Accepted | grep -v "$SALT_MASTER_MINION_ID"`; do
salt-key -d $i -y
done
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'
salt-call saltutil.refresh_pillar
salt-call saltutil.sync_all
salt-call state.sls linux.network,linux,openssh,salt
salt-call state.sls maas.cluster,maas.region,reclass
ssh-keyscan cfg01 > /var/lib/jenkins/.ssh/known_hosts
reboot