diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2026-10-03 11:41:33 -0700 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2026-10-11 18:36:45 -0700 |
| commit | 024ae3365ffa40b5d0b117577c552587b258ca7a (patch) | |
| tree | a2907f5a9018009e55b0d1690c3210844b74af30 /bootstrap.sh | |
| download | site-configs-024ae3365ffa40b5d0b117577c552587b258ca7a.zip | |
Initial Commit
Diffstat (limited to 'bootstrap.sh')
| -rwxr-xr-x | bootstrap.sh | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 0000000..6fe4797 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,56 @@ +#!/bin/sh +set -e + +PLAYBOOK_DIR="$(cd "$(dirname "$0")" && pwd)" +PLAYBOOK="${PLAYBOOK_DIR}/site.yml" + +main() { + ensure_ansible_installed + ensure_ansible_collections_installed + run_playbook "$@" +} + +ensure_ansible_installed() { + log_step "Checking for Ansible" + if ! bin_exists ansible-playbook; then + log_step "Installing Ansible" + if bin_exists brew; then + brew install ansible + else + log_err "brew (homebrew) not found. Unsupported package manager. Install Ansible manually." + exit 1 + fi + else + log_step "Ansible already installed" + fi +} + +ensure_ansible_collections_installed() { + log_step "Checking for required ansible collections" + if ! ansible-galaxy collection list 2>/dev/null | grep --quiet community.general; then + log_step "Installing required Ansible collections..." + ansible-galaxy collection install community.general + else + log_step "Ansible collections already installed" + fi +} + +run_playbook() { + log_step "Running playbook" + ansible-playbook --ask-become-pass "$PLAYBOOK" "$@" + log_step "Done!" +} + +bin_exists() { + command -v "$1" >/dev/null 2>&1 +} + +log_step() { + echo "==> $1" +} + +log_err() { + echo "[ERROR] $1" >&2 +} + +main "$@" |