-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathprovision
executable file
·53 lines (45 loc) · 1.23 KB
/
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
46
47
48
49
50
51
52
53
#!/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
# and roles-external is not a symlink and is not a git repository
# and the file .no-provision is not present
if [ -d roles-external ] && [ -f "$environment_dir"/requirements.yml ]
then
if [ -L roles-external ] || [ -d roles-external/.git ] \
|| [ -f roles-external/.no-provision ]
then
echo "Skipping download of extra roles"
else
echo "Downloading roles to roles-external"
ansible-galaxy install -r "$environment_dir"/requirements.yml -f -p .
fi
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