-
Notifications
You must be signed in to change notification settings - Fork 22
/
provision
executable file
·45 lines (36 loc) · 957 Bytes
/
provision
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
#!/bin/bash
set -e
export ANSIBLE_ROLES_PATH="roles:roles-external"
# parse parameters
help="Usage: $0 <ENV> [ANSIBLE_OPT]
eg $0 acc --tags eb
will provision the tag eb on acc"
if [ "$#" -eq 0 ]; then
echo -e "$help"
exit 1
fi
env=$1
shift
# Set some variables
environment_dir="environments-external/$env/"
inventory="environments-external/$env/inventory"
playbook="provision.yml"
if ! [ -e "$inventory" ]; then
echo "Inventory file '$inventory' for environment '$env' not found."
exit 1
fi
# Download extra roles when requirements.yml is present
if [ -f "$environment_dir"/requirements.yml ]; then
echo "Downloading roles to roles-external"
ansible-galaxy install -r "$environment_dir"/requirements.yml -f -p .
else
echo "No extra roles found to be downloaded"
fi
cmd=$(
cat <<-EOF
ansible-playbook -i $inventory $playbook -e environment_dir=$environment_dir $@
EOF
)
echo "executing $cmd" | tr -d "\n" | tr -s ' '
echo $cmd
$cmd