get_mount_facts -- find bind mounts and add info to options field (#12036)

* get_mount_facts -- find bind mounts and add info to options field

* get_mount_facts -- only run findmnt if get_bin_path() finds the binary
pull/15406/head
Wolfgang Karall 9 years ago committed by Brian Coca
parent 4822c2caa5
commit 7a9b8e43da

@ -1083,6 +1083,19 @@ class LinuxHardware(Hardware):
def get_mount_facts(self):
uuids = dict()
self.facts['mounts'] = []
bind_mounts = []
findmntPath = module.get_bin_path("findmnt")
if findmntPath:
rc, out, err = module.run_command("%s -lnur" % ( findmntPath ), use_unsafe_shell=True)
if rc == 0:
# find bind mounts, in case /etc/mtab is a symlink to /proc/mounts
for line in out.split('\n'):
fields = line.rstrip('\n').split()
if(len(fields) < 2):
continue
if(re.match(".*\]",fields[1])):
bind_mounts.append(fields[0])
mtab = get_file_content('/etc/mtab', '')
for line in mtab.split('\n'):
fields = line.rstrip('\n').split()
@ -1101,6 +1114,11 @@ class LinuxHardware(Hardware):
uuid = out.strip()
uuids[fields[0]] = uuid
if fields[1] in bind_mounts:
# only add if not already there, we might have a plain /etc/mtab
if not re.match(".*bind.*", fields[3]):
fields[3] += ",bind"
self.facts['mounts'].append(
{'mount': fields[1],
'device':fields[0],

Loading…
Cancel
Save