Merge pull request #14764 from bcoca/max_diff_config
made max diff size configurable
This commit is contained in:
commit
f565508d7f
3 changed files with 8 additions and 3 deletions
|
@ -198,6 +198,10 @@
|
|||
# is used. This value must be an integer from 0 to 9.
|
||||
#var_compression_level = 9
|
||||
|
||||
# This controls the cutoff point (in bytes) on --diff for files
|
||||
# set to 0 for unlimited (RAM may suffer!).
|
||||
#max_diff_size = 1048576
|
||||
|
||||
[privilege_escalation]
|
||||
#become=True
|
||||
#become_method=sudo
|
||||
|
|
|
@ -239,6 +239,7 @@ RETRY_FILES_ENABLED = get_config(p, DEFAULTS, 'retry_files_enabled',
|
|||
RETRY_FILES_SAVE_PATH = get_config(p, DEFAULTS, 'retry_files_save_path', 'ANSIBLE_RETRY_FILES_SAVE_PATH', None, ispath=True)
|
||||
DEFAULT_NULL_REPRESENTATION = get_config(p, DEFAULTS, 'null_representation', 'ANSIBLE_NULL_REPRESENTATION', None, isnone=True)
|
||||
DISPLAY_ARGS_TO_STDOUT = get_config(p, DEFAULTS, 'display_args_to_stdout', 'ANSIBLE_DISPLAY_ARGS_TO_STDOUT', False, boolean=True)
|
||||
MAX_FILE_SIZE_FOR_DIFF = get_config(p, DEFAULTS, 'max_diff_size', 'ANSIBLE_MAX_DIFF_SIZE', 1024*1024, integer=True)
|
||||
|
||||
# CONNECTION RELATED
|
||||
ANSIBLE_SSH_ARGS = get_config(p, 'ssh_connection', 'ssh_args', 'ANSIBLE_SSH_ARGS', '-o ControlMaster=auto -o ControlPersist=60s')
|
||||
|
@ -298,6 +299,5 @@ DEFAULT_SUBSET = None
|
|||
DEFAULT_SU_PASS = None
|
||||
VAULT_VERSION_MIN = 1.0
|
||||
VAULT_VERSION_MAX = 1.0
|
||||
MAX_FILE_SIZE_FOR_DIFF = 1*1024*1024
|
||||
TREE_DIR = None
|
||||
LOCALHOST = frozenset(['127.0.0.1', 'localhost', '::1'])
|
||||
|
|
|
@ -615,7 +615,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
|||
diff['before'] = ''
|
||||
elif peek_result['appears_binary']:
|
||||
diff['dst_binary'] = 1
|
||||
elif peek_result['size'] > C.MAX_FILE_SIZE_FOR_DIFF:
|
||||
elif C.MAX_FILE_SIZE_FOR_DIFF > 0 and peek_result['size'] > C.MAX_FILE_SIZE_FOR_DIFF:
|
||||
diff['dst_larger'] = C.MAX_FILE_SIZE_FOR_DIFF
|
||||
else:
|
||||
display.debug("Slurping the file %s" % source)
|
||||
|
@ -631,7 +631,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
|||
|
||||
if source_file:
|
||||
st = os.stat(source)
|
||||
if st[stat.ST_SIZE] > C.MAX_FILE_SIZE_FOR_DIFF:
|
||||
if C.MAX_FILE_SIZE_FOR_DIFF > 0 and st[stat.ST_SIZE] > C.MAX_FILE_SIZE_FOR_DIFF:
|
||||
diff['src_larger'] = C.MAX_FILE_SIZE_FOR_DIFF
|
||||
else:
|
||||
display.debug("Reading local copy of the file %s" % source)
|
||||
|
@ -640,6 +640,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
|||
src_contents = src.read()
|
||||
except Exception as e:
|
||||
raise AnsibleError("Unexpected error while reading source (%s) for diff: %s " % (source, str(e)))
|
||||
|
||||
if "\x00" in src_contents:
|
||||
diff['src_binary'] = 1
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue