Skip to content

Commit

Permalink
Fix the role for UEFI systems (#90)
Browse files Browse the repository at this point in the history
- Fix __bootloader_uefi_ directories for other than RHEL distributions
- Add a note about supported architectures in README
- Fix license
- Use a general grub conf path if UEFI path is a stub
  • Loading branch information
spetrosi authored Feb 26, 2024
1 parent 51f56a4 commit 6bac514
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 19 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright <YEAR> <COPYRIGHT HOLDER>
Copyright 2024 Red Hat, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

An Ansible role for bootloader and kernel command line management.

## Supported architectures

This role currently supports configuring `grub2` boot loader which runs on the following architectures:

* AMD and Intel 64-bit architectures (x86-64)
* The 64-bit ARM architecture (ARMv8.0)
* IBM Power Systems, Little Endian (POWER9)

## Requirements

See below
Expand Down
37 changes: 22 additions & 15 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@
use: "{{ (__bootloader_is_ostree | d(false)) |
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"

- name: Ensure boot loader settings
bootloader_settings:
bootloader_settings: "{{ bootloader_settings }}"
notify:
- Fix default kernel boot parameters
- Reboot system

- name: Determine platform type
stat:
path: /sys/firmware/efi
Expand All @@ -36,21 +29,28 @@
- name: Get stat of {{ __bootloader_default_grub }}
stat:
path: "{{ __bootloader_default_grub }}"
register: __bootloader_grub_stat
register: __bootloader_default_grub_stat

- name: Get stat of {{ __bootloader_grub_conf }}
stat:
path: "{{ __bootloader_grub_conf }}"
register: __bootloader_grub_conf_stat

- name: Use a general grub conf path if UEFI path is a stub
when:
- __bootloader_grub_conf_stat.stat.size < 500
- __bootloader_grub_conf == __bootloader_uefi_conf_dir ~ 'grub.cfg'
set_fact:
__bootloader_grub_conf: /boot/grub2/grub.cfg

- name: >-
Update boot loader timeout configuration in {{ __bootloader_default_grub }}
replace:
path: "{{ __bootloader_default_grub }}"
regexp: '^GRUB_TIMEOUT=.*'
replace: 'GRUB_TIMEOUT={{ bootloader_timeout }}'
mode: "{{ __bootloader_grub_stat.stat.exists |
ternary(__bootloader_grub_stat.stat.mode, '0644') }}"

- name: Get stat of {{ __bootloader_grub_conf }}
stat:
path: "{{ __bootloader_grub_conf }}"
register: __bootloader_grub_conf_stat
mode: "{{ __bootloader_default_grub_stat.stat.exists |
ternary(__bootloader_default_grub_stat.stat.mode, '0644') }}"

- name: Update boot loader timeout configuration in {{ __bootloader_grub_conf }}
replace:
Expand All @@ -60,6 +60,13 @@
mode: "{{ __bootloader_grub_conf_stat.stat.exists |
ternary(__bootloader_grub_conf_stat.stat.mode, '0644') }}"

- name: Ensure boot loader settings
bootloader_settings:
bootloader_settings: "{{ bootloader_settings }}"
notify:
- Fix default kernel boot parameters
- Reboot system

- name: Update boot loader password
when: bootloader_password is not none
block:
Expand Down
6 changes: 3 additions & 3 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ __bootloader_packages:
- grubby
__bootloader_default_grub: /etc/default/grub
__bootloader_uefi_conf_dir: >-
{%- if ansible_distribution == 'RedHat' -%}
/boot/efi/EFI/redhat/
{%- elif ansible_distribution in ['SLES', 'SLES_SAP'] -%}
{%- if ansible_os_family == 'RedHat' -%}
/boot/efi/EFI/{{ ansible_distribution | lower }}/
{%- elif ansible_os_family == Suse -%}
/boot/efi/EFI/BOOT/
{%- endif -%}
__bootloader_bios_conf_dir: /boot/grub2/

0 comments on commit 6bac514

Please sign in to comment.