summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--library/files/file9
1 files changed, 5 insertions, 4 deletions
diff --git a/library/files/file b/library/files/file
index 1306ef5f0a..d2a20dbb7a 100644
--- a/library/files/file
+++ b/library/files/file
@@ -182,10 +182,11 @@ def main():
elif state in ['link','hard']:
- absrc = src
- if not os.path.isabs(absrc):
- absrc = os.path.abspath(src)
-
+ if os.path.isdir(path):
+ relpath = path
+ else:
+ relpath = os.path.dirname(path)
+ absrc = os.path.normpath('%s/%s' % (relpath, os.path.basename(src)))
if not os.path.exists(absrc) and not force:
module.fail_json(path=path, src=src, msg='src file does not exist, use "force=yes" if you really want to create the link: %s' % absrc)