Add backup to assemble
This commit is contained in:
parent
25b34ddb60
commit
aa7feb076e
1 changed files with 4 additions and 0 deletions
4
assemble
4
assemble
|
@ -50,6 +50,7 @@ def main():
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
src = dict(required=True),
|
src = dict(required=True),
|
||||||
dest = dict(required=True),
|
dest = dict(required=True),
|
||||||
|
backup=dict(default=False, choices=BOOLEANS),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -58,6 +59,7 @@ def main():
|
||||||
destmd5 = None
|
destmd5 = None
|
||||||
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.boolean(module.params.get('backup', False))
|
||||||
|
|
||||||
if not os.path.exists(src):
|
if not os.path.exists(src):
|
||||||
module.fail_json(msg="Source (%s) does not exist" % src)
|
module.fail_json(msg="Source (%s) does not exist" % src)
|
||||||
|
@ -72,6 +74,8 @@ def main():
|
||||||
destmd5 = module.md5(dest)
|
destmd5 = module.md5(dest)
|
||||||
|
|
||||||
if pathmd5 != destmd5:
|
if pathmd5 != destmd5:
|
||||||
|
if backup and destmd5 is not None:
|
||||||
|
module.backuplocal(dest)
|
||||||
shutil.copy(path, dest)
|
shutil.copy(path, dest)
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue