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 # shellcheck disable=SC1090
11 source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/lib.sh"
13 # KVM, compute node prereqs (libvirt first), VCP deployment
14 salt -C 'kvm*' pkg.install bridge-utils
15 salt -C 'kvm*' state.apply linux.network
16 salt -C 'kvm*' system.reboot
17 wait_for 90 "! salt 'kvm*' test.ping | tee /dev/stderr | grep -Fq 'Not connected'"
19 salt -C '* and not cfg01* and not mas01*' state.apply linux,ntp
21 salt -C 'kvm*' state.sls libvirt
23 salt -C '* and not cfg01* and not mas01*' state.apply salt
24 salt -C 'kvm*' saltutil.sync_all
25 wait_for 10 "! salt -C 'kvm*' state.sls salt.control | " \
26 "tee /dev/stderr | grep -Fq 'Not connected'"
28 vcp_nodes=$(salt --out yaml 'kvm01*' pillar.get salt:control:cluster:internal:node | \
29 awk '/\s+\w+:$/ {gsub(/:$/, "*"); print $1}')
31 # Check all vcp nodes are available
33 while [ $rc -ne 0 ]; do
35 for node in $vcp_nodes; do
36 salt "$node" test.ping 2>/dev/null || { rc=$?; break; };
41 wait_for 10 "salt -C '* and not cfg01* and not mas01*' saltutil.sync_all"
42 wait_for 10 "salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' state.apply salt"
43 wait_for 10 "! salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' state.apply linux,ntp | " \
44 "tee /dev/stderr | grep -Fq 'Not connected'"
46 wait_for 10 "salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' ssh.set_auth_key ${SUDO_USER} \
47 $(awk 'NR==1{print $2}' "$(eval echo "~${SUDO_USER}/.ssh/authorized_keys")")"