mirror of
https://github.com/fscotto/infra.git
synced 2026-05-30 15:39:58 +00:00
Append NVIDIA params to GRUB cmdline instead of overwriting
Previously the task hardcoded GRUB_CMDLINE_LINUX to a fixed string containing nymph's rd.luks.uuid, rootflags and apparmor parameters, clobbering whatever the host had. Switch to an idempotent lineinfile-with-backrefs loop that appends nouveau.modeset=0 and nvidia-drm.modeset=1 only when missing, preserving the existing kernel cmdline. grub-mkconfig now runs only when the cmdline changed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,16 +1,21 @@
|
||||
---
|
||||
- name: Configure GRUB kernel parameters for NVIDIA hybrid graphics
|
||||
- name: Ensure NVIDIA kernel parameters are present in GRUB cmdline
|
||||
tags: [packages, nvidia]
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/default/grub
|
||||
regexp: '^GRUB_CMDLINE_LINUX='
|
||||
line: 'GRUB_CMDLINE_LINUX="rd.luks.uuid=1e15d159-5d05-4a1f-9639-ac200dff9f9c rootflags=subvol=@ apparmor=1 security=apparmor nouveau.modeset=0 nvidia-drm.modeset=1"'
|
||||
state: present
|
||||
backrefs: true
|
||||
regexp: '^(GRUB_CMDLINE_LINUX="(?!.*{{ item | regex_escape }}).*)"$'
|
||||
line: '\1 {{ item }}"'
|
||||
loop:
|
||||
- nouveau.modeset=0
|
||||
- nvidia-drm.modeset=1
|
||||
register: nymph_grub_cmdline
|
||||
|
||||
- name: Regenerate GRUB configuration
|
||||
tags: [packages, nvidia]
|
||||
ansible.builtin.command: grub-mkconfig -o /boot/grub/grub.cfg
|
||||
changed_when: true
|
||||
when: nymph_grub_cmdline is changed
|
||||
|
||||
- name: Configure NVIDIA power management for hybrid graphics
|
||||
tags: [packages, nvidia]
|
||||
|
||||
Reference in New Issue
Block a user