From 2b4688a0bd00b31be92ce9094da5f1dc74af5b99 Mon Sep 17 00:00:00 2001 From: Mike Grozak Date: Thu, 6 Feb 2014 17:20:32 +0100 Subject: [PATCH] Started the development of the 'chdir' functionality for file module - creation symlinks without the base directory prefix --- library/files/file | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/library/files/file b/library/files/file index bef175873e..4b59b652c7 100644 --- a/library/files/file +++ b/library/files/file @@ -149,6 +149,7 @@ def main(): original_basename = dict(required=False), # Internal use only, for recursive ops recurse = dict(default='no', type='bool'), force = dict(required=False,default=False,type='bool'), + chdir = dict(required=False,default=False), diff_peek = dict(default=None), validate = dict(required=False, default=None), ), @@ -159,8 +160,16 @@ def main(): params = module.params state = params['state'] force = params['force'] + + params['chdir'] = chdir = os.path.expanduser(params['chdir']) params['path'] = path = os.path.expanduser(params['path']) + if state == 'link' and chdir is not None and os.isdir(chdir): + os.chdir(chdir) + # catch exception permission deny, no directory, etc + # save current working directory, chdir to it at the end of the module + # or before any escape + # short-circuit for diff_peek if params.get('diff_peek', None) is not None: appears_binary = False