From d68eb7272e069891f60f91ae71d8c7f7473c41c3 Mon Sep 17 00:00:00 2001 From: Landry Breuil Date: Mon, 27 Oct 2014 20:27:57 +0100 Subject: [PATCH 1/2] parse /etc/fstab on OpenBSD to get mount facts --- lib/ansible/module_utils/facts.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 09332e00be..555a81df2c 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -926,6 +926,7 @@ class OpenBSDHardware(Hardware): self.get_memory_facts() self.get_processor_facts() self.get_device_facts() + self.get_mount_facts() return self.facts def get_sysctl(self): @@ -938,6 +939,17 @@ class OpenBSDHardware(Hardware): sysctl[key] = value.strip() return sysctl + @timeout(10) + def get_mount_facts(self): + self.facts['mounts'] = [] + fstab = get_file_content('/etc/fstab') + if fstab: + for line in fstab.split('\n'): + if line.startswith('#') or line.strip() == '': + continue + fields = re.sub(r'\s+',' ',line.rstrip('\n')).split() + self.facts['mounts'].append({'mount': fields[1], 'device': fields[0], 'fstype' : fields[2], 'options': fields[3]}) + def get_memory_facts(self): # Get free memory. vmstat output looks like: # procs memory page disks traps cpu From 792d8d1808211167e5d15e015370c73a3822c0b6 Mon Sep 17 00:00:00 2001 From: Landry Breuil Date: Tue, 28 Oct 2014 10:04:59 +0100 Subject: [PATCH 2/2] Ignore swap or altroot entries --- lib/ansible/module_utils/facts.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 555a81df2c..9e857ff994 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -948,6 +948,8 @@ class OpenBSDHardware(Hardware): if line.startswith('#') or line.strip() == '': continue fields = re.sub(r'\s+',' ',line.rstrip('\n')).split() + if fields[1] == 'none' or fields[3] == 'xx': + continue self.facts['mounts'].append({'mount': fields[1], 'device': fields[0], 'fstype' : fields[2], 'options': fields[3]}) def get_memory_facts(self):