From 961d4b0d6c25cb89c353af64cdc325ecf9edf21e Mon Sep 17 00:00:00 2001
From: Serge van Ginderachter <serge@vanginderachter.be>
Date: Thu, 17 Jul 2014 14:49:40 +0200
Subject: [PATCH] execute the mount after path validation

This avoids a stale situation where name/path contains some impossible path,
but gets configured (faultly) in fstab, and the module only fails after that,
when creating that path.
---
 system/mount | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/system/mount b/system/mount
index a886a04dbd5..9dc6fbe7b8c 100755
--- a/system/mount
+++ b/system/mount
@@ -307,7 +307,6 @@ def main():
         module.exit_json(changed=changed, **args)
 
     if state in ['mounted', 'present']:
-        name, changed = set_mount(**args)
         if state == 'mounted':
             if not os.path.exists(name):
                 try:
@@ -315,6 +314,8 @@ def main():
                 except (OSError, IOError), e:
                     module.fail_json(msg="Error making dir %s: %s" % (name, str(e)))
 
+        name, changed = set_mount(**args)
+        if state == 'mounted':
             res = 0
             if os.path.ismount(name):
                 if changed: