-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #878 from stackhpc/reset-bls-entries
Fix issue with GRUB defaulting to an old kernel
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |