-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmongosible
executable file
·60 lines (49 loc) · 1.31 KB
/
mongosible
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
#!/bin/bash
set -e
help () {
fatal <<HELP_MSG
Usage:
$0 # deploy on test
$0 --prod # deploy on prod
$0 --all # deploy on test and prod
$0 --list-tags # list all tags
$0 [ -t sometag ] [ ... ]
HELP_MSG
}
cd "$(cd "$(dirname "$0")"; pwd)"
ensure_suitcase () {
if ! test -f ansible-deps-cache/.versions 2>/dev/null; then
curl https://raw.githubusercontent.com/epfl-si/ansible.suitcase/master/install.sh | \
SUITCASE_DIR=$PWD/ansible-deps-cache \
SUITCASE_ANSIBLE_VERSION=10.0.1 \
bash -x
fi
. ansible-deps-cache/lib.sh
ensure_ansible_runtime
}
ensure_suitcase
declare -a ansible_args
inventory_mode="test"
while [ "$#" -gt 0 ]; do
case "$1" in
--help)
help ;;
--prod)
inventory_mode="prod"
shift ;;
--all)
inventory_mode="test-and-prod"
shift ;;
*)
ansible_args+=("$1")
shift ;;
esac
done
inventories () {
case "$inventory_mode" in
test) echo "-i inventory/inventory-test.yml" ;;
prod) echo "-i inventory/inventory-prod.yml" ;;
all) echo "-i inventory/inventory-test.yml -i inventory/inventory-prod.yml" ;;
esac
}
ansible-playbook $(inventories) playbook.yml "${ansible_args[@]}"