This repository has been archived on 2023-12-29. You can view files and clone it, but cannot push or open issues or pull requests.
pi-ansible/provision.sh

46 lines
1.1 KiB
Bash
Raw Normal View History

#!/bin/sh
2022-12-26 01:13:06 +00:00
usage() {
printf '%s\n' "Usage:"
printf '$ %s\n' "$0"
printf '$ %s\n' "$0 os"
printf '$ %s\n' "$0 services [SINGLE_SERVICE]"
printf '$ %s\n' "$0 reboot [-f|--force]"
}
2023-01-04 20:02:33 +00:00
cd "$(dirname "$0")" || exit 255
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
2022-12-25 17:39:26 +00:00
os)
2023-01-14 18:29:21 +00:00
$BASE_CMD --tags os ;;
docker)
$BASE_CMD --tags docker ;;
services)
if [ -z "$2" ]; then
$BASE_CMD --tags services
else
$BASE_CMD --tags services --extra-vars "single_service=$2"
fi
2023-01-14 18:29:21 +00:00
;;
2022-12-25 17:39:26 +00:00
reboot)
if [ "$2" = "-f" ] || [ "$2" = "--force" ]; then
$BASE_CMD --tags reboot --extra-vars "force_reboot=true"
else
$BASE_CMD --tags reboot
fi
2023-01-14 18:29:21 +00:00
;;
-h|--help)
2023-01-14 18:29:21 +00:00
usage ;;
*)
2023-01-14 18:29:21 +00:00
usage >&2; exit 1 ;;
esac
fi