Merge "[baremetal] Fix: wrong nic name idf index"
[fuel.git] / mcp / config / states / baremetal_init
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
16 # patch the networking module for Debian based distros
17 debian_ip_source=/usr/lib/python2.7/dist-packages/salt/modules/debian_ip.py
18 salt -C 'kvm* or cmp*' file.line $debian_ip_source \
19   content='iface = iface.lower()' mode='delete'
20
21 salt -C 'kvm* or cmp*' file.replace $debian_ip_source \
22   pattern="^\s{8}__salt__\['pkg.install'\]\('vlan'\)" \
23   repl="\n        if not __salt__['pkg.version']('vlan'):\n            __salt__['pkg.install']('vlan')"
24
25 salt -C 'kvm*' pkg.install bridge-utils
26 salt -C 'kvm*' state.apply linux.network,linux.system.kernel
27 salt -C 'kvm* or cmp*' state.apply salt.minion
28 salt -C 'cmp*' state.apply linux.system
29 salt -C 'cmp*' state.apply linux.network || true
30
31 # disable dhcp offered routes on compute nodes
32 salt -C 'cmp*' file.write /etc/dhcp/dhclient-enter-hooks.d/no-default-route \
33   args='unset new_routers'
34
35 salt -C 'kvm* or cmp*' system.reboot
36 wait_for 90.0 "salt -C 'kvm* or cmp*' test.ping"
37
38 salt -C 'kvm* or cmp*' state.apply linux,ntp
39 salt -C 'kvm* or cmp*' pkg.upgrade refresh=False