commit | author | age
|
abfa26
|
1 |
#!/bin/bash |
GC |
2 |
|
|
3 |
set -eo pipefail |
|
4 |
|
db0fc1
|
5 |
ORIG=$(cd $(dirname $0); cd ../..; pwd) |
abfa26
|
6 |
ansible_path=${ORIG}/ansible |
db0fc1
|
7 |
static=${ORIG}/tests/static |
abfa26
|
8 |
|
281c84
|
9 |
cd ${ORIG} |
GC |
10 |
|
d68cfc
|
11 |
for i in \ |
GC |
12 |
$(find ${ORIG}/ansible/configs -name 'sample_vars*.y*ml' | sort) \ |
|
13 |
${static}/scenarii/*.{yaml,yml}; do |
|
14 |
echo |
|
15 |
echo '##################################################' |
|
16 |
echo "$(basename $(dirname ${i}))/$(basename ${i})" |
|
17 |
echo '##################################################' |
abfa26
|
18 |
|
d68cfc
|
19 |
|
GC |
20 |
extra_args=() |
|
21 |
|
|
22 |
config=$(basename $(dirname "${i}")) |
|
23 |
|
|
24 |
if ! egrep --quiet ^env_type: ${i}; then |
|
25 |
echo "No env_type found in ${i}" |
|
26 |
fi |
abfa26
|
27 |
env_type=$(egrep ^env_type: ${i}|cut -d' ' -f 2) |
d68cfc
|
28 |
|
70782b
|
29 |
# Ansible Workshops AKA as Linklight needs to be downloaded |
TK |
30 |
if [ "${env_type}" = linklight ] || [ "${env_type}" = ansible-workshops ]; then |
|
31 |
if [ ! -d ${ansible_path}/workdir/${env_type} ]; then |
|
32 |
echo "Download ${env_type}" |
|
33 |
git clone https://github.com/ansible/workshops.git ${ansible_path}/workdir/${env_type} |
d68cfc
|
34 |
fi |
GC |
35 |
touch $(dirname "${i}")/env_secret_vars.yml |
|
36 |
extra_args=( |
|
37 |
-e ANSIBLE_REPO_PATH=${ansible_path} |
|
38 |
) |
|
39 |
fi |
|
40 |
|
abfa26
|
41 |
if [ -e "${ansible_path}/configs/${env_type}/hosts" ]; then |
GC |
42 |
inventory=(-i "${ansible_path}/configs/${env_type}/hosts") |
|
43 |
else |
db0fc1
|
44 |
inventory=(-i "${static}/tox-inventory.txt") |
abfa26
|
45 |
fi |
GC |
46 |
|
0dfc02
|
47 |
# Setup galaxy roles and collections, make sure it works |
OE |
48 |
ansible-playbook --tags galaxy_roles \ |
|
49 |
"${inventory[@]}" \ |
|
50 |
${ansible_path}/main.yml \ |
|
51 |
${extra_args[@]} \ |
|
52 |
-e @${i} |
|
53 |
|
281c84
|
54 |
for playbook in \ |
GC |
55 |
${ansible_path}/main.yml \ |
d68cfc
|
56 |
${ansible_path}/destroy.yml; do |
GC |
57 |
ansible-playbook --syntax-check \ |
|
58 |
--list-tasks \ |
|
59 |
"${inventory[@]}" \ |
|
60 |
"${playbook}" \ |
|
61 |
${extra_args[@]} \ |
|
62 |
-e @${i} |
|
63 |
done |
|
64 |
# lifecycle (stop / start) |
281c84
|
65 |
|
d68cfc
|
66 |
for ACTION in stop start status; do |
GC |
67 |
ansible-playbook --syntax-check \ |
|
68 |
--list-tasks \ |
|
69 |
"${inventory[@]}" \ |
|
70 |
${ansible_path}/lifecycle_entry_point.yml \ |
|
71 |
${extra_args[@]} \ |
|
72 |
-e ACTION=${ACTION} \ |
|
73 |
-e @${i} |
281c84
|
74 |
done |
abfa26
|
75 |
done |
d68cfc
|
76 |
|
GC |
77 |
exit 0 |