Skip to content

Commit

Permalink
Skip symlink creation if exist or remove it before create
Browse files Browse the repository at this point in the history
  • Loading branch information
rakhinskiy committed Feb 8, 2024
1 parent 14dc007 commit 7ee3faa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/molecule/provisioner/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,12 @@ def _link_or_update_vars(self):
if not os.path.exists(source):
msg = f"The source path '{source}' does not exist."
util.sysexit_with_message(msg)
if os.path.exists(target):
if os.path.realpath(target) == os.path.realpath(source):
LOG.debug(f"Required symlink {target} to {source} exist, skip creation")
continue
LOG.debug(f"Required symlink {target} exist with another source")
os.remove(target)
msg = f"Inventory {source} linked to {target}"
LOG.debug(msg)
os.symlink(source, target)
Expand Down

0 comments on commit 7ee3faa

Please sign in to comment.