1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #1361 from lantins/devel

Copy module can replace symlink with a real file.
This commit is contained in:
Michael DeHaan 2012-10-18 16:59:45 -07:00
commit d58bc4da4e
2 changed files with 6 additions and 2 deletions

View file

@ -100,11 +100,15 @@ def main():
module.fail_json(msg="Destination %s not writable" % (os.path.dirname(dest))) module.fail_json(msg="Destination %s not writable" % (os.path.dirname(dest)))
backup_file = None backup_file = None
if md5sum_src != md5sum_dest: if md5sum_src != md5sum_dest or os.path.islink(dest):
try: try:
if backup: if backup:
if os.path.exists(dest): if os.path.exists(dest):
backup_file = module.backup_local(dest) backup_file = module.backup_local(dest)
# allow for conversion from symlink.
if os.path.islink(dest):
os.unlink(dest)
open(dest, 'w').close()
#TODO:pid + epoch should avoid most collisions, hostname/mac for those using nfs? #TODO:pid + epoch should avoid most collisions, hostname/mac for those using nfs?
# might be an issue with exceeding path length # might be an issue with exceeding path length
dest_tmp = "%s.%s.%s.tmp" % (dest,os.getpid(),time.time()) dest_tmp = "%s.%s.%s.tmp" % (dest,os.getpid(),time.time())

View file

@ -31,7 +31,7 @@ description:
version_added: "0.2" version_added: "0.2"
options: [] options: []
examples: examples:
- code: ansible www.example.net -m facter - code: ansible www.example.net -m facter
description: "Example command-line invocation" description: "Example command-line invocation"
notes: [] notes: []
requirements: [ "facter", "ruby-json" ] requirements: [ "facter", "ruby-json" ]