#!/bin/sh
usage () {
printf '%s\n' "Usage:"
printf '\t%s\n' "$0"
printf '\t%s\n' "$0 os"
printf '\t%s\n' "$0 services [SINGLE_SERVICE]"
printf '\t%s\n' "$0 reboot [-f|--force]"
}
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
$BASE_CMD
else
case $1 in
os)
$BASE_CMD --tags os
;;
services)
if [ -z "$2" ]; then
$BASE_CMD --tags services
$BASE_CMD --tags services --extra-vars "single_service=$2"
reboot)
if [ "$2" = "-f" ] || [ "$2" = "--force" ]; then
$BASE_CMD --tags reboot --extra-vars "force_reboot=true"
$BASE_CMD --tags reboot
-h|--help)
usage
*)
usage >&2
exit 1
esac