58 lines
1.4 KiB
Bash
58 lines
1.4 KiB
Bash
|
#!/bin/sh
|
||
|
|
||
|
set -e
|
||
|
|
||
|
usage() {
|
||
|
printf '%s\n' "Usage:"
|
||
|
printf '$ %s\n' "$0 [-h|--help]"
|
||
|
printf '$ %s\n' "$0 os"
|
||
|
printf '$ %s\n' "$0 docker"
|
||
|
printf '$ %s\n' "$0 users [-i|--init]"
|
||
|
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
|
||
|
BASE_CMD="ansible-playbook playbook.yml --ask-vault-pass --ask-become-pass"
|
||
|
|
||
|
case $1 in
|
||
|
"")
|
||
|
install_modules; $BASE_CMD ;;
|
||
|
os|docker)
|
||
|
install_modules; $BASE_CMD --tags "$1" ;;
|
||
|
users)
|
||
|
install_modules
|
||
|
if [ "$2" = "-i" ] || [ "$2" = "--init" ]; then
|
||
|
$BASE_CMD --user root --tags "$1"
|
||
|
else
|
||
|
$BASE_CMD --tags "$1"
|
||
|
fi
|
||
|
;;
|
||
|
reboot)
|
||
|
install_modules
|
||
|
if [ "$2" = "-f" ] || [ "$2" = "--force" ]; then
|
||
|
$BASE_CMD --tags "$1" --extra-vars "force_reboot=true"
|
||
|
else
|
||
|
$BASE_CMD --tags "$1" --extra-vars "reboot=true"
|
||
|
fi
|
||
|
;;
|
||
|
services)
|
||
|
install_modules
|
||
|
if [ -z "$2" ]; then
|
||
|
$BASE_CMD --tags "$1"
|
||
|
else
|
||
|
$BASE_CMD --tags "$1" --extra-vars "single_service=$2"
|
||
|
fi
|
||
|
;;
|
||
|
-h|--help)
|
||
|
usage ;;
|
||
|
*)
|
||
|
usage >&2; exit 1 ;;
|
||
|
esac
|