diff --git a/cachyos.yml b/arch.yml similarity index 64% rename from cachyos.yml rename to arch.yml index 0a87be8..db20493 100644 --- a/cachyos.yml +++ b/arch.yml @@ -1,5 +1,5 @@ --- -- name: Configure CachyOS workstation +- name: Configure Arch-based workstation hosts: localhost connection: local become: yes @@ -8,9 +8,9 @@ - name: Verify operating system ansible.builtin.assert: that: - - ansible_facts['distribution'] == "Archlinux" - fail_msg: "This playbook is intended for CachyOS only." - success_msg: "CachyOS detected successfully." + - ansible_facts['os_family'] == "Archlinux" + fail_msg: "This playbook is intended for Arch-based distributions only." + success_msg: "Arch-based distribution detected successfully." - name: Ensure Fastfetch is installed ansible.builtin.package: diff --git a/bootstrap.sh b/bootstrap.sh index 3f64c32..88c8935 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -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 ==="