-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap
executable file
·36 lines (28 loc) · 1.06 KB
/
bootstrap
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
#!/bin/bash
# Just enough bash to get ansible running. See ./README.md
set -eu -o pipefail
function main () {
require_sudo
(set -x && apt-get install -yq software-properties-common)
(set -x && apt-add-repository --yes --update ppa:ansible/ansible)
(set -x && apt-get update)
(set -x && apt-get install -yq ansible)
# Don't end up with root-owned files in the repo.
REG_USER=$(logname)
(set -x && runuser -u "$REG_USER" -- ansible-galaxy install -r ./galaxy/requirements.yml)
RECIPE_DEFAULT=recipes/UNSPECIFIED
RECIPE_ARG=${1:-$RECIPE_DEFAULT}
if [ ! -e "$RECIPE_ARG" ]; then
>&2 echo "ERROR: the recipe '$RECIPE_ARG' does not exist, or was not specified. The path to the desired recipe must be supplied as the first argument."
exit 1
fi
shift # Eat the recipe arg so we can pass everything else to ansible (mostly so we can pass tags).
(set -x && ansible-playbook playbooks/main.yml -i "$RECIPE_ARG" "$@")
}
function require_sudo() {
if [ $EUID -ne 0 ]; then
>&2 echo "ERROR: Please run this script with sudo."
exit 1
fi
}
main "$@"