358e1874de64a1e73952dfe4f4e906f53f3f402e
[fuel.git] / mcp / config / states / baremetal_init
1 #!/bin/bash -e
2 ##############################################################################
3 # Copyright (c) 2018 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 source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/xdf_data.sh"
15
16 cluster_nodes_query="${control_nodes_query} or cmp*"
17 compute_nodes_query='cmp*'
18
19 # KVM, compute node prereqs
20 # patch the networking module for Debian based distros
21 debian_ip_source=/usr/lib/python2.7/dist-packages/salt/modules/debian_ip.py
22 salt -C "${cluster_nodes_query}" file.line $debian_ip_source \
23   content='iface = iface.lower()' mode='delete'
24
25 salt -C "${cluster_nodes_query}" file.replace $debian_ip_source \
26   pattern="^\s{8}__salt__\['pkg.install'\]\('vlan'\)" \
27   repl="\n        if not __salt__['pkg.version']('vlan'):\n            __salt__['pkg.install']('vlan')"
28
29 salt -C "${cluster_nodes_query}" pkg.install bridge-utils
30 salt -C "${control_nodes_query}" state.apply linux.network,linux.system.kernel
31 wait_for 5.0 "salt -C '${cluster_nodes_query}' state.apply salt.minion"
32 wait_for 5.0 "salt -C '${compute_nodes_query}' state.apply linux.system,linux.network"
33 wait_for 30.0 "salt -C '${cluster_nodes_query}' test.ping"
34
35 salt -C "${cluster_nodes_query}" system.reboot
36 wait_for 90.0 "salt -C '${cluster_nodes_query}' test.ping"
37
38 salt -C "${cluster_nodes_query}" state.apply linux,ntp
39 salt -C "${cluster_nodes_query}" pkg.upgrade refresh=False dist_upgrade=True