From cf2321a1ce41e421cba4e12b73c09c2a12fe61d0 Mon Sep 17 00:00:00 2001 From: Ahmed Abdelhalim Date: Sun, 1 Mar 2026 23:48:05 +0100 Subject: Refactor graphics driver roles Now with the gpu_driver, the installing of the correct driver is delegated to this role, which orchestrate the installing of one or more drivers. This refactoring of the role/testing, means that the roles don't run on testing (intentionally), if a driver needs to be tested it will be added but for now it's not really all that beneficial to keep this 30+ minutes testing roles running just to test the packages existence. It also simplifies the roles, and added as a dependency for steam which is the main reason why these are needed to be installed (also better hyprland animations, but that's not as crucial as steam failing without the drivers). --- configure.yml | 18 ++---------------- molecule/archlinux-gnome/converge.yml | 1 - molecule/archlinux/converge.yml | 1 - roles/gpu_driver/meta/argument_specs.yml | 8 ++++++++ roles/gpu_driver/meta/main.yml | 12 ++++++++++++ roles/gpu_driver/tasks/main.yml | 12 ++++++++++++ roles/gpu_driver/vars/main.yml | 6 ++++++ roles/pciutils/meta/argument_specs.yml | 6 ++++++ roles/pciutils/meta/main.yml | 17 +++++++++++++++++ roles/pciutils/tasks/main.yml | 6 ++++++ roles/steam/meta/main.yml | 1 + 11 files changed, 70 insertions(+), 18 deletions(-) create mode 100644 roles/gpu_driver/meta/argument_specs.yml create mode 100644 roles/gpu_driver/meta/main.yml create mode 100644 roles/gpu_driver/tasks/main.yml create mode 100644 roles/gpu_driver/vars/main.yml create mode 100644 roles/pciutils/meta/argument_specs.yml create mode 100644 roles/pciutils/meta/main.yml create mode 100644 roles/pciutils/tasks/main.yml diff --git a/configure.yml b/configure.yml index f71f962d..e1fc93e2 100644 --- a/configure.yml +++ b/configure.yml @@ -39,27 +39,13 @@ - role: "podman" - role: "ansible" - role: "claude" + - role: "hyprland" - role: "firefox" - role: "zen-browser" - role: "chromium" - role: "obsidian" - role: "microsoft-teams" - - role: "hyprland" - -- name: "Nvidia configure" - gather_facts: true - hosts: - - archlinux.local - roles: - - role: "nvidia_gtx1060" - - role: "steam" - -- name: "Mac nvidia configure" - gather_facts: true - hosts: - - mac.local - roles: - - role: "intel_i915" + - role: "gpu_driver" - role: "steam" - name: "Ubuntu configure" diff --git a/molecule/archlinux-gnome/converge.yml b/molecule/archlinux-gnome/converge.yml index eb08fa9c..eaa8bc23 100644 --- a/molecule/archlinux-gnome/converge.yml +++ b/molecule/archlinux-gnome/converge.yml @@ -97,7 +97,6 @@ - role: "chromium" - role: "obsidian" - role: "microsoft-teams" - - role: "nvidia_gtx1060" - role: "steam" - role: "usbutils" - role: "nginx" diff --git a/molecule/archlinux/converge.yml b/molecule/archlinux/converge.yml index 6da075d2..bd2c4c93 100644 --- a/molecule/archlinux/converge.yml +++ b/molecule/archlinux/converge.yml @@ -96,7 +96,6 @@ - role: "chromium" - role: "obsidian" - role: "microsoft-teams" - - role: "nvidia_gtx1060" - role: "steam" - role: "waybar" - role: "hyprland" diff --git a/roles/gpu_driver/meta/argument_specs.yml b/roles/gpu_driver/meta/argument_specs.yml new file mode 100644 index 00000000..6986388f --- /dev/null +++ b/roles/gpu_driver/meta/argument_specs.yml @@ -0,0 +1,8 @@ +--- +argument_specs: + main: + short_description: "Detect the GPU and include the appropriate driver role" + description: > + Detects the GPU present on the machine using PCI device information and + includes the matching driver role (intel_i915 or nvidia_gtx1060). + options: {} diff --git a/roles/gpu_driver/meta/main.yml b/roles/gpu_driver/meta/main.yml new file mode 100644 index 00000000..4b4c9a4e --- /dev/null +++ b/roles/gpu_driver/meta/main.yml @@ -0,0 +1,12 @@ +--- +dependencies: + - role: "pciutils" +galaxy_info: + author: "a14m" + description: "Detect the GPU and include the appropriate driver role" + license: "MIT" + min_ansible_version: "2.18" + platforms: + - name: "ArchLinux" + versions: + - "all" diff --git a/roles/gpu_driver/tasks/main.yml b/roles/gpu_driver/tasks/main.yml new file mode 100644 index 00000000..7f6f130f --- /dev/null +++ b/roles/gpu_driver/tasks/main.yml @@ -0,0 +1,12 @@ +--- +- name: "Detect GPU" + ansible.builtin.command: + cmd: "lspci" + register: gpu_driver_lspci + changed_when: false + +- name: "Include driver role for matched GPU" + ansible.builtin.include_role: + name: "{{ item.role }}" + loop: "{{ gpu_driver_map }}" + when: item.match in gpu_driver_lspci.stdout diff --git a/roles/gpu_driver/vars/main.yml b/roles/gpu_driver/vars/main.yml new file mode 100644 index 00000000..152f7499 --- /dev/null +++ b/roles/gpu_driver/vars/main.yml @@ -0,0 +1,6 @@ +--- +gpu_driver_map: + - match: "GeForce GTX 1060" + role: "nvidia_gtx1060" + - match: "Intel" + role: "intel_i915" diff --git a/roles/pciutils/meta/argument_specs.yml b/roles/pciutils/meta/argument_specs.yml new file mode 100644 index 00000000..a9845ff3 --- /dev/null +++ b/roles/pciutils/meta/argument_specs.yml @@ -0,0 +1,6 @@ +--- +argument_specs: + main: + short_description: "Install pciutils on Linux distribution" + description: "Install pciutils on Linux distribution" + options: {} diff --git a/roles/pciutils/meta/main.yml b/roles/pciutils/meta/main.yml new file mode 100644 index 00000000..b3a2fe28 --- /dev/null +++ b/roles/pciutils/meta/main.yml @@ -0,0 +1,17 @@ +--- +dependencies: [] +galaxy_info: + author: "a14m" + description: "Install pciutils" + license: "MIT" + min_ansible_version: "2.18" + platforms: + - name: "ArchLinux" + versions: + - "all" + - name: "Ubuntu" + versions: + - "noble" + - name: "Debian" + versions: + - "bookworm" diff --git a/roles/pciutils/tasks/main.yml b/roles/pciutils/tasks/main.yml new file mode 100644 index 00000000..b9d6d62f --- /dev/null +++ b/roles/pciutils/tasks/main.yml @@ -0,0 +1,6 @@ +--- +- name: "Ensure pciutils is installed" + become: true + ansible.builtin.package: + name: "pciutils" + state: "present" diff --git a/roles/steam/meta/main.yml b/roles/steam/meta/main.yml index dd77817d..f5068235 100644 --- a/roles/steam/meta/main.yml +++ b/roles/steam/meta/main.yml @@ -4,6 +4,7 @@ dependencies: when: ansible_facts['distribution'] == "Archlinux" - role: "multiverse" when: ansible_facts['distribution'] == "Ubuntu" + - role: "gpu_driver" galaxy_info: author: "a14m" description: "Install steam" -- cgit v1.2.3