|
|
@ -82,19 +82,19 @@ def main():
|
|
|
|
module = AnsibleModule(
|
|
|
|
module = AnsibleModule(
|
|
|
|
# not checking because of daisy chain to file module
|
|
|
|
# not checking because of daisy chain to file module
|
|
|
|
argument_spec = dict(
|
|
|
|
argument_spec = dict(
|
|
|
|
src=dict(required=False),
|
|
|
|
src = dict(required=False),
|
|
|
|
content=dict(required=False),
|
|
|
|
content = dict(required=False),
|
|
|
|
dest=dict(required=True),
|
|
|
|
dest = dict(required=True),
|
|
|
|
backup=dict(default=False, type='bool'),
|
|
|
|
backup = dict(default=False, type='bool'),
|
|
|
|
force = dict(default='yes', aliases=['thirsty'], type='bool'),
|
|
|
|
force = dict(default=True, aliases=['thirsty'], type='bool'),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
add_file_common_args=True,
|
|
|
|
add_file_common_args=True,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
src = os.path.expanduser(module.params['src'])
|
|
|
|
src = os.path.expanduser(module.params['src'])
|
|
|
|
dest = os.path.expanduser(module.params['dest'])
|
|
|
|
dest = os.path.expanduser(module.params['dest'])
|
|
|
|
backup = module.params['backup']
|
|
|
|
backup = module.params['backup']
|
|
|
|
force = module.params['force']
|
|
|
|
force = module.params['force']
|
|
|
|
|
|
|
|
|
|
|
|
if not os.path.exists(src):
|
|
|
|
if not os.path.exists(src):
|
|
|
|
module.fail_json(msg="Source %s failed to transfer" % (src))
|
|
|
|
module.fail_json(msg="Source %s failed to transfer" % (src))
|
|
|
@ -105,8 +105,8 @@ def main():
|
|
|
|
md5sum_dest = None
|
|
|
|
md5sum_dest = None
|
|
|
|
|
|
|
|
|
|
|
|
if os.path.exists(dest):
|
|
|
|
if os.path.exists(dest):
|
|
|
|
if not force:
|
|
|
|
# if not force:
|
|
|
|
module.exit_json(msg="file already exists", src=src, dest=dest, changed=False)
|
|
|
|
# module.exit_json(msg="file already exists and force is set (%s)" % force, src=src, dest=dest, changed=False)
|
|
|
|
if (os.path.isdir(dest)):
|
|
|
|
if (os.path.isdir(dest)):
|
|
|
|
basename = os.path.basename(src)
|
|
|
|
basename = os.path.basename(src)
|
|
|
|
dest = os.path.join(dest, basename)
|
|
|
|
dest = os.path.join(dest, basename)
|
|
|
|