From 9c0051e3256f3550ddab5abd3f60bfc7cc02eb63 Mon Sep 17 00:00:00 2001 From: Robert Sander Date: Sat, 13 Jun 2026 16:33:49 +0200 Subject: [PATCH] filesystem module gfs2 support (#12218) * adds GFS2 to filesystem module * adds changelog fragment * adds PR URL * adds blank line * removes RedHat, package not available * renames file and removes license remark * adds remark about adding gfs2 to 13.1.0 * corrects typo * Update changelogs/fragments/12218-filesystem-gfs2.yaml Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --------- Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- changelogs/fragments/12218-filesystem-gfs2.yaml | 2 ++ plugins/modules/filesystem.py | 10 +++++++++- tests/integration/targets/filesystem/defaults/main.yml | 1 + tests/integration/targets/filesystem/tasks/setup.yml | 6 ++++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/12218-filesystem-gfs2.yaml diff --git a/changelogs/fragments/12218-filesystem-gfs2.yaml b/changelogs/fragments/12218-filesystem-gfs2.yaml new file mode 100644 index 0000000000..8da71078e6 --- /dev/null +++ b/changelogs/fragments/12218-filesystem-gfs2.yaml @@ -0,0 +1,2 @@ +minor_changes: + - filesystem - adds GFS2 support (https://github.com/ansible-collections/community.general/pull/12218). diff --git a/plugins/modules/filesystem.py b/plugins/modules/filesystem.py index 746f1660d0..a792be17a3 100644 --- a/plugins/modules/filesystem.py +++ b/plugins/modules/filesystem.py @@ -35,11 +35,12 @@ options: default: present version_added: 1.3.0 fstype: - choices: [bcachefs, btrfs, ext2, ext3, ext4, ext4dev, f2fs, lvm, ocfs2, reiserfs, xfs, vfat, swap, ufs] + choices: [bcachefs, btrfs, ext2, ext3, ext4, ext4dev, f2fs, lvm, ocfs2, reiserfs, xfs, vfat, swap, ufs, gfs2] description: - Filesystem type to be created. This option is required with O(state=present) (or if O(state) is omitted). - V(ufs) support has been added in community.general 3.4.0. - V(bcachefs) support has been added in community.general 8.6.0. + - V(gfs2) support has been added in community.general 13.1.0. type: str aliases: [type] dev: @@ -611,6 +612,12 @@ class UFS(Filesystem): return fragmentsize * providersize +class GFS2(Filesystem): + MKFS = "mkfs.gfs2" + MKFS_FORCE_FLAGS = ["-O"] + MKFS_SET_UUID_OPTIONS = ["-U"] + + FILESYSTEMS = { "bcachefs": Bcachefs, "ext2": Ext2, @@ -626,6 +633,7 @@ FILESYSTEMS = { "LVM2_member": LVM, "swap": Swap, "ufs": UFS, + "gfs2": GFS2, } diff --git a/tests/integration/targets/filesystem/defaults/main.yml b/tests/integration/targets/filesystem/defaults/main.yml index 7ff30bcd54..3ae2ffc2ed 100644 --- a/tests/integration/targets/filesystem/defaults/main.yml +++ b/tests/integration/targets/filesystem/defaults/main.yml @@ -29,6 +29,7 @@ tested_filesystems: lvm: {fssize: 20, grow: true, new_uuid: 'something'} swap: {fssize: 10, grow: false, new_uuid: null} # grow not implemented ufs: {fssize: 10, grow: true, new_uuid: null} + gfs2: {fssize: 10, grow: false, new_uuid: null} get_uuid_any: "blkid -c /dev/null -o value -s UUID {{ dev }}" diff --git a/tests/integration/targets/filesystem/tasks/setup.yml b/tests/integration/targets/filesystem/tasks/setup.yml index 5a52f620b9..a6a6c823c9 100644 --- a/tests/integration/targets/filesystem/tasks/setup.yml +++ b/tests/integration/targets/filesystem/tasks/setup.yml @@ -88,6 +88,12 @@ state: present when: ansible_facts.os_family == 'Debian' +- name: "Install GFS2" + ansible.builtin.package: + name: gfs2-utils + state: present + when: ansible_facts.os_family in ['Debian', 'Suse', 'Ubuntu'] + - name: "Install f2fs tools and get version" when: - ansible_facts.os_family != 'RedHat' or ansible_facts.distribution == 'Fedora'