Add multi-distribution bootstrap support

This commit is contained in:
2026-11-02 16:23:41 -07:00
parent fcb34a00d3
commit d7c13b142e
2 changed files with 40 additions and 16 deletions
+4 -4
View File
@@ -1,5 +1,5 @@
--- ---
- name: Configure CachyOS workstation - name: Configure Arch-based workstation
hosts: localhost hosts: localhost
connection: local connection: local
become: yes become: yes
@@ -8,9 +8,9 @@
- name: Verify operating system - name: Verify operating system
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- ansible_facts['distribution'] == "Archlinux" - ansible_facts['os_family'] == "Archlinux"
fail_msg: "This playbook is intended for CachyOS only." fail_msg: "This playbook is intended for Arch-based distributions only."
success_msg: "CachyOS detected successfully." success_msg: "Arch-based distribution detected successfully."
- name: Ensure Fastfetch is installed - name: Ensure Fastfetch is installed
ansible.builtin.package: ansible.builtin.package:
+36 -12
View File
@@ -13,30 +13,54 @@ if [ "$EUID" -ne 0 ]; then
exit 1 exit 1
fi fi
echo "Installing required packages..." # Detect operating system
apt update source /etc/os-release
apt install -y git ansible
echo echo "Detected OS: $PRETTY_NAME"
read -rsp "Enter Ansible Vault password: " VAULT_PASSWORD
echo echo
printf '%s\n' "$VAULT_PASSWORD" > /root/.ansible_vault_password case "$ID $ID_LIKE" in
chmod 600 /root/.ansible_vault_password *ubuntu*|*debian*)
unset VAULT_PASSWORD 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] [defaults]
vault_password_file = /root/.ansible_vault_password vault_password_file = /root/.ansible_vault_password
EOF 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
echo "Running initial Ansible Pull..." echo "Running initial Ansible Pull using $PLAYBOOK..."
echo echo
ansible-pull -U "$REPO_URL" local.yml ansible-pull -U "$REPO_URL" "$PLAYBOOK"
echo echo
echo "=== Bootstrap complete ===" echo "=== Bootstrap complete ==="