Skip to content

Commit b80fbec

Browse files
authored
Merge pull request #2455 from stackhpc/reset-bls-entries-hook
Add hook to reset-bls-entries after host package update
2 parents 170e476 + 9a9341c commit b80fbec

3 files changed

Lines changed: 33 additions & 24 deletions

File tree

etc/kayobe/ansible/maintenance/reset-bls-entries.yml

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,33 @@
1010
tags:
1111
- reset-bls-entries
1212
tasks:
13-
- name: Get machine ID
14-
ansible.builtin.command: cat /etc/machine-id
15-
register: machine_id
16-
check_mode: false
13+
- name: Reset BLS entries on RedHat-based systems
14+
when: ansible_facts.os_family == 'RedHat'
15+
block:
16+
- name: Get machine ID
17+
ansible.builtin.command: cat /etc/machine-id
18+
register: machine_id
19+
check_mode: false
1720

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
21+
- name: Find entries with wrong machine ID
22+
ansible.builtin.find:
23+
paths: /boot/loader/entries
24+
patterns: "*.conf"
25+
register: bls_entries
26+
check_mode: false
2427

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-
ansible.builtin.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') }}"
28+
# We set force to false to avoid replacing an existing BLS entry with the
29+
# correct machine ID.
30+
- name: Rename entries with wrong machine ID
31+
ansible.builtin.copy:
32+
src: /boot/loader/entries/{{ item }}
33+
dest: /boot/loader/entries/{{ item | ansible.builtin.regex_replace('^[a-f0-9]*', machine_id.stdout) }}
34+
force: false
35+
remote_src: true
36+
with_items: "{{ bls_entries.files | map(attribute='path') | reject('search', machine_id.stdout) | map('basename') }}"
3437

35-
- name: Remove entries with wrong machine ID
36-
ansible.builtin.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') }}"
38+
- name: Remove entries with wrong machine ID
39+
ansible.builtin.file:
40+
path: /boot/loader/entries/{{ item }}
41+
state: absent
42+
with_items: "{{ bls_entries.files | map(attribute='path') | reject('search', machine_id.stdout) | map('basename') }}"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/maintenance/reset-bls-entries.yml
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
Adds a hook to automatically fix BLS configuration files under
5+
``/boot/loader/entries`` after overcloud host package update.

0 commit comments

Comments
 (0)