mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-28 23:51:23 -07:00
Add partition uuid to facts for Linux. (#16986)
Works by looking for partition name in /dev/disk/by-uuid
This commit is contained in:
parent
3d07f848f2
commit
ab678738d6
1 changed files with 14 additions and 0 deletions
|
@ -1326,6 +1326,7 @@ class LinuxHardware(Hardware):
|
||||||
if not part['sectorsize']:
|
if not part['sectorsize']:
|
||||||
part['sectorsize'] = get_file_content(part_sysdir + "/queue/hw_sector_size",512)
|
part['sectorsize'] = get_file_content(part_sysdir + "/queue/hw_sector_size",512)
|
||||||
part['size'] = self.module.pretty_bytes((float(part['sectors']) * float(part['sectorsize'])))
|
part['size'] = self.module.pretty_bytes((float(part['sectors']) * float(part['sectorsize'])))
|
||||||
|
part['uuid'] = get_partition_uuid(partname)
|
||||||
self.get_holders(part, part_sysdir)
|
self.get_holders(part, part_sysdir)
|
||||||
|
|
||||||
d['partitions'][partname] = part
|
d['partitions'][partname] = part
|
||||||
|
@ -3224,6 +3225,19 @@ def get_uname_version(module):
|
||||||
return out
|
return out
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def get_partition_uuid(partname):
|
||||||
|
try:
|
||||||
|
uuids = os.listdir("/dev/disk/by-uuid")
|
||||||
|
except OSError:
|
||||||
|
return
|
||||||
|
|
||||||
|
for uuid in uuids:
|
||||||
|
dev = os.path.realpath("/dev/disk/by-uuid/" + uuid)
|
||||||
|
if dev == ("/dev/" + partname):
|
||||||
|
return uuid
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
def get_file_lines(path):
|
def get_file_lines(path):
|
||||||
'''get list of lines from file'''
|
'''get list of lines from file'''
|
||||||
data = get_file_content(path)
|
data = get_file_content(path)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue