This repository has been archived by the owner on Jan 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathauto_val.sh
executable file
·82 lines (69 loc) · 2.09 KB
/
auto_val.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2019-2020 Intel Corporation
# Usage:
# Regular Network Edge mode:
# ./auto_val.sh -f <flavor> deploy both controller & nodes
# ./auto_val.sh -f <flavor> c[ontroller] deploy only controller
# ./auto_val.sh -f <flavor> n[odes] deploy only nodes
#
# Single-node cluster:
# ./auto_val.sh -f <flavor> s[ingle] deploy single-node cluster playbook
set -euxo pipefail
source scripts/ansible-precheck.sh
source scripts/task_log_file.sh
source scripts/parse_args.sh
flavor=""
while getopts ":f:" o; do
case "${o}" in
f)
flavor=${OPTARG}
;;
*)
echo "Invalid flag"
exit 1
;;
esac
done
shift $((OPTIND-1))
# Remove all previous flavors
find "${PWD}/inventory/default/group_vars/" -type l -name "30_*_flavor.yml" -delete
if [[ -z "${flavor}" ]]; then
echo "No flavor provided, please choose specific flavor"
echo -e " $0 -f <flavor> <filter>"
echo "Available flavors: minimal, $(ls -m flavors -I minimal)"
exit 1
else
flavor_path="${PWD}/flavors/${flavor}"
if [[ ! -d "${flavor_path}" ]]; then
echo "Flavor ${flavor} does not exist[${flavor_path}]"
exit 1
fi
for f in "${flavor_path}"/*.yml
do
fname=$(basename "${f}" .yml)
dir="${PWD}/inventory/default/group_vars/${fname}"
if [[ ! -d "${dir}" ]]; then
echo "${f} does not match a directory in group_vars:"
ls "${PWD}/inventory/default/group_vars/"
exit 1
fi
ln -sfn "${f}" "${dir}/30_${flavor}_flavor.yml"
done
fi
limit=""
filter="${1:-}"
playbook="network_edge.yml"
if [[ "${filter}" == s* ]]; then
playbook="single_node_network_edge.yml"
elif [[ "${flavor}" == central_orchestrator ]]; then
limit=$(get_limit "c")
else
limit=$(get_limit "${filter}")
fi
eval ansible-playbook -vv \
"${playbook}" \
--inventory inventory/default/inventory.ini "${limit}"
if ! python3 scripts/log_all.py; then
echo "[Warning] Log collection failed"
fi