Skip to content

Commit b7e87d4

Browse files
authored
Merge pull request #878 from stackhpc/reset-bls-entries
Fix issue with GRUB defaulting to an old kernel
2 parents e1a64bd + ca192e2 commit b7e87d4

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
# Custom playbook to reset Boot Loader Specification (BLS) entries to resolve
3+
# an issue with GRUB defaulting to an old kernel. This is adapted from a Bash
4+
# script in diskimage-builder:
5+
# https://opendev.org/openstack/diskimage-builder/src/branch/master/diskimage_builder/elements/rhel/post-install.d/03-reset-bls-entries
6+
7+
- name: Reset BLS entries
8+
hosts: overcloud
9+
become: true
10+
tags:
11+
- reset-bls-entries
12+
tasks:
13+
- name: Get machine ID
14+
command: cat /etc/machine-id
15+
register: machine_id
16+
check_mode: false
17+
18+
- name: Find entries with wrong machine ID
19+
ansible.builtin.find:
20+
paths: /boot/loader/entries
21+
patterns: "*.conf"
22+
register: bls_entries
23+
check_mode: false
24+
25+
# We set force to false to avoid replacing an existing BLS entry with the
26+
# correct machine ID.
27+
- name: Rename entries with wrong machine ID
28+
copy:
29+
src: "/boot/loader/entries/{{ item }}"
30+
dest: "/boot/loader/entries/{{ item | ansible.builtin.regex_replace('^[a-f0-9]*', machine_id.stdout) }}"
31+
force: false
32+
remote_src: true
33+
with_items: "{{ bls_entries.files | map(attribute='path') | reject('search', machine_id.stdout) | map('basename') }}"
34+
35+
- name: Remove entries with wrong machine ID
36+
file:
37+
path: "/boot/loader/entries/{{ item }}"
38+
state: absent
39+
with_items: "{{ bls_entries.files | map(attribute='path') | reject('search', machine_id.stdout) | map('basename') }}"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
fixes:
3+
- |
4+
Add a new ``reset-bls-entries.yml`` custom playbook which will rename
5+
existing Boot Loader Specification (BLS) entries using the current machine
6+
ID for each host. This should fix an issue with Grub not selecting the most
7+
recent kernel during boot.

0 commit comments

Comments
 (0)