From 2214c747a22d594177f524d1f7e7e1f078c52491 Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Mon, 7 May 2018 17:08:46 +0200 Subject: [PATCH] facts: Detecting NVME partitions under Linux (#39730) In the current state of the code, the nvme partitions are returned as empty as in : "ansible_devices": { "nvme0n1": { "model": "SAMSUNG MZVLW256HEHP-000L7", "partitions": {}, The parsing of the /sys/block/ try to find a disk named like : as in sda1 for sda But in the nvme context, the partition of nvme0n1 is named nvme0n1p1. This add a possible 'p' between the diskname and the partname. This patch simply add the option of having a 'p' between the diskname and the partname. The patch works on my host : "model": "INTEL SSDPEDMD400G4", "partitions": { "nvme0n1p1": { ... "size": "93.13 GB", } Fixes #38742 Signed-off-by: Erwan Velu --- lib/ansible/module_utils/facts/hardware/linux.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/facts/hardware/linux.py b/lib/ansible/module_utils/facts/hardware/linux.py index b758d11bf7..fd8ffb985a 100644 --- a/lib/ansible/module_utils/facts/hardware/linux.py +++ b/lib/ansible/module_utils/facts/hardware/linux.py @@ -615,7 +615,7 @@ class LinuxHardware(Hardware): d['partitions'] = {} for folder in os.listdir(sysdir): - m = re.search("(" + diskname + r"\d+)", folder) + m = re.search("(" + diskname + r"[p]*\d+)", folder) if m: part = {} partname = m.group(1)