now correctly checks absolute path for src= existance for links

also updated docs to be a bit clearer on symlink behaviour
reviewable/pr18780/r1
Brian Coca 11 years ago
parent ff5560f00c
commit 4fd957620a

@ -81,8 +81,8 @@ options:
default: null default: null
choices: [] choices: []
description: description:
- path of the file to link to (applies only to C(state=link)). Will accept absolute, - path of the file to link to (applies only to C(state= link or hard)). Will accept absolute,
relative and nonexisting paths. Relative paths are not expanded. relative and nonexisting (with C(force)) paths. Relative paths are not expanded.
seuser: seuser:
required: false required: false
default: null default: null
@ -266,8 +266,12 @@ def main():
elif state in ['link','hard']: elif state in ['link','hard']:
if not os.path.exists(src) and not force: absrc = src
module.fail_json(path=path, src=src, msg='src file does not exist') if not os.path.isabs(absrc):
absrc = os.path.normpath('%s/%s' % (os.path.dirname(path), absrc))
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)
if state == 'hard': if state == 'hard':
if not os.path.isabs(src): if not os.path.isabs(src):

Loading…
Cancel
Save