Skip to content

Commit

Permalink
Handle missing GRUB_CMDLINE_LINUX_DEFAULT variable
Browse files Browse the repository at this point in the history
If GRUB_CMDLINE_LINUX_DEFAULT is unset in /etc/default/grub, initialise
it from GRUB_CMDLINE_LINUX. We write back the updated kernel command
line as GRUB_CMDLINE_LINUX_DEFAULT, the intent being to only apply to
normal (non-rescue) boots. However, on RedHat 9.x, the grubby command
that runs next still updates GRUB_CMDLINE_LINUX.

Fixes #18.
  • Loading branch information
priteau committed Sep 26, 2024
1 parent 66b01ed commit e3620af
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions roles/grubcmdline/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,24 @@
grub_cmdline_linux_default: >-
{{ grub_result.content | b64decode | regex_search('^GRUB_CMDLINE_LINUX_DEFAULT.*$', multiline=True) | regex_replace('^GRUB_CMDLINE_LINUX_DEFAULT="(.*)"$', '\1') }}
- name: Set fact containing GRUB_CMDLINE_LINUX
ansible.builtin.set_fact:
grub_cmdline_linux: >-
{{ grub_result.content | b64decode | regex_search('^GRUB_CMDLINE_LINUX=.*$', multiline=True) | regex_replace('^GRUB_CMDLINE_LINUX="(.*)"$', '\1') }}
- name: Display GRUB_CMDLINE_LINUX_DEFAULT
ansible.builtin.debug:
var: grub_cmdline_linux_default

- name: Display GRUB_CMDLINE_LINUX
ansible.builtin.debug:
var: grub_cmdline_linux

- name: Initialise GRUB_CMDLINE_LINUX_DEFAULT if unset
ansible.builtin.set_fact:
grub_cmdline_linux_default: "{{ grub_cmdline_linux }}"
when: grub_cmdline_linux_default == 'None'

- name: Determine which parameters need removing
# We use a regex here so you can remove parameters regardless of their value, e.g to remove iommu=on you
# could use the regex: ^iommu=
Expand Down

0 comments on commit e3620af

Please sign in to comment.