Add multi-distribution bootstrap support
This commit is contained in:
@@ -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:
|
||||
+26
-2
@@ -13,6 +13,16 @@ if [ "$EUID" -ne 0 ]; then
|
||||
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
|
||||
@@ -31,12 +41,26 @@ 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