Skip to content

Commit

Permalink
Merge pull request #878 from stackhpc/reset-bls-entries
Browse files Browse the repository at this point in the history
Fix issue with GRUB defaulting to an old kernel
  • Loading branch information
priteau authored Jan 23, 2024
2 parents e1a64bd + ca192e2 commit b7e87d4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
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.

0 comments on commit b7e87d4

Please sign in to comment.