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: Fix the role for UEFI systems #90

Merged
merged 1 commit into from
Feb 26, 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
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 -%}
richm marked this conversation as resolved.
Show resolved Hide resolved
/boot/efi/EFI/BOOT/
{%- endif -%}
__bootloader_bios_conf_dir: /boot/grub2/
Loading