diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 6ae21c54a6c..bf286c2eb67 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -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],