mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Correctly examine path for relative links in file module
Fixes #7515 Fixes #7537
This commit is contained in:
parent
bb3426327c
commit
202ac68995
1 changed files with 5 additions and 4 deletions
|
@ -189,10 +189,11 @@ def main():
|
||||||
|
|
||||||
elif state in ['link','hard']:
|
elif state in ['link','hard']:
|
||||||
|
|
||||||
absrc = src
|
if os.path.isdir(path):
|
||||||
if not os.path.isabs(absrc):
|
relpath = path
|
||||||
absrc = os.path.abspath(src)
|
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:
|
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)
|
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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue