ansible/deploy.sh

51 lines
1.2 KiB
Bash
Raw Normal View History

#!/bin/sh
usage () {
{
echo "Usage: $0"
echo "Usage: $0 base"
echo "Usage: $0 users"
echo "Usage: $0 services [--deploy] [SERVICE]"
} >&2
}
2024-03-01 19:53:08 +00:00
BASE_CMD="ansible-playbook playbook.yml"
DEPLOY="false"
if [ -z "$(ansible-galaxy collection list community.general 2>/dev/null)" ]; then
echo "Installing community.general modules"
ansible-galaxy collection install community.general
fi
if [ -z "$1" ]; then
echo "Deploying all!"
$BASE_CMD
else
case $1 in
"services")
if [ -n "$2" && "$2" = "--deploy" ]; then
DEPLOY="true"
shift
fi
if [ -z "$2" ]; then
echo "Deploying all services!"
$BASE_CMD --tags setup_services --extra-vars "deploy_services=$DEPLOY"
else
echo "Deploying service: $2"
$BASE_CMD --tags setup_services --extra-vars "deploy_services=$DEPLOY" --extra-vars "single_service=$2"
fi
2022-11-26 19:09:34 +00:00
;;
2022-11-11 21:16:22 +00:00
"base")
$BASE_CMD --tags base_only
2022-11-26 19:09:34 +00:00
;;
2022-12-29 16:55:59 +00:00
"users")
$BASE_CMD --tags setup-users
2022-12-29 16:55:59 +00:00
;;
2022-11-26 08:15:55 +00:00
*)
usage
2022-11-26 19:09:34 +00:00
exit 1
;;
esac
fi