Files
ansible_pull_master/bootstrap.sh
T

43 lines
788 B
Bash
Executable File

#!/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
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
echo
echo "Running initial Ansible Pull..."
echo
ansible-pull -U "$REPO_URL" local.yml
echo
echo "=== Bootstrap complete ==="