From 51f2ddd445e91765be4decd4f594adf781d15867 Mon Sep 17 00:00:00 2001 From: Hungtsetse <33526088+hungtsetse@users.noreply.github.com> Date: Tue, 26 Sep 2023 23:12:03 +0800 Subject: [PATCH] Extend mount info (#81768) --- changelogs/fragments/80478-extend-mount-info.yml | 2 ++ lib/ansible/module_utils/facts/hardware/linux.py | 5 ++++- test/units/module_utils/facts/hardware/test_linux.py | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/80478-extend-mount-info.yml diff --git a/changelogs/fragments/80478-extend-mount-info.yml b/changelogs/fragments/80478-extend-mount-info.yml new file mode 100644 index 00000000000..fcb20e15116 --- /dev/null +++ b/changelogs/fragments/80478-extend-mount-info.yml @@ -0,0 +1,2 @@ +minor_changes: + - "Add ``dump`` and ``passno`` mount information to facts component (https://github.com/ansible/ansible/issues/80478)" diff --git a/lib/ansible/module_utils/facts/hardware/linux.py b/lib/ansible/module_utils/facts/hardware/linux.py index 4e6305cb185..f6e87ac3246 100644 --- a/lib/ansible/module_utils/facts/hardware/linux.py +++ b/lib/ansible/module_utils/facts/hardware/linux.py @@ -556,6 +556,7 @@ class LinuxHardware(Hardware): fields = [self._replace_octal_escapes(field) for field in fields] device, mount, fstype, options = fields[0], fields[1], fields[2], fields[3] + dump, passno = int(fields[4]), int(fields[5]) if not device.startswith(('/', '\\')) and ':/' not in device or fstype == 'none': continue @@ -563,7 +564,9 @@ class LinuxHardware(Hardware): mount_info = {'mount': mount, 'device': device, 'fstype': fstype, - 'options': options} + 'options': options, + 'dump': dump, + 'passno': passno} if mount in bind_mounts: # only add if not already there, we might have a plain /etc/mtab diff --git a/test/units/module_utils/facts/hardware/test_linux.py b/test/units/module_utils/facts/hardware/test_linux.py index e3e07e7850c..4cf89c1469b 100644 --- a/test/units/module_utils/facts/hardware/test_linux.py +++ b/test/units/module_utils/facts/hardware/test_linux.py @@ -73,12 +73,14 @@ class TestFactsLinuxHardwareGetMountFacts(unittest.TestCase): 'block_total': 105871006, 'block_used': 5713133, 'device': '/dev/mapper/fedora_dhcp129--186-home', + 'dump': 0, 'fstype': 'ext4', 'inode_available': 26860880, 'inode_total': 26902528, 'inode_used': 41648, 'mount': '/home', 'options': 'rw,seclabel,relatime,data=ordered', + 'passno': 0, 'size_available': 410246647808, 'size_total': 433647640576, 'uuid': 'N/A'}