-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfsdteamsible
executable file
·86 lines (74 loc) · 2.16 KB
/
fsdteamsible
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
#
# This is a wrapper around ansible / ansible-playbook.
#
# Usage ("ansible-playbook" mode):
#
# ./ansible/cffsible [--prod]
#
#
# If you are unfamiliar with Ansible, read up on it at
# - https://www.ansible.com/overview/how-ansible-works
# - https://github.com/jdauphant/awesome-ansible
cd "$(dirname "$0")"; cd "$(/bin/pwd)"
git_current_branch="$(git rev-parse --abbrev-ref HEAD 2>/dev/null)"
case "$git_current_branch" in
"") : ;;
*) playbook_flags="$playbook_flags -e git_current_branch=$git_current_branch" ;;
esac
warn () {
if [ -n "$1" ]; then
echo "$@" >&2
else
cat >&2
fi
}
fatal () {
warn "$@"
exit 1
}
platform_check () {
if ! test -f ansible-deps-cache/.versions 2>/dev/null; then
curl https://raw.githubusercontent.com/epfl-si/ansible.suitcase/master/install.sh | \
SUITCASE_ANSIBLE_VERSION=4.0.0 \
SUITCASE_DIR=$PWD/ansible-deps-cache \
SUITCASE_PIP_EXTRA="cryptography" \
SUITCASE_PYTHON_VERSION="3.8.10" \
SUITCASE_ANSIBLE_REQUIREMENTS=requirements.yml \
SUITCASE_NO_EYAML=1 \
bash -x
fi
export PATH="$PWD/ansible-deps-cache/bin:$PATH"
export ANSIBLE_ROLES_PATH="$PWD/ansible-deps-cache/roles"
export ANSIBLE_COLLECTIONS_PATHS="$PWD/ansible-deps-cache"
}
###########################################################################
mode=ansible-playbook
declare -a ansible_args
ansible_args=(-e "fsdteam_dir=$OLDPWD")
while [ "$#" -gt 0 ]; do
case "$1" in
-m) mode=ansible
ansible_args+=("-m")
shift ;;
*)
ansible_args+=("$1")
shift ;;
esac
done
# https://github.com/ansible/ansible/issues/32499, https://bugs.python.org/issue35219
case "$(uname -s)" in
Darwin) export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES ;;
esac
set -e
platform_check
case "$mode" in
ansible-playbook)
ansible-playbook $playbook_flags -i inventory.yml "${ansible_args[@]}" \
$ansible_flags \
playbook.yml
;;
ansible)
ansible inventory.yml $ansible_flags "${ansible_args[@]}"
;;
esac