|
|
@ -19,7 +19,7 @@
|
|
|
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import time
|
|
|
|
import tempfile
|
|
|
|
|
|
|
|
|
|
|
|
DOCUMENTATION = '''
|
|
|
|
DOCUMENTATION = '''
|
|
|
|
---
|
|
|
|
---
|
|
|
@ -214,7 +214,8 @@ def main():
|
|
|
|
backup = dict(default=False, type='bool'),
|
|
|
|
backup = dict(default=False, type='bool'),
|
|
|
|
force = dict(default=True, aliases=['thirsty'], type='bool'),
|
|
|
|
force = dict(default=True, aliases=['thirsty'], type='bool'),
|
|
|
|
validate = dict(required=False, type='str'),
|
|
|
|
validate = dict(required=False, type='str'),
|
|
|
|
directory_mode = dict(required=False)
|
|
|
|
directory_mode = dict(required=False),
|
|
|
|
|
|
|
|
remote_src = dict(required=False, type='bool'),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
add_file_common_args=True,
|
|
|
|
add_file_common_args=True,
|
|
|
|
supports_check_mode=True,
|
|
|
|
supports_check_mode=True,
|
|
|
@ -228,6 +229,7 @@ def main():
|
|
|
|
validate = module.params.get('validate',None)
|
|
|
|
validate = module.params.get('validate',None)
|
|
|
|
follow = module.params['follow']
|
|
|
|
follow = module.params['follow']
|
|
|
|
mode = module.params['mode']
|
|
|
|
mode = module.params['mode']
|
|
|
|
|
|
|
|
remote_src = module.params['remote_src']
|
|
|
|
|
|
|
|
|
|
|
|
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))
|
|
|
@ -307,6 +309,11 @@ def main():
|
|
|
|
(rc,out,err) = module.run_command(validate % src)
|
|
|
|
(rc,out,err) = module.run_command(validate % src)
|
|
|
|
if rc != 0:
|
|
|
|
if rc != 0:
|
|
|
|
module.fail_json(msg="failed to validate: rc:%s error:%s" % (rc,err))
|
|
|
|
module.fail_json(msg="failed to validate: rc:%s error:%s" % (rc,err))
|
|
|
|
|
|
|
|
if remote_src:
|
|
|
|
|
|
|
|
tmpdest = tempfile.mkstemp(dir=os.basedir(dest))
|
|
|
|
|
|
|
|
shutil.copy2(src, tmpdest)
|
|
|
|
|
|
|
|
module.atomic_move(tmpdest, dest)
|
|
|
|
|
|
|
|
else:
|
|
|
|
module.atomic_move(src, dest)
|
|
|
|
module.atomic_move(src, dest)
|
|
|
|
except IOError:
|
|
|
|
except IOError:
|
|
|
|
module.fail_json(msg="failed to copy: %s to %s" % (src, dest))
|
|
|
|
module.fail_json(msg="failed to copy: %s to %s" % (src, dest))
|
|
|
|