From f4593ecac79ee33c343f9736ad09aabf91b05c56 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Mon, 24 Oct 2016 15:44:52 +0200 Subject: [PATCH] Add support for getting hardware facts on GNU Hurd (#18152) * Fallback to /proc/mounts if /etc/mtab do not exist On modern system, the file is just a compatibility symlink, and some system (like GNU Hurd) do not have it, but provides /proc/mounts * Add support for uptime, memory and mount facts on GNU Hurd --- lib/ansible/module_utils/facts.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 106f385a0c..64f0038633 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -1281,7 +1281,11 @@ class LinuxHardware(Hardware): return bind_mounts def _mtab_entries(self): - mtab = get_file_content('/etc/mtab', '') + mtab_file = '/etc/mtab' + if not os.path.exists(mtab_file): + mtab_file = '/proc/mounts' + + mtab = get_file_content(mtab_file, '') mtab_entries = [] for line in mtab.splitlines(): fields = line.split() @@ -2159,6 +2163,20 @@ class Darwin(Hardware): if rc == 0: self.facts['memfree_mb'] = int(out.splitlines()[-1].split()[1]) // 1024 // 1024 +class HurdHardware(LinuxHardware): + """ + GNU Hurd specific subclass of Hardware. Define memory and mount facts + based on procfs compatibility translator mimicking the interface of + the Linux kernel. + """ + + platform = 'GNU' + + def populate(self): + self.get_uptime_facts() + self.get_memory_facts() + self.get_mount_facts() + return self.facts class Network(Facts): """