Merge pull request #54537 from garethgreenaway/2019_2_1_port_51856

[master] Porting #51856 to master
This commit is contained in:
Daniel Wozniak 2019-10-11 09:26:45 -07:00 committed by GitHub
commit 5e9c2c1935
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4501,6 +4501,22 @@ def replace(name,
When using YAML multiline string syntax in ``pattern:``, make sure to
also use that syntax in the ``repl:`` part, or you might loose line
feeds.
When regex capture groups are used in ``pattern:``, their captured value is
available for reuse in the ``repl:`` part as a backreference (ex. ``\1``).
.. code-block:: yaml
add_login_group_to_winbind_ssh_access_list:
file.replace:
- name: '/etc/security/pam_winbind.conf'
- pattern: '^(require_membership_of = )(.*)$'
- repl: '\1\2,append-new-group-to-line'
.. note::
The ``file.replace`` state uses Python's ``re`` module.
For more advanced options, see https://docs.python.org/2/library/re.html
'''
name = os.path.expanduser(name)