Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle missing GRUB_CMDLINE_LINUX_DEFAULT variable #19

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions roles/grubcmdline/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,25 @@
ansible.builtin.set_fact:
grub_cmdline_linux_default: >-
{{ grub_result.content | b64decode | regex_search('^GRUB_CMDLINE_LINUX_DEFAULT.*$', multiline=True) | regex_replace('^GRUB_CMDLINE_LINUX_DEFAULT="(.*)"$', '\1') }}
- name: Display GRUB_CMDLINE_DEFAULT

- 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 All @@ -43,7 +58,7 @@
ansible.builtin.set_fact:
grub_cmdline_linux_new: "{{ grub_cmdline_linux_default.split() | difference(grub_cmdline_linux_remove) + kernel_cmdline | select() }}"

- name: Display newly computed GRUB_CMDLINE_DEFAULT
- name: Display newly computed GRUB_CMDLINE_LINUX_DEFAULT
ansible.builtin.debug:
var: grub_cmdline_linux_new

Expand Down