@@ -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"
@@ -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
@@ -1,5 +1,4 @@
---
iscsi_target_packages:
- - lvm2
- targetcli-fb
- sg3_utils
@@ -1,6 +1,5 @@
---
iscsi_target_packages:
- - lvm2
- targetcli
- sg3_utils
@@ -1,6 +1,5 @@
---
iscsi_target_packages:
- - lvm2
- targetcli-fb
- sg3_utils
@@ -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"
@@ -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"
@@ -1,5 +1,4 @@
---
-smbd_lvm_pvs: []
smbd_share_device_prefix: ""
smbd_share_device_count: 0
smbd_share_label: "share"
@@ -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
new file mode 100644
@@ -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
new file mode 100644
@@ -0,0 +1,2 @@
+---
+physical_volumes: []
new file mode 100644
@@ -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(',') }}"