From ffb87adbc2fa14d5162b185a2621583545a78448 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 28 May 2014 11:46:06 -0500 Subject: [PATCH] Correctly examine path for relative links in file module Fixes #7515 Fixes #7537 --- files/file | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/files/file b/files/file index 32588e56e6e..8d3a71a2379 100644 --- a/files/file +++ b/files/file @@ -189,10 +189,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)