2 ##############################################################################
3 # Copyright (c) 2017 Mirantis Inc., Enea AB and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 CI_DEBUG=${CI_DEBUG:-0}; [[ "${CI_DEBUG}" =~ (false|0) ]] || set -x
12 # shellcheck disable=SC1090
13 source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/lib.sh"
15 # patch the networking module for Debian based distros
16 debian_ip_source=/usr/lib/python2.7/dist-packages/salt/modules/debian_ip.py
17 salt -C 'kvm* or cmp*' file.line $debian_ip_source \
18 content='iface = iface.lower()' mode='delete'
20 salt -C 'kvm* or cmp*' file.replace $debian_ip_source \
21 pattern="^\s{8}__salt__\['pkg.install'\]\('vlan'\)" \
22 repl="\n if not __salt__['pkg.version']('vlan'):\n __salt__['pkg.install']('vlan')"
24 salt -C 'kvm*' pkg.install bridge-utils
25 salt -C 'kvm*' state.apply linux.network
26 salt -C 'cmp*' state.apply linux.system
27 salt -C 'cmp*' state.apply linux.network || true
28 salt -C 'kvm* or cmp*' system.reboot
29 wait_for 90 "! salt -C 'kvm* or cmp*' test.ping | " \
30 "tee /dev/stderr | grep -Fq 'Not connected'"
32 salt -C '* and not cfg01* and not mas01*' state.apply linux,ntp
34 wait_for 5 "salt -C 'kvm*' state.sls libvirt"
36 salt -C '* and not cfg01* and not mas01*' state.apply salt
37 salt -C 'kvm*' saltutil.sync_all
38 wait_for 10 "! salt -C 'kvm*' state.sls salt.control | " \
39 "tee /dev/stderr | grep -Fq 'Not connected'"
41 vcp_nodes=$(salt --out yaml 'kvm01*' pillar.get salt:control:cluster:internal:node | \
42 awk '/\s+\w+:$/ {gsub(/:$/, "*"); print $1}')
44 # Check all vcp nodes are available
48 while [ $rc -ne 0 ] && [ ${attempt} -lt ${total_attempts} ]; do
50 for node in $vcp_nodes; do
51 salt "$node" test.ping 2>/dev/null || { rc=$?; break; };
57 wait_for 10 "salt -C '* and not cfg01* and not mas01*' saltutil.sync_all"
58 wait_for 10 "salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' state.apply salt"
59 wait_for 10 "! salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' state.apply linux,ntp | " \
60 "tee /dev/stderr | grep -Fq 'Not connected'"
62 wait_for 10 "salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' ssh.set_auth_key ${SUDO_USER} \
63 $(awk 'NR==1{print $2}' "$(eval echo "~${SUDO_USER}/.ssh/authorized_keys")")"
65 # Disable proxy dhcp routes after installation
66 salt -C 'prx*' file.write /etc/dhcp/dhclient-enter-hooks.d/no-default-route \
67 args='unset new_routers'