#!/bin/bash set -e REPO_URL="https://gitea.romerozone.top/robert/ansible_pull_master.git" echo "=== Ansible Pull Bootstrap ===" echo if [ "$EUID" -ne 0 ]; then echo "Please run this script with sudo:" echo " sudo ./bootstrap.sh" exit 1 fi # Detect operating system source /etc/os-release echo "Detected OS: $PRETTY_NAME" echo case "$ID $ID_LIKE" in *ubuntu*|*debian*) PLAYBOOK="local.yml" echo "Installing required packages..." apt update apt install -y git ansible echo read -rsp "Enter Ansible Vault password: " VAULT_PASSWORD echo printf '%s\n' "$VAULT_PASSWORD" > /root/.ansible_vault_password chmod 600 /root/.ansible_vault_password unset VAULT_PASSWORD mkdir -p /etc/ansible cat > /etc/ansible/ansible.cfg <<'EOF' [defaults] vault_password_file = /root/.ansible_vault_password EOF ;; *arch*) PLAYBOOK="arch.yml" echo "Updating system and installing required packages..." pacman -Syu --needed --noconfirm git ansible ;; *) echo "Unsupported operating system: $ID" exit 1 ;; esac echo echo "Running initial Ansible Pull using $PLAYBOOK..." echo ansible-pull -U "$REPO_URL" "$PLAYBOOK" echo echo "=== Bootstrap complete ==="