Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Fix tripleo_multipathd handling of blacklist section
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ASBishop committed Jan 31, 2023
1 parent 2932173 commit 21ee613
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions tripleo_ansible/roles/tripleo_multipathd/tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,33 +61,38 @@
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

- name: Add global blacklist if multipathd is disabled
lineinfile:
path: /etc/multipath.conf
insertafter: '^blacklist'
insertafter: '^blacklist\s*{'
regexp: '^[\s]+devnode \"\.\*\"'
line: ' devnode ".*"'
when:
Expand Down

0 comments on commit 21ee613

Please sign in to comment.