mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-11 16:44:22 -07:00
Merge pull request #4801 from sspans/devel
Add support for relative symlinks
This commit is contained in:
commit
bd9fb39634
1 changed files with 7 additions and 8 deletions
|
@ -280,20 +280,19 @@ def main():
|
||||||
|
|
||||||
elif state in ['link','hard']:
|
elif state in ['link','hard']:
|
||||||
|
|
||||||
if os.path.isabs(src):
|
if state == 'hard':
|
||||||
abs_src = src
|
if os.path.isabs(src):
|
||||||
else:
|
abs_src = src
|
||||||
module.fail_json(msg="absolute paths are required")
|
else:
|
||||||
|
module.fail_json(msg="absolute paths are required")
|
||||||
|
|
||||||
if not os.path.exists(abs_src) and not force:
|
if not os.path.exists(abs_src) and not force:
|
||||||
module.fail_json(path=path, src=src, msg='src file does not exist')
|
module.fail_json(path=path, src=src, msg='src file does not exist')
|
||||||
|
|
||||||
if prev_state == 'absent':
|
if prev_state == 'absent':
|
||||||
changed = True
|
changed = True
|
||||||
elif prev_state == 'link':
|
elif prev_state == 'link':
|
||||||
old_src = os.readlink(path)
|
old_src = os.readlink(path)
|
||||||
if not os.path.isabs(old_src):
|
|
||||||
old_src = os.path.join(os.path.dirname(path), old_src)
|
|
||||||
if old_src != src:
|
if old_src != src:
|
||||||
changed = True
|
changed = True
|
||||||
elif prev_state == 'hard':
|
elif prev_state == 'hard':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue