Add multi-distribution bootstrap support
This commit is contained in:
+36
-12
@@ -13,30 +13,54 @@ if [ "$EUID" -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Installing required packages..."
|
||||
apt update
|
||||
apt install -y git ansible
|
||||
# Detect operating system
|
||||
source /etc/os-release
|
||||
|
||||
echo
|
||||
read -rsp "Enter Ansible Vault password: " VAULT_PASSWORD
|
||||
echo "Detected OS: $PRETTY_NAME"
|
||||
echo
|
||||
|
||||
printf '%s\n' "$VAULT_PASSWORD" > /root/.ansible_vault_password
|
||||
chmod 600 /root/.ansible_vault_password
|
||||
unset VAULT_PASSWORD
|
||||
case "$ID $ID_LIKE" in
|
||||
*ubuntu*|*debian*)
|
||||
PLAYBOOK="local.yml"
|
||||
|
||||
mkdir -p /etc/ansible
|
||||
echo "Installing required packages..."
|
||||
apt update
|
||||
apt install -y git ansible
|
||||
|
||||
cat > /etc/ansible/ansible.cfg <<'EOF'
|
||||
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..."
|
||||
echo "Running initial Ansible Pull using $PLAYBOOK..."
|
||||
echo
|
||||
|
||||
ansible-pull -U "$REPO_URL" local.yml
|
||||
ansible-pull -U "$REPO_URL" "$PLAYBOOK"
|
||||
|
||||
echo
|
||||
echo "=== Bootstrap complete ==="
|
||||
|
||||
Reference in New Issue
Block a user