Fixing mounting of multiple sources to the same dest (#21413)

This commit is contained in:
Jiri Tyr 2017-02-14 17:09:48 +00:00 committed by Toshio Kuratomi
parent 8c6606aeee
commit 9008e8017b

View file

@ -454,11 +454,18 @@ def is_bind_mounted(module, linux_mounts, dest, src=None, fstype=None):
if get_platform() == 'Linux' and linux_mounts is not None: 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: for m in linux_mounts:
is_mounted = True if m['dst'] == dest:
is_mounted = True
else: else:
mounted_src = None
for m in linux_mounts:
if m['dst'] == dest:
mounted_src = m['src']
# That's for mounted # That's for mounted
if dest in linux_mounts and linux_mounts[dest]['src'] == src: if mounted_src is not None and mounted_src == src:
is_mounted = True is_mounted = True
else: else:
bin_path = module.get_bin_path('mount', required=True) bin_path = module.get_bin_path('mount', required=True)
@ -518,7 +525,7 @@ def get_linux_mounts(module):
mntinfo.append(record) mntinfo.append(record)
mounts = {} mounts = []
for mnt in mntinfo: for mnt in mntinfo:
src = mnt['src'] src = mnt['src']
@ -551,12 +558,15 @@ def get_linux_mounts(module):
break break
mounts[mnt['dst']] = { record = {
'dst': mnt['dst'],
'src': src, 'src': src,
'opts': mnt['opts'], 'opts': mnt['opts'],
'fs': mnt['fs'] 'fs': mnt['fs']
} }
mounts.append(record)
return mounts return mounts