summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Tyr <jiri.tyr@gmail.com>2016-11-21 13:55:51 +0000
committerToshio Kuratomi <a.badger@gmail.com>2016-11-23 07:24:13 -0800
commit373dcef535f41dcd6d493369f64920329f4666ad (patch)
tree19c9835b8bd903926b4aaa5e4456337a1bbf2812
parent3b54dd0375f83fd7b275926ad80919f712d05ea6 (diff)
downloadansible-modules-core-373dcef535f41dcd6d493369f64920329f4666ad.tar.gz
Fall back if mountinfo reading failed (fixing #5603)
(cherry picked from commit 351dd9344e4f9c41d47ba574f554eb16c15c2ce2)
-rw-r--r--system/mount.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/system/mount.py b/system/mount.py
index 9e67e1f6..b94752ff 100644
--- a/system/mount.py
+++ b/system/mount.py
@@ -398,7 +398,7 @@ def is_bind_mounted(module, linux_mounts, dest, src=None, fstype=None):
is_mounted = False
- if get_platform() == 'Linux':
+ if get_platform() == 'Linux' and linux_mounts is not None:
if src is None:
# That's for unmounted/absent
if dest in linux_mounts:
@@ -439,7 +439,7 @@ def get_linux_mounts(module):
try:
f = open(mntinfo_file)
except IOError:
- module.fail_json(msg="Cannot open file %s" % mntinfo_file)
+ return
lines = map(str.strip, f.readlines())
@@ -604,6 +604,11 @@ def main():
if get_platform() == 'Linux':
linux_mounts = get_linux_mounts(module)
+ if linux_mounts is None:
+ args['warnings'] = (
+ 'Cannot open file /proc/self/mountinfo. '
+ 'Bind mounts might be misinterpreted.')
+
# Override defaults with user specified params
for key in ('src', 'fstype', 'passno', 'opts', 'dump', 'fstab'):
if module.params[key] is not None: