use custom ismount function in mount module (#2737)

* based on cpython os.path.ismount
* includes patch from http://bugs.python.org/issue2466
* fixes #2186
* when the upstream bug is fixed this should be removed/rewritten
* use ismount from module_utils
pull/18777/head
Robin Roth 9 years ago committed by Matt Clay
parent 075edf7bb2
commit ee06cd27b2

@ -234,7 +234,7 @@ def mount(module, **kwargs):
cmd = [ mount_bin, ]
if os.path.ismount(name):
if ismount(name):
cmd += [ '-o', 'remount', ]
if get_platform().lower() == 'freebsd':
@ -311,7 +311,7 @@ def main():
if state == 'absent':
name, changed = unset_mount(module, **args)
if changed and not module.check_mode:
if os.path.ismount(name):
if ismount(name):
res,msg = umount(module, **args)
if res:
module.fail_json(msg="Error unmounting %s: %s" % (name, msg))
@ -325,7 +325,7 @@ def main():
module.exit_json(changed=changed, **args)
if state == 'unmounted':
if os.path.ismount(name):
if ismount(name):
if not module.check_mode:
res,msg = umount(module, **args)
if res:
@ -345,7 +345,7 @@ def main():
name, changed = set_mount(module, **args)
if state == 'mounted':
res = 0
if os.path.ismount(name):
if ismount(name):
if changed and not module.check_mode:
res,msg = mount(module, **args)
elif 'bind' in args.get('opts', []):
@ -375,4 +375,6 @@ def main():
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.ismount import *
main()

Loading…
Cancel
Save