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

fix: Add /etc/default/grub if missing #93

Merged
merged 3 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
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
25 changes: 25 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,31 @@
use: "{{ (__bootloader_is_ostree | d(false)) |
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"

- name: Get stat of {{ __bootloader_default_grub }}
stat:
path: "{{ __bootloader_default_grub }}"
register: __bootloader_default_grub_stat

- name: If missing, add {{ __bootloader_default_grub }}
when: not __bootloader_default_grub_stat.stat.exists
block:
- name: Get bootloader args of the default kernel
shell: >-
set -euo pipefail;
grubby --info=DEFAULT | grep -oP 'args=\K(.*)'
register: __bootloader_default_args
changed_when: false

- name: Generate {{ __bootloader_default_grub }}
vars:
grub_cmdline_linux: "{{ __bootloader_default_args.stdout }}"
template:
src: etc_default_grub.j2
dest: "{{ __bootloader_default_grub }}"
owner: root
group: root
mode: 0644

- name: Determine platform type
stat:
path: /sys/firmware/efi
Expand Down
13 changes: 13 additions & 0 deletions templates/etc_default_grub.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{ ansible_managed | comment }}
{{ "system_role:bootloader" | comment(prefix="", postfix="") }}
GRUB_TIMEOUT={{ bootloader_timeout }}
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX={{ grub_cmdline_linux }}
richm marked this conversation as resolved.
Show resolved Hide resolved
GRUB_DISABLE_RECOVERY="true"
{% if not (ansible_facts['os_family'] == 'RedHat' and
ansible_facts['distribution_version'] is version('7', '>=')) %}
GRUB_ENABLE_BLSCFG=true
{% endif %}
1 change: 1 addition & 0 deletions tests/roles/linux-system-roles.bootloader/templates
Loading