Skip to content

Fix issue with GRUB defaulting to an old kernel #878

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

Merged
merged 1 commit into from
Jan 23, 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
39 changes: 39 additions & 0 deletions etc/kayobe/ansible/reset-bls-entries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
# Custom playbook to reset Boot Loader Specification (BLS) entries to resolve
# an issue with GRUB defaulting to an old kernel. This is adapted from a Bash
# script in diskimage-builder:
# https://opendev.org/openstack/diskimage-builder/src/branch/master/diskimage_builder/elements/rhel/post-install.d/03-reset-bls-entries

- name: Reset BLS entries
hosts: overcloud
become: true
tags:
- reset-bls-entries
tasks:
- name: Get machine ID
command: cat /etc/machine-id
register: machine_id
check_mode: false

- name: Find entries with wrong machine ID
ansible.builtin.find:
paths: /boot/loader/entries
patterns: "*.conf"
register: bls_entries
check_mode: false

# We set force to false to avoid replacing an existing BLS entry with the
# correct machine ID.
- name: Rename entries with wrong machine ID
copy:
src: "/boot/loader/entries/{{ item }}"
dest: "/boot/loader/entries/{{ item | ansible.builtin.regex_replace('^[a-f0-9]*', machine_id.stdout) }}"
force: false
remote_src: true
with_items: "{{ bls_entries.files | map(attribute='path') | reject('search', machine_id.stdout) | map('basename') }}"

- name: Remove entries with wrong machine ID
file:
path: "/boot/loader/entries/{{ item }}"
state: absent
with_items: "{{ bls_entries.files | map(attribute='path') | reject('search', machine_id.stdout) | map('basename') }}"
7 changes: 7 additions & 0 deletions releasenotes/notes/reset-bls-entries-b2bded62c5887937.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
fixes:
- |
Add a new ``reset-bls-entries.yml`` custom playbook which will rename
existing Boot Loader Specification (BLS) entries using the current machine
ID for each host. This should fix an issue with Grub not selecting the most
recent kernel during boot.