Merge "[baremetal] Fix DPDK by running linux.system first"
[fuel.git] / mcp / config / states / virtual_control_plane
1 #!/bin/bash -e
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 ##############################################################################
9
10 CI_DEBUG=${CI_DEBUG:-0}; [[ "${CI_DEBUG}" =~ (false|0) ]] || set -x
11
12 # shellcheck disable=SC1090
13 source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/lib.sh"
14
15 # KVM, compute node prereqs (libvirt first), VCP deployment
16 salt -C 'kvm*' pkg.install bridge-utils
17 salt -C 'kvm*' state.apply linux.network
18 salt -C 'cmp*' state.apply linux.system
19 salt -C 'kvm* or cmp*' system.reboot
20 wait_for 90 "! salt -C 'kvm* or cmp*' test.ping | " \
21   "tee /dev/stderr | grep -Fq 'Not connected'"
22
23 salt -C '* and not cfg01* and not mas01*' state.apply linux,ntp
24
25 wait_for 5 "salt -C 'kvm*' state.sls libvirt"
26
27 salt -C '* and not cfg01* and not mas01*' state.apply salt
28 salt -C 'kvm*' saltutil.sync_all
29 wait_for 10 "! salt -C 'kvm*' state.sls salt.control | " \
30   "tee /dev/stderr | grep -Fq 'Not connected'"
31
32 vcp_nodes=$(salt --out yaml 'kvm01*' pillar.get salt:control:cluster:internal:node | \
33             awk '/\s+\w+:$/ {gsub(/:$/, "*"); print $1}')
34
35 # Check all vcp nodes are available
36 rc=1
37 while [ $rc -ne 0 ]; do
38   rc=0
39   for node in $vcp_nodes; do
40     salt "$node" test.ping 2>/dev/null || { rc=$?; break; };
41   done
42   sleep 5
43 done
44
45 wait_for 10 "salt -C '* and not cfg01* and not mas01*' saltutil.sync_all"
46 wait_for 10 "salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' state.apply salt"
47 wait_for 10 "! salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' state.apply linux,ntp | " \
48   "tee /dev/stderr | grep -Fq 'Not connected'"
49
50 wait_for 10 "salt -C 'E@^(?!cfg01|mas01|kvm|cmp00).*' ssh.set_auth_key ${SUDO_USER} \
51   $(awk 'NR==1{print $2}' "$(eval echo "~${SUDO_USER}/.ssh/authorized_keys")")"