-
Notifications
You must be signed in to change notification settings - Fork 3
/
playbook
executable file
·68 lines (55 loc) · 1.95 KB
/
playbook
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
#!/bin/bash
PROJECT="metaworx"
MODE="prod"
ZONES=("us-midwest-1")
KEYCHECK="true"
## Check for command
if [ -z "$1" ]; then
echo "You need to specify a playbook (see playbooks/*.yml)"
exit 1
fi
if [ $MODE = "dev" ]; then
KEYCHECK="false"
fi
## Remove all current roles
ansible-galaxy list | awk '{ print $2 }' | cut -d "," -f 1 | xargs ansible-galaxy remove >/dev/null
## Add back in requirements
ansible-galaxy install -r requirements.yml >/dev/null
## Suck in puppet-config's network.yaml
if [[ ! -z "${GITHUB_TOKEN}" ]]; then
pushd inventories/$PROJECT/$MODE/project_vars 1>/dev/null
FILE="https://api.github.com/repos/nexcess/puppet-config/contents/data/common.d/network.yaml"
curl --header "Authorization: token $GITHUB_TOKEN" \
--header 'Accept: application/vnd.github.v3.raw' \
--remote-name \
--location $FILE 2>/dev/null
if [ $? -ne 0 ]; then
echo "!! network.yml file NOT DOWNLOADED !!"
exit 1
fi
FILE="https://api.github.com/repos/nexcess/puppet-config/contents/data/common.d/interworx.yaml"
curl --header "Authorization: token $GITHUB_TOKEN" \
--header 'Accept: application/vnd.github.v3.raw' \
--remote-name \
--location $FILE 2>/dev/null
if [ $? -ne 0 ]; then
echo "!! interworx.yml file NOT DOWNLOADED !!"
exit 1
fi
FILE="https://api.github.com/repos/nexcess/puppet-config/contents/data/common.d/apache.yaml"
curl --header "Authorization: token $GITHUB_TOKEN" \
--header 'Accept: application/vnd.github.v3.raw' \
--remote-name \
--location $FILE 2>/dev/null
if [ $? -ne 0 ]; then
echo "!! apache.yml file NOT DOWNLOADED !!"
exit 1
fi
popd 1>/dev/null
fi
## Run Playbook
for zone in "${ZONES[@]}"; do
echo "Running: $zone"
ANSIBLE_HOST_KEY_CHECKING=$KEYCHECK ansible-playbook -i ./inventories/$PROJECT/$MODE/$zone.ini ./playbooks/$1.yml \
|| exit;
done