9928215713cc7413463dd21253824e3cda03d252
[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
18 # KVM, compute node prereqs
19 # patch the networking module for Debian based distros
20 debian_ip_source=/usr/lib/python2.7/dist-packages/salt/modules/debian_ip.py
21 salt -C "${cluster_nodes_query}" file.line $debian_ip_source \
22   content='iface = iface.lower()' mode='delete'
23
24 salt -C "${cluster_nodes_query}" file.replace $debian_ip_source \
25   pattern="^\s{8}__salt__\['pkg.install'\]\('vlan'\)" \
26   repl="\n        if not __salt__['pkg.version']('vlan'):\n            __salt__['pkg.install']('vlan')"
27
28 salt -C "${cluster_nodes_query}" pkg.install bridge-utils
29 salt -C "${cluster_nodes_query}" state.apply linux.system.repo
30 wait_for 5.0 "salt -C '${cluster_nodes_query}' state.apply salt.minion"
31 wait_for 5.0 "salt -C '${cluster_nodes_query}' state.apply linux,ntp"
32 wait_for 30.0 "salt -C '${cluster_nodes_query}' test.ping"
33
34 salt -C "${cluster_nodes_query}" cmd.run 'reboot'
35 wait_for 90.0 "salt -C '${cluster_nodes_query}' test.ping"
36
37 salt -C "${cluster_nodes_query}" state.apply linux,ntp
38 salt -C "${cluster_nodes_query}" pkg.upgrade refresh=False dist_upgrade=True