mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #42621 from rallytime/merge-2017.7
[2017.7] Merge forward from 2016.11 to 2017.7
This commit is contained in:
commit
b7cd30d3ee
3 changed files with 34 additions and 5 deletions
|
@ -1901,6 +1901,7 @@ def replace(path,
|
|||
show_changes=True,
|
||||
ignore_if_missing=False,
|
||||
preserve_inode=True,
|
||||
backslash_literal=False,
|
||||
):
|
||||
'''
|
||||
.. versionadded:: 0.17.0
|
||||
|
@ -2001,6 +2002,14 @@ def replace(path,
|
|||
filename. Hard links will then share an inode with the backup, instead
|
||||
(if using ``backup`` to create a backup copy).
|
||||
|
||||
backslash_literal : False
|
||||
.. versionadded:: 2016.11.7
|
||||
|
||||
Interpret backslashes as literal backslashes for the repl and not
|
||||
escape characters. This will help when using append/prepend so that
|
||||
the backslashes are not interpreted for the repl on the second run of
|
||||
the state.
|
||||
|
||||
If an equal sign (``=``) appears in an argument to a Salt command it is
|
||||
interpreted as a keyword argument in the format ``key=val``. That
|
||||
processing can be bypassed in order to pass an equal sign through to the
|
||||
|
@ -2097,7 +2106,10 @@ def replace(path,
|
|||
if re.search(cpattern, r_data):
|
||||
return True # `with` block handles file closure
|
||||
else:
|
||||
result, nrepl = re.subn(cpattern, repl, r_data, count)
|
||||
result, nrepl = re.subn(cpattern,
|
||||
repl.replace('\\', '\\\\') if backslash_literal else repl,
|
||||
r_data,
|
||||
count)
|
||||
|
||||
# found anything? (even if no change)
|
||||
if nrepl > 0:
|
||||
|
@ -2151,8 +2163,10 @@ def replace(path,
|
|||
r_data = mmap.mmap(r_file.fileno(),
|
||||
0,
|
||||
access=mmap.ACCESS_READ)
|
||||
result, nrepl = re.subn(cpattern, repl,
|
||||
r_data, count)
|
||||
result, nrepl = re.subn(cpattern,
|
||||
repl.replace('\\', '\\\\') if backslash_literal else repl,
|
||||
r_data,
|
||||
count)
|
||||
try:
|
||||
w_file.write(salt.utils.to_str(result))
|
||||
except (OSError, IOError) as exc:
|
||||
|
|
|
@ -1034,6 +1034,11 @@ def refresh_db(**kwargs):
|
|||
|
||||
clean_cmd = [_yum(), '--quiet', 'clean', 'expire-cache']
|
||||
update_cmd = [_yum(), '--quiet', 'check-update']
|
||||
|
||||
if __grains__.get('os_family') == 'RedHat' and __grains__.get('osmajorrelease') == '7':
|
||||
# This feature is disable because it is not used by Salt and lasts a lot with using large repo like EPEL
|
||||
update_cmd.append('--setopt=autocheck_running_kernel=false')
|
||||
|
||||
for args in (repo_arg, exclude_arg, branch_arg):
|
||||
if args:
|
||||
clean_cmd.extend(args)
|
||||
|
|
|
@ -3787,7 +3787,8 @@ def replace(name,
|
|||
not_found_content=None,
|
||||
backup='.bak',
|
||||
show_changes=True,
|
||||
ignore_if_missing=False):
|
||||
ignore_if_missing=False,
|
||||
backslash_literal=False):
|
||||
r'''
|
||||
Maintain an edit in a file.
|
||||
|
||||
|
@ -3887,6 +3888,14 @@ def replace(name,
|
|||
state will display an error raised by the execution module. If set to
|
||||
``True``, the state will simply report no changes.
|
||||
|
||||
backslash_literal : False
|
||||
.. versionadded:: 2016.11.7
|
||||
|
||||
Interpret backslashes as literal backslashes for the repl and not
|
||||
escape characters. This will help when using append/prepend so that
|
||||
the backslashes are not interpreted for the repl on the second run of
|
||||
the state.
|
||||
|
||||
For complex regex patterns, it can be useful to avoid the need for complex
|
||||
quoting and escape sequences by making use of YAML's multiline string
|
||||
syntax.
|
||||
|
@ -3935,7 +3944,8 @@ def replace(name,
|
|||
backup=backup,
|
||||
dry_run=__opts__['test'],
|
||||
show_changes=show_changes,
|
||||
ignore_if_missing=ignore_if_missing)
|
||||
ignore_if_missing=ignore_if_missing,
|
||||
backslash_literal=backslash_literal)
|
||||
|
||||
if changes:
|
||||
ret['pchanges']['diff'] = changes
|
||||
|
|
Loading…
Add table
Reference in a new issue