Implement --diff for the copy module.
This commit is contained in:
parent
4d4dbb370f
commit
46b78399d3
1 changed files with 15 additions and 1 deletions
16
file
16
file
|
@ -140,7 +140,8 @@ def main():
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
state = dict(choices=['file','directory','link','absent'], default='file'),
|
state = dict(choices=['file','directory','link','absent'], default='file'),
|
||||||
path = dict(aliases=['dest', 'name'], required=True),
|
path = dict(aliases=['dest', 'name'], required=True),
|
||||||
recurse = dict(default='no', choices=BOOLEANS)
|
recurse = dict(default='no', choices=BOOLEANS),
|
||||||
|
diff_peek = dict(default=None)
|
||||||
),
|
),
|
||||||
add_file_common_args=True,
|
add_file_common_args=True,
|
||||||
supports_check_mode=True
|
supports_check_mode=True
|
||||||
|
@ -150,6 +151,19 @@ def main():
|
||||||
state = params['state']
|
state = params['state']
|
||||||
params['path'] = path = os.path.expanduser(params['path'])
|
params['path'] = path = os.path.expanduser(params['path'])
|
||||||
|
|
||||||
|
# short-circuit for diff_peek
|
||||||
|
if params.get('diff_peek', None) is not None:
|
||||||
|
appears_binary = False
|
||||||
|
try:
|
||||||
|
f = open(path)
|
||||||
|
b = f.read(8192)
|
||||||
|
f.close()
|
||||||
|
if b.find("\x00") != -1:
|
||||||
|
appears_binary = True
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
module.exit_json(path=path, changed=False, appears_binary=appears_binary)
|
||||||
|
|
||||||
# source is both the source of a symlink or an informational passing of the src for a template module
|
# source is both the source of a symlink or an informational passing of the src for a template module
|
||||||
# or copy module, even if this module never uses it, it is needed to key off some things
|
# or copy module, even if this module never uses it, it is needed to key off some things
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue