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
|
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:
|
||||||
+26
-2
@@ -13,6 +13,16 @@ if [ "$EUID" -ne 0 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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..."
|
echo "Installing required packages..."
|
||||||
apt update
|
apt update
|
||||||
apt install -y git ansible
|
apt install -y git ansible
|
||||||
@@ -31,12 +41,26 @@ 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 ==="
|
||||||
|
|||||||
Reference in New Issue
Block a user