Update provision.sh

This commit is contained in:
Sam A. 2023-01-16 15:27:07 +01:00
parent 877ce5d62c
commit 401a958740
Signed by: samsapti
GPG key ID: CBBBE7371E81C4EA

View file

@ -2,39 +2,42 @@
usage() { usage() {
printf '%s\n' "Usage:" printf '%s\n' "Usage:"
printf '$ %s\n' "$0" printf '$ %s\n' "$0 [-h|--help]"
printf '$ %s\n' "$0 os" printf '$ %s\n' "$0 os"
printf '$ %s\n' "$0 services [SINGLE_SERVICE]" printf '$ %s\n' "$0 docker"
printf '$ %s\n' "$0 reboot [-f|--force]" printf '$ %s\n' "$0 reboot [-f|--force]"
printf '$ %s\n' "$0 services [SINGLE_SERVICE]"
}
install_modules() {
if [ -z "$(ansible-galaxy collection list community.general 2>/dev/null)" ]; then
ansible-galaxy collection install community.general
fi
} }
cd "$(dirname "$0")" || exit 255 cd "$(dirname "$0")" || exit 255
BASE_CMD="ansible-playbook playbook.yml --ask-vault-pass --ask-become-pass" BASE_CMD="ansible-playbook playbook.yml --ask-vault-pass --ask-become-pass"
if [ -z "$(ansible-galaxy collection list community.general 2>/dev/null)" ]; then
ansible-galaxy collection install community.general
fi
if [ -z "$1" ]; then if [ -z "$1" ]; then
$BASE_CMD $BASE_CMD
else else
case $1 in case $1 in
os) os|docker)
$BASE_CMD --tags os ;; install_modules && $BASE_CMD --tags "$1" ;;
docker) reboot)
$BASE_CMD --tags docker ;; install_modules
services) if [ "$2" = "-f" ] || [ "$2" = "--force" ]; then
if [ -z "$2" ]; then $BASE_CMD --tags "$1" --extra-vars "force_reboot=true"
$BASE_CMD --tags services
else else
$BASE_CMD --tags services --extra-vars "single_service=$2" $BASE_CMD --tags "$1"
fi fi
;; ;;
reboot) services)
if [ "$2" = "-f" ] || [ "$2" = "--force" ]; then install_modules
$BASE_CMD --tags reboot --extra-vars "force_reboot=true" if [ -z "$2" ]; then
$BASE_CMD --tags "$1"
else else
$BASE_CMD --tags reboot $BASE_CMD --tags "$1" --extra-vars "single_service=$2"
fi fi
;; ;;
-h|--help) -h|--help)