Ansible: Add X.org configuration

- Detect if X.org is installed with a small fact script
- Symlink Xdefaults file if X.org is installed
This commit is contained in:
Eryn Wells 2025-02-19 13:08:20 -08:00
parent 29fdc610bb
commit 687083bf31
4 changed files with 39 additions and 0 deletions

9
Ansible/facts/xorg.fact Normal file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env zsh
if which xorg 1>/dev/null 2>&1; then
xorg_exists="true"
else
xorg_exists="false"
fi
echo "{ \"exists\": ${xorg_exists} }"

View file

@ -0,0 +1,3 @@
- name: "Rebuild local facts"
ansible.builtin.setup:
gather_subset: [ local ]

View file

@ -19,3 +19,7 @@
- name: Configure tmux
ansible.builtin.import_tasks: tmux.yml
- name: Configure X.org
ansible.builtin.import_tasks: xorg.yml
when: ansible_os_family == "Linux"

View file

@ -0,0 +1,23 @@
---
# TODO: This likely will require a lot more packages to install. IIRC, X.org
# also requires input and video packages to run in a basic state. Not to
# mention, graphics acceleration, window management, etc.
- name: "Xorg : Install X.org"
ansible.builtin.package:
name: xorg
state: present
notify: Rebuild local facts
# Make sure local facts are rebuilt so the steps below can correctly detect
# if X.org is present.
- name: "Xorg : Flush handlers"
meta: flush_handlers
- name: "Xorg : Configure"
when: ansible_local.xorg.exists
block:
- name: "Xorg : Symlink Xdefaults"
ansible.builtin.include_tasks: symlink_dotfile_directory.yml
vars:
dotfile_src: Xdefaults