mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #9428 from landryb/openbsd_add_mount_facts
parse /etc/fstab on OpenBSD to get mount facts
This commit is contained in:
commit
aed493158c
1 changed files with 14 additions and 0 deletions
|
@ -1103,6 +1103,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):
|
||||
|
@ -1115,6 +1116,19 @@ 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()
|
||||
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):
|
||||
# Get free memory. vmstat output looks like:
|
||||
# procs memory page disks traps cpu
|
||||
|
|
Loading…
Reference in a new issue