Fix tripleo_multipathd handling of blacklist section

Fix the tripleo_multipathd role's task that detects whether a
blacklist section is present in /etc/multipath.conf. Previously,
an error caused it to insert malformed lines in the file.

Resolves: rhbz#2159555
Change-Id: If85e8c3644af21455ce497d88ee975c056f4fcaa
(cherry picked from commit 21ee61309c)
(cherry picked from commit b2702e4611)
This commit is contained in:
Alan Bishop 2023-01-31 09:26:05 -08:00
parent cec5e912c8
commit 6976f3f616
1 changed files with 18 additions and 13 deletions

View File

@ -61,25 +61,30 @@
path: /etc/multipath.conf
setype: container_file_t
- name: Ensure a blacklist section is present
lineinfile:
path: /etc/multipath.conf
regexp: '^blacklist'
line: 'blacklist {'
- name: Check if a blacklist section is present
shell: grep -q '^blacklist\s*{' /etc/multipath.conf
failed_when: false
changed_when: false
register: blacklist_section
- name: Terminate the blacklist section if one was added
replace:
path: /etc/multipath.conf
regexp: '^(blacklist {)'
replace: '\1\n}'
- name: Add a blacklist section if it's missing
block:
- name: Start the blacklist section
lineinfile:
path: /etc/multipath.conf
line: 'blacklist {'
- name: Terminate the blacklist section
replace:
path: /etc/multipath.conf
regexp: '^(blacklist {)'
replace: '\1\n}'
when:
- blacklist_section.changed
- blacklist_section.rc|int == 1
- name: Remove global blacklist if multipathd is enabled
replace:
path: /etc/multipath.conf
regexp: '^blacklist {\n[\s]+devnode \"\.\*\"'
regexp: '^blacklist\s*{\n[\s]+devnode \"\.\*\"'
replace: 'blacklist {'
when:
- tripleo_multipathd_enable | bool
@ -87,7 +92,7 @@
- name: Add global blacklist if multipathd is disabled
lineinfile:
path: /etc/multipath.conf
insertafter: '^blacklist'
insertafter: '^blacklist\s*{'
regexp: '^[\s]+devnode \"\.\*\"'
line: ' devnode ".*"'
when: