Browse Source

Run LVM filter tasks when enabled, regardless of allow/deny list size

When the LVM filter is enabled, it should also run when the allow list
is empty.

Change-Id: I88ec250cb3e29c08ce7e7f5e02b5e7e48f997fea
Closes-Bug: #1907452
changes/09/766209/4
Giulio Fidente 11 months ago
parent
commit
20f1e9766b
  1. 65
      tripleo_ansible/roles/tripleo_lvmfilter/tasks/main.yml

65
tripleo_ansible/roles/tripleo_lvmfilter/tasks/main.yml

@ -32,38 +32,33 @@
| intersect(ansible_devices.keys())
+ (tripleo_tripleo_lvmfilter_devices_allowlist | default([]))
| unique }}"
- name: create lvm.conf with global_filter
when:
- allowed_devices is defined
- (allowed_devices | length) > 0
block:
- name: build lvm2 allow list
set_fact:
lvm2_allow_list: "\"{{ allowed_devices | map('regex_replace', '(.+)', 'a|\\1|')
| join('\",\"') }}\""
- name: build lvm2 deny list
set_fact:
lvm2_deny_list: "\"{{ tripleo_tripleo_lvmfilter_devices_denylist | default([])
| map('regex_replace', '(.+)', 'r|\\1|') | join('\",\"') }}\""
- name: build lvm2 filter
set_fact:
filter: "{{ lvm2_allow_list + ',' + lvm2_deny_list }}"
- name: regenerate lvm config
become: true
command: >
lvmconfig -f /tmp/tripleo_lvmfilter.conf
--mergedconfig --withgeneralpreamble --withspaces --withsummary --withcomments --ignorelocal --showdeprecated
--config devices/global_filter='[{{ filter }}]'
- name: copy new lvm.conf in place
become: true
copy:
remote_src: true
src: /tmp/tripleo_lvmfilter.conf
dest: /etc/lvm/lvm.conf
owner: root
group: root
mode: '0644'
backup: true
when: tripleo_tripleo_lvmfilter_enabled
notify:
- Refresh LVM caches
- name: build lvm2 allow list
set_fact:
lvm2_allow_list: "\"{{ allowed_devices | map('regex_replace', '(.+)', 'a|\\1|')
| join('\",\"') }}\""
- name: build lvm2 deny list
set_fact:
lvm2_deny_list: "\"{{ tripleo_tripleo_lvmfilter_devices_denylist | default([])
| map('regex_replace', '(.+)', 'r|\\1|') | join('\",\"') }}\""
- name: build lvm2 filter
set_fact:
lvm2_filter: "{{ lvm2_allow_list + ',' + lvm2_deny_list }}"
- name: regenerate lvm config
become: true
command: >
lvmconfig -f /tmp/tripleo_lvmfilter.conf
--mergedconfig --withgeneralpreamble --withspaces --withsummary --withcomments --ignorelocal --showdeprecated
--config devices/global_filter='[{{ lvm2_filter }}]'
- name: copy new lvm.conf in place
become: true
copy:
remote_src: true
src: /tmp/tripleo_lvmfilter.conf
dest: /etc/lvm/lvm.conf
owner: root
group: root
mode: '0644'
backup: true
when: tripleo_tripleo_lvmfilter_enabled
notify:
- Refresh LVM caches

Loading…
Cancel
Save