From: cel@kernel.org
To: Luis Chamberlain <mcgrof@kernel.org>,
Chandan Babu R <chandanbabu@kernel.org>,
Jeff Layton <jlayton@kernel.org>
Cc: <kdevops@lists.linux.dev>, Chuck Lever <chuck.lever@oracle.com>
Subject: [PATCH v1 06/13] playbooks: Add a role to create an LVM volume group
Date: Mon, 10 Mar 2025 10:18:06 -0400 [thread overview]
Message-ID: <20250310141813.969325-7-cel@kernel.org> (raw)
In-Reply-To: <20250310141813.969325-1-cel@kernel.org>
From: Chuck Lever <chuck.lever@oracle.com>
There are currently three playbooks that need to set up a volume
group: nfsd, smbd, and iscsi. All three need to steer their way
around the physical root and data partitions, in addition to
managing the differences between cloud providers.
Refactor (de-duplicate) the LVM-related tasks in these three
playbooks into a new role that can be shared and then later
updated to avoid already in-use physical block devices.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
kconfigs/Kconfig.nfsd | 6 +--
playbooks/roles/iscsi/tasks/main.yml | 25 +++-------
playbooks/roles/iscsi/vars/Debian.yml | 1 -
playbooks/roles/iscsi/vars/RedHat.yml | 1 -
playbooks/roles/iscsi/vars/Suse.yml | 1 -
playbooks/roles/nfsd/defaults/main.yml | 1 -
playbooks/roles/nfsd/tasks/main.yml | 23 +++------
playbooks/roles/smbd/defaults/main.yml | 1 -
playbooks/roles/smbd/tasks/main.yml | 23 +++------
playbooks/roles/volume_group/README.md | 48 +++++++++++++++++++
.../roles/volume_group/defaults/main.yml | 2 +
playbooks/roles/volume_group/tasks/main.yml | 31 ++++++++++++
12 files changed, 105 insertions(+), 58 deletions(-)
create mode 100644 playbooks/roles/volume_group/README.md
create mode 100644 playbooks/roles/volume_group/defaults/main.yml
create mode 100644 playbooks/roles/volume_group/tasks/main.yml
diff --git a/kconfigs/Kconfig.nfsd b/kconfigs/Kconfig.nfsd
index d071f5fba278..60e9da1aba2d 100644
--- a/kconfigs/Kconfig.nfsd
+++ b/kconfigs/Kconfig.nfsd
@@ -67,14 +67,14 @@ config NFSD_LEASE_TIME
complete faster.
choice
- prompt "Local or external physical storage"
+ prompt "Persistent storage for exported file systems"
default NFSD_EXPORT_STORAGE_LOCAL
config NFSD_EXPORT_STORAGE_LOCAL
bool "Local"
help
- Exported file systems will reside on physical storage
- local to the NFS server itself.
+ Exported file systems will reside on block devices local
+ to the NFS server itself.
config NFSD_EXPORT_STORAGE_ISCSI
bool "iSCSI"
diff --git a/playbooks/roles/iscsi/tasks/main.yml b/playbooks/roles/iscsi/tasks/main.yml
index bbb49756f4da..2638bacc882b 100644
--- a/playbooks/roles/iscsi/tasks/main.yml
+++ b/playbooks/roles/iscsi/tasks/main.yml
@@ -18,24 +18,13 @@
name: "{{ iscsi_target_packages }}"
state: present
-- name: Initialize the list of local physical volumes
- ansible.builtin.set_fact:
- iscsi_lvm_pvs: []
-
-- name: Expand the list of local physical volumes
- ansible.builtin.set_fact:
- iscsi_lvm_pvs: "{{ iscsi_lvm_pvs + [iscsi_target_pv_prefix + item | string] }}"
- with_items: "{{ range(1, iscsi_target_pv_count + 1) }}"
- loop_control:
- label: "Adding {{ iscsi_target_pv_prefix + item | string }} ..."
-
-- name: Create LVM volume group {{ iscsi_target_vg_name }}
- become: true
- become_flags: 'su - -c'
- become_method: ansible.builtin.sudo
- community.general.lvg:
- vg: "{{ iscsi_target_vg_name }}"
- pvs: "{{ iscsi_lvm_pvs | join(',') }}"
+- name: Set up a volume group on local block devices
+ ansible.builtin.include_role:
+ name: volume_group
+ vars:
+ volume_group_name: "{{ iscsi_target_vg_name }}"
+ volume_device_prefix: "{{ iscsi_target_pv_prefix }}"
+ volume_device_count: "{{ iscsi_target_pv_count }}"
- name: Create a directory for storing iSCSI persistent reservations
become: true
diff --git a/playbooks/roles/iscsi/vars/Debian.yml b/playbooks/roles/iscsi/vars/Debian.yml
index 9571f1de98c2..e353c17ee568 100644
--- a/playbooks/roles/iscsi/vars/Debian.yml
+++ b/playbooks/roles/iscsi/vars/Debian.yml
@@ -1,5 +1,4 @@
---
iscsi_target_packages:
- - lvm2
- targetcli-fb
- sg3_utils
diff --git a/playbooks/roles/iscsi/vars/RedHat.yml b/playbooks/roles/iscsi/vars/RedHat.yml
index 6082344368d6..b5376613d55e 100644
--- a/playbooks/roles/iscsi/vars/RedHat.yml
+++ b/playbooks/roles/iscsi/vars/RedHat.yml
@@ -1,6 +1,5 @@
---
iscsi_target_packages:
- - lvm2
- targetcli
- sg3_utils
diff --git a/playbooks/roles/iscsi/vars/Suse.yml b/playbooks/roles/iscsi/vars/Suse.yml
index 63393d988f1e..1b1c0b25a8aa 100644
--- a/playbooks/roles/iscsi/vars/Suse.yml
+++ b/playbooks/roles/iscsi/vars/Suse.yml
@@ -1,6 +1,5 @@
---
iscsi_target_packages:
- - lvm2
- targetcli-fb
- sg3_utils
diff --git a/playbooks/roles/nfsd/defaults/main.yml b/playbooks/roles/nfsd/defaults/main.yml
index 271d2d1d8912..ccdee468bd02 100644
--- a/playbooks/roles/nfsd/defaults/main.yml
+++ b/playbooks/roles/nfsd/defaults/main.yml
@@ -1,7 +1,6 @@
# SPDX-License-Identifier GPL-2.0+
---
# Our sensible defaults for the nfsd role.
-nfsd_lvm_pvs: []
nfsd_export_device_prefix: ""
nfsd_export_device_count: 0
nfsd_export_label: "export"
diff --git a/playbooks/roles/nfsd/tasks/main.yml b/playbooks/roles/nfsd/tasks/main.yml
index 7e18c3813900..144ecd86686e 100644
--- a/playbooks/roles/nfsd/tasks/main.yml
+++ b/playbooks/roles/nfsd/tasks/main.yml
@@ -30,22 +30,13 @@
- nfsd_export_storage_iscsi|bool
- nfsd_export_fstype != "tmpfs"
-- name: Build string of devices to use as PVs
- set_fact:
- nfsd_lvm_pvs: "{{ nfsd_lvm_pvs + [ nfsd_export_device_prefix + item|string ] }}"
- with_items: "{{ range(1, nfsd_export_device_count + 1) }}"
- loop_control:
- label: "Physical volume: {{ nfsd_export_device_prefix + item|string }}"
- when:
- - nfsd_export_storage_local|bool
-
-- name: Create a new LVM VG
- become: yes
- become_flags: 'su - -c'
- become_method: sudo
- community.general.lvg:
- vg: "exports"
- pvs: "{{ nfsd_lvm_pvs | join(',') }}"
+- name: Set up a volume group on local block devices
+ ansible.builtin.include_role:
+ name: volume_group
+ vars:
+ volume_group_name: "exports"
+ volume_device_prefix: "{{ nfsd_export_device_prefix }}"
+ volume_device_count: "{{ nfsd_export_device_count }}"
when:
- nfsd_export_storage_local|bool
- nfsd_export_fstype != "tmpfs"
diff --git a/playbooks/roles/smbd/defaults/main.yml b/playbooks/roles/smbd/defaults/main.yml
index d75cc0b4ce75..4161224f27b9 100644
--- a/playbooks/roles/smbd/defaults/main.yml
+++ b/playbooks/roles/smbd/defaults/main.yml
@@ -1,5 +1,4 @@
---
-smbd_lvm_pvs: []
smbd_share_device_prefix: ""
smbd_share_device_count: 0
smbd_share_label: "share"
diff --git a/playbooks/roles/smbd/tasks/main.yml b/playbooks/roles/smbd/tasks/main.yml
index bb19009606f7..486ccdc613bf 100644
--- a/playbooks/roles/smbd/tasks/main.yml
+++ b/playbooks/roles/smbd/tasks/main.yml
@@ -22,22 +22,13 @@
group: root
mode: 0644
-- name: Build string of devices to use as PVs
- set_fact:
- smbd_lvm_pvs: "{{ smbd_lvm_pvs + [ smbd_share_device_prefix + item|string ] }}"
- with_items: "{{ range(1, smbd_share_device_count + 1) }}"
-
-- name: Print the PV list
- ansible.builtin.debug:
- var: smbd_lvm_pvs
-
-- name: Create a new LVM VG
- become: yes
- become_flags: 'su - -c'
- become_method: sudo
- community.general.lvg:
- vg: "shares"
- pvs: "{{ smbd_lvm_pvs | join(',') }}"
+- name: Set up a volume group on local block devices
+ ansbiel.builtin.include_role:
+ name: volume_group
+ var:
+ volume_group_name: "shares"
+ volume_device_prefix: "{{ smbd_share_device_prefix }}"
+ volume_device_count: "{{ smbd_share_device_count }}"
- name: Create {{ smbd_share_path }}
become: yes
diff --git a/playbooks/roles/volume_group/README.md b/playbooks/roles/volume_group/README.md
new file mode 100644
index 000000000000..56cb7c55f9f4
--- /dev/null
+++ b/playbooks/roles/volume_group/README.md
@@ -0,0 +1,48 @@
+volume_group
+============
+
+The volume_group playbook creates a logical volume group
+on a target node using unused block devices.
+
+Requirements
+------------
+
+The ansible community.general collection must be installed on the
+control host.
+
+Role Variables
+--------------
+
+ * volume_group_name: The name for new volume group (string)
+ * volume_device_prefix: The pathname prefix for block devices to
+ consider for the new volume group (string)
+ * volume_device_count: The number of block devices to include in
+ the new volume group (int)
+
+Dependencies
+------------
+
+None.
+
+Example Playbook
+----------------
+
+Below is an example playbook task:
+
+```
+- name: Create a volume group for NFSD exports
+ ansible.builtin.include_role:
+ name: volume_group
+ vars:
+ volume_group_name: "exports"
+ volume_device_prefix: "/dev/disk/by-id/virtio*"
+ volume_count: 3
+```
+
+For further examples refer to one of this role's users, the
+[https://github.com/linux-kdevops/kdevops](kdevops) project.
+
+License
+-------
+
+copyleft-next-0.3.1
diff --git a/playbooks/roles/volume_group/defaults/main.yml b/playbooks/roles/volume_group/defaults/main.yml
new file mode 100644
index 000000000000..68f3fb3f5775
--- /dev/null
+++ b/playbooks/roles/volume_group/defaults/main.yml
@@ -0,0 +1,2 @@
+---
+physical_volumes: []
diff --git a/playbooks/roles/volume_group/tasks/main.yml b/playbooks/roles/volume_group/tasks/main.yml
new file mode 100644
index 000000000000..086c86454893
--- /dev/null
+++ b/playbooks/roles/volume_group/tasks/main.yml
@@ -0,0 +1,31 @@
+---
+- name: Gather hardware facts
+ ansible.builtin.gather_facts:
+ gather_subset:
+ - "!all"
+ - "!min"
+ - "hardware"
+
+- name: Install dependencies for LVM support
+ become: true
+ become_flags: 'su - -c'
+ become_method: ansible.builtin.sudo
+ ansible.builtin.package:
+ name:
+ - lvm2
+ state: present
+
+- name: Enumerate block devices to provision as physical volumes
+ ansible.builtin.set_fact:
+ physical_volumes: "{{ physical_volumes + [volume_device_prefix + item | string] }}"
+ with_items: "{{ range(1, volume_device_count + 1) }}"
+ loop_control:
+ label: "Block device: {{ volume_device_prefix + item | string }}"
+
+- name: Create an LVM Volume Group
+ become: true
+ become_flags: "su - -c"
+ become_method: ansible.builtin.sudo
+ community.general.lvg:
+ vg: "{{ volume_group_name }}"
+ pvs: "{{ physical_volumes | join(',') }}"
--
2.48.1
next prev parent reply other threads:[~2025-03-10 14:18 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-10 14:18 [PATCH v1 00/13] Block device provisioning for storage nodes cel
2025-03-10 14:18 ` [PATCH v1 01/13] terraform/AWS: Upgrade the EBS volume type to "gp3" cel
2025-03-10 14:18 ` [PATCH v1 02/13] terraform/Azure: Remove managed_disk_type selection cel
2025-03-10 14:18 ` [PATCH v1 03/13] terraform/Azure: Create a set of multiple generic block devices cel
2025-03-10 14:18 ` [PATCH v1 04/13] terraform/OCI: " cel
2025-03-13 5:56 ` Chandan Babu R
2025-03-10 14:18 ` [PATCH v1 05/13] guestfs: Set storage options consistently cel
2025-03-10 14:18 ` cel [this message]
2025-03-10 14:18 ` [PATCH v1 07/13] volume_group: Detect the /data partition directly cel
2025-03-10 14:18 ` [PATCH v1 08/13] volume_group: Prepare to support cloud providers cel
2025-03-10 14:18 ` [PATCH v1 09/13] volume_group: Create volume group on terraform/AWS nodes cel
2025-03-10 14:18 ` [PATCH v1 10/13] volume_group: Create a volume group on Azure nodes cel
2025-03-10 14:18 ` [PATCH v1 11/13] volume_group: Create a volume group on GCE nodes cel
2025-03-10 14:18 ` [PATCH v1 12/13] volume_group: Create a volume group on OCI nodes cel
2025-03-13 6:29 ` Chandan Babu R
2025-03-10 14:18 ` [PATCH v1 13/13] volume_group: Create a volume group on OpenStack public clouds cel
2025-03-11 3:29 ` [PATCH v1 00/13] Block device provisioning for storage nodes Luis Chamberlain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250310141813.969325-7-cel@kernel.org \
--to=cel@kernel.org \
--cc=chandanbabu@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=kdevops@lists.linux.dev \
--cc=mcgrof@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.