From 9008e8017b1d4f9493adf4c3d38df187ca2d037a Mon Sep 17 00:00:00 2001 From: Jiri Tyr Date: Tue, 14 Feb 2017 17:09:48 +0000 Subject: [PATCH] Fixing mounting of multiple sources to the same dest (#21413) --- lib/ansible/modules/system/mount.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/ansible/modules/system/mount.py b/lib/ansible/modules/system/mount.py index c979ed614a6..6a80259ca10 100644 --- a/lib/ansible/modules/system/mount.py +++ b/lib/ansible/modules/system/mount.py @@ -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 src is None: # That's for unmounted/absent - if dest in linux_mounts: - is_mounted = True + for m in linux_mounts: + if m['dst'] == dest: + is_mounted = True else: + mounted_src = None + + for m in linux_mounts: + if m['dst'] == dest: + mounted_src = m['src'] + # 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 else: bin_path = module.get_bin_path('mount', required=True) @@ -518,7 +525,7 @@ def get_linux_mounts(module): mntinfo.append(record) - mounts = {} + mounts = [] for mnt in mntinfo: src = mnt['src'] @@ -551,12 +558,15 @@ def get_linux_mounts(module): break - mounts[mnt['dst']] = { + record = { + 'dst': mnt['dst'], 'src': src, 'opts': mnt['opts'], 'fs': mnt['fs'] } + mounts.append(record) + return mounts