From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 672C71A314B for ; Mon, 10 Mar 2025 14:18:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741616301; cv=none; b=qSqqjtzqSZm9wHuqGy5weAyDUIrO9oqJ1HBdFw/Hntl34swRzi4WwbCP2X8UAfatAkqA+fDMVNDTjQoKKa7l5pbPHQg66iDHhq+wkipgGhtqGMCqHsyPC4XCGkp9+5kKgY6znF8+JLcQ9PFpysUmHr9Rjhv8JXnrg+Lvc214j+k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741616301; c=relaxed/simple; bh=VPRvDpePx02tWKbP1f6UpLFWyAV+sF3RPjqit/ICW+w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HZ9JQJ/BfuxNCAIOsKt5bxHGssI7ucR/bEe5nc9kEumYL6g/yFJO6JMHdMeLSfNMojxNIKt3PosBHJuiNfwBPSfkqzj6k7NsT0XKfQVRwyMzJEGCRQIXCNMXBsqtsESlRXZziq049/PkOCk0huTyRDqMYSIazuUu13kDAWrCXsA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uVy48t64; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uVy48t64" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E570C4CEE5; Mon, 10 Mar 2025 14:18:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741616300; bh=VPRvDpePx02tWKbP1f6UpLFWyAV+sF3RPjqit/ICW+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uVy48t64vyUi6HitfWL1klhvyNrTR0xpgCeFafilv13df92qVuECBYOc1shzMXBe9 e3bRnm3/t6PUY/bwda5aoYySN6sV/WrMR8UBVOtivBOW2JkQp6LOsUKLoNW4lkKsHe BaEIJnIl81M+KLuI9XpTIBk9Kadyu+3DCc1RiMomiUt5JCnKDjwuzYXul0/61tL/Op /HfXi0btuq7lmH6RfmoxplO8cP93etlGWKTNE774fjXd8NSXNB3w0Q+xBIyl1edAZv BPCNpJofa8SvflzqnqVpYHjZsB8drKj+g6jar53qY3EtG8WTsCiMYjFL9Jo6gxA9+5 l81Lsj7ppxt4A== From: cel@kernel.org To: Luis Chamberlain , Chandan Babu R , Jeff Layton Cc: , Chuck Lever Subject: [PATCH v1 06/13] playbooks: Add a role to create an LVM volume group Date: Mon, 10 Mar 2025 10:18:06 -0400 Message-ID: <20250310141813.969325-7-cel@kernel.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250310141813.969325-1-cel@kernel.org> References: <20250310141813.969325-1-cel@kernel.org> Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Chuck Lever 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 --- 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