2019-02-15 09:19:24 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2022-11-28 14:27:49 +00:00
|
|
|
usage () {
|
|
|
|
{
|
|
|
|
echo "Usage: $0 [--vagrant]"
|
|
|
|
echo "Usage: $0 [--vagrant] base"
|
2023-03-14 15:17:02 +00:00
|
|
|
echo "Usage: $0 [--vagrant] users"
|
2022-11-28 14:27:49 +00:00
|
|
|
echo "Usage: $0 [--vagrant] services [SERVICE]"
|
|
|
|
} >&2
|
|
|
|
}
|
|
|
|
|
2024-03-01 19:53:08 +00:00
|
|
|
BASE_CMD="ansible-playbook playbook.yml"
|
2019-02-15 09:19:24 +00:00
|
|
|
|
2022-11-26 08:15:18 +00:00
|
|
|
if [ "$1" = "--vagrant" ]; then
|
2022-12-04 21:45:32 +00:00
|
|
|
BASE_CMD="$BASE_CMD --verbose --inventory=vagrant_host"
|
2023-11-04 00:20:53 +00:00
|
|
|
VAGRANT_VAR="from_vagrant"
|
2022-11-26 08:15:18 +00:00
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
2022-11-10 21:03:49 +00:00
|
|
|
if [ -z "$(ansible-galaxy collection list community.general 2>/dev/null)" ]; then
|
2022-11-26 08:15:18 +00:00
|
|
|
echo "Installing community.general modules"
|
2022-11-10 21:03:49 +00:00
|
|
|
ansible-galaxy collection install community.general
|
|
|
|
fi
|
|
|
|
|
2019-02-15 09:19:24 +00:00
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "Deploying all!"
|
|
|
|
$BASE_CMD
|
|
|
|
else
|
|
|
|
case $1 in
|
|
|
|
"services")
|
|
|
|
if [ -z "$2" ]; then
|
|
|
|
echo "Deploying all services!"
|
2023-11-04 00:20:53 +00:00
|
|
|
eval "$BASE_CMD --tags setup_services $(test -z "$VAGRANT_VAR" || printf '%s' "$VAGRANT_VAR=true")"
|
2019-02-15 09:19:24 +00:00
|
|
|
else
|
2022-11-26 08:15:18 +00:00
|
|
|
echo "Deploying service: $2"
|
2023-11-04 00:20:53 +00:00
|
|
|
$BASE_CMD --tags setup_services --extra-vars '{"single_service": "'"$2"'"'"$(test -z "$VAGRANT_VAR" || printf '%s' ', "'"$VAGRANT_VAR"'": true')"'}'
|
2019-02-15 09:19:24 +00:00
|
|
|
fi
|
2022-11-26 19:09:34 +00:00
|
|
|
;;
|
2022-11-11 21:16:22 +00:00
|
|
|
"base")
|
2023-11-04 00:20:53 +00:00
|
|
|
eval "$BASE_CMD --tags base_only $(test -z "$VAGRANT_VAR" || printf '%s' "$VAGRANT_VAR=true")"
|
2022-11-26 19:09:34 +00:00
|
|
|
;;
|
2022-12-29 16:55:59 +00:00
|
|
|
"users")
|
2023-11-04 00:20:53 +00:00
|
|
|
eval "$BASE_CMD --tags setup-users $(test -z "$VAGRANT_VAR" || printf '%s' "$VAGRANT_VAR=true")"
|
2022-12-29 16:55:59 +00:00
|
|
|
;;
|
2022-11-26 08:15:55 +00:00
|
|
|
*)
|
2022-11-28 14:27:49 +00:00
|
|
|
usage
|
2022-11-26 19:09:34 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
2019-02-15 09:19:24 +00:00
|
|
|
esac
|
|
|
|
fi
|