66 lines
1.2 KiB
Bash
Executable File
66 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cd "$REPO_ROOT"
|
|
|
|
LIMIT=""
|
|
EXTRA_ARGS=()
|
|
|
|
usage() {
|
|
cat <<EOF
|
|
Usage: $(basename "$0") [HOST] [OPTIONS]
|
|
|
|
Provision server(s) with site.yml.
|
|
|
|
HOST Optional. Limit to one host: adama, roslin, or desktop.
|
|
Omit to run against all webservers.
|
|
|
|
Options:
|
|
--check Dry run (ansible --check)
|
|
--diff Show diffs
|
|
-h, --help Show this help
|
|
|
|
Examples:
|
|
$(basename "$0") adama --check # dry run on adama only
|
|
$(basename "$0") adama # provision adama
|
|
$(basename "$0") # provision all hosts
|
|
EOF
|
|
}
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
--check)
|
|
EXTRA_ARGS+=(--check)
|
|
shift
|
|
;;
|
|
--diff)
|
|
EXTRA_ARGS+=(--diff)
|
|
shift
|
|
;;
|
|
adama|roslin|desktop)
|
|
LIMIT="$1"
|
|
shift
|
|
;;
|
|
*)
|
|
echo "Unknown argument: $1" >&2
|
|
usage >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
CMD=(ansible-playbook playbooks/site.yml "${EXTRA_ARGS[@]}")
|
|
if [[ -n "$LIMIT" ]]; then
|
|
CMD+=(--limit "$LIMIT")
|
|
echo "==> Targeting host: $LIMIT"
|
|
else
|
|
echo "==> Targeting all webservers"
|
|
fi
|
|
|
|
exec "${CMD[@]}"
|