Skip to content

Commit 49ad0b6

Browse files
committed
Configure LVM's devices file
Configure LVM's "devices file" in order to prevent it from scanning cinder volume attachments. LVM uses the concept of a devices file to control whether it scans local and dynamically attached (SAN) volumes. This is an enhancement over using LVM device filters. The devices file essentially provides a whitelist of devices that should be scanned, and the file is automatically updated by LVM commands such as 'lvcreate'. For this to work, the devices file must exist even if it's empty. Resolves: OSPRH-20217 Signed-off-by: Alan Bishop <[email protected]>
1 parent a4ab60d commit 49ad0b6

File tree

6 files changed

+82
-0
lines changed

6 files changed

+82
-0
lines changed

roles/edpm_bootstrap/defaults/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,10 @@ edpm_bootstrap_fips_fms_status:
9494
- {exit_code: 0, state: 'enabled', message: 'FIPS is enabled'}
9595
- {exit_code: 1, state: 'inconsistent', message: 'FIPS setup is inconsistent'}
9696
- {exit_code: 2, state: 'disabled', message: 'FIPS is disabled'}
97+
98+
# Full path name of LVM's default "devicesfile" (see /etc/lvm/lvm.conf)
99+
edpm_bootstrap_lvm_devices_file: /etc/lvm/devices/system.devices
100+
101+
# Specifies whether to import existing LVM devices into the devices file. This
102+
# is overridden (set false) when updating nova compute nodes.
103+
edpm_bootstrap_lvm_import_devices: true

roles/edpm_bootstrap/meta/argument_specs.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,16 @@ argument_specs:
112112
default: /var/lib/openstack/reboot_required
113113
description: |
114114
Path of the reboot_required folder used by `edpm_reboot` role
115+
116+
edpm_bootstrap_lvm_devices_file:
117+
type: path
118+
default: /etc/lvm/devices/system.devices
119+
description: |
120+
Full path name of LVM's default "devicesfile" (see /etc/lvm/lvm.conf)
121+
122+
edpm_bootstrap_lvm_import_devices:
123+
type: bool
124+
default: true
125+
description: |
126+
Specifies whether to import existing LVM devices into the devices file.
127+
This is overridden (set false) when updating nova compute nodes.

roles/edpm_bootstrap/molecule/default/verify.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@
99
path: /tmp/edpm_bootstrap_command
1010
register: bootstrap_stat
1111
failed_when: not bootstrap_stat.stat.exists
12+
13+
- name: Verify the LVM devices file exists
14+
stat:
15+
path: "{{ edpm_bootstrap_lvm_devices_file }}"
16+
register: lvm_devices_stat
17+
failed_when: not lvm_devices_stat.stat.exists

roles/edpm_bootstrap/tasks/bootstrap.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,6 @@
108108
- name: FIPS tasks
109109
ansible.builtin.import_tasks: fips.yml
110110
when: edpm_bootstrap_fips_mode != 'check'
111+
112+
- name: LVM tasks
113+
ansible.builtin.import_tasks: lvm.yml

roles/edpm_bootstrap/tasks/lvm.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
# Copyright 2025 Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
- name: Check if the LVM devices file exists
18+
become: true
19+
ansible.builtin.stat:
20+
path: "{{ edpm_bootstrap_lvm_devices_file }}"
21+
register: lvm_devices_file
22+
23+
- name: Create the LVM devices file
24+
become: true
25+
when: not (lvm_devices_file.stat.exists | bool)
26+
block:
27+
- name: Import any existing LVM devices
28+
ansible.builtin.command: /usr/sbin/vgimportdevices --all
29+
register: vgimportdevices
30+
changed_when: true
31+
failed_when: vgimportdevices.rc not in [0, 5]
32+
when: (edpm_bootstrap_lvm_import_devices | bool)
33+
34+
- name: Create an empty LVM devices file
35+
ansible.builtin.file:
36+
path: "{{ edpm_bootstrap_lvm_devices_file }}"
37+
state: touch
38+
mode: '0600'
39+
owner: root
40+
group: root
41+
when: not (edpm_bootstrap_lvm_import_devices | bool) or vgimportdevices.rc == 5

roles/edpm_nova/tasks/update.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,15 @@
1010
mode: "0644"
1111
loop:
1212
- {"src": "nova_statedir_ownership.py", "dest": "nova_statedir_ownership.py"}
13+
14+
- name: Run LVM bootstrap tasks
15+
tags:
16+
- update
17+
- nova
18+
ansible.builtin.include_role:
19+
name: osp.edpm.edpm_bootstrap
20+
tasks_from: lvm.yml
21+
vars:
22+
# Don't import existing LVM devices in case there are "rogue" ones associated
23+
# with an attached cinder volume.
24+
edpm_bootstrap_lvm_import_devices: false

0 commit comments

Comments
 (0)