From f096359608ca05ceac77a8c6d7cff685f0950133 Mon Sep 17 00:00:00 2001 From: sysadmin75 Date: Sat, 27 Dec 2014 20:08:25 -0500 Subject: [PATCH] ansible-modules-core #530 fix - Mount module does not accept spaces in mount point path --- lib/ansible/modules/system/mount.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/system/mount.py b/lib/ansible/modules/system/mount.py index 1564d0999f4..ad3887b2707 100644 --- a/lib/ansible/modules/system/mount.py +++ b/lib/ansible/modules/system/mount.py @@ -116,6 +116,11 @@ def set_mount(**kwargs): ) args.update(kwargs) + # save the mount name before space replacement + origname = args['name'] + # replace any space in mount name with '\040' to make it fstab compatible (man fstab) + args['name'] = args['name'].replace(' ', r'\040') + new_line = '%(src)s %(name)s %(fstype)s %(opts)s %(dump)s %(passno)s\n' to_write = [] @@ -160,7 +165,8 @@ def set_mount(**kwargs): if changed: write_fstab(to_write, args['fstab']) - return (args['name'], changed) + # mount function needs origname + return (origname, changed) def unset_mount(**kwargs): @@ -175,6 +181,11 @@ def unset_mount(**kwargs): ) args.update(kwargs) + # save the mount name before space replacement + origname = args['name'] + # replace any space in mount name with '\040' to make it fstab compatible (man fstab) + args['name'] = args['name'].replace(' ', r'\040') + to_write = [] changed = False for line in open(args['fstab'], 'r').readlines(): @@ -203,7 +214,8 @@ def unset_mount(**kwargs): if changed: write_fstab(to_write, args['fstab']) - return (args['name'], changed) + # umount needs origname + return (origname, changed) def mount(module, **kwargs):