Fall back if mountinfo reading failed (fixing #5603)
This commit is contained in:
parent
82e74668a6
commit
b264f8c1cd
1 changed files with 7 additions and 2 deletions
|
@ -398,7 +398,7 @@ def is_bind_mounted(module, linux_mounts, dest, src=None, fstype=None):
|
||||||
|
|
||||||
is_mounted = False
|
is_mounted = False
|
||||||
|
|
||||||
if get_platform() == 'Linux':
|
if get_platform() == 'Linux' and linux_mounts is not None:
|
||||||
if src is None:
|
if src is None:
|
||||||
# That's for unmounted/absent
|
# That's for unmounted/absent
|
||||||
if dest in linux_mounts:
|
if dest in linux_mounts:
|
||||||
|
@ -439,7 +439,7 @@ def get_linux_mounts(module):
|
||||||
try:
|
try:
|
||||||
f = open(mntinfo_file)
|
f = open(mntinfo_file)
|
||||||
except IOError:
|
except IOError:
|
||||||
module.fail_json(msg="Cannot open file %s" % mntinfo_file)
|
return
|
||||||
|
|
||||||
lines = map(str.strip, f.readlines())
|
lines = map(str.strip, f.readlines())
|
||||||
|
|
||||||
|
@ -604,6 +604,11 @@ def main():
|
||||||
if get_platform() == 'Linux':
|
if get_platform() == 'Linux':
|
||||||
linux_mounts = get_linux_mounts(module)
|
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
|
# Override defaults with user specified params
|
||||||
for key in ('src', 'fstype', 'passno', 'opts', 'dump', 'fstab'):
|
for key in ('src', 'fstype', 'passno', 'opts', 'dump', 'fstab'):
|
||||||
if module.params[key] is not None:
|
if module.params[key] is not None:
|
||||||
|
|
Loading…
Reference in a new issue