Improve documentation for replace module (#82756)

pull/82757/head
Remi Rampin 3 months ago committed by GitHub
parent 03246dc0ae
commit ca2de9e2a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -74,6 +74,7 @@ options:
- Uses Python regular expressions; see
U(https://docs.python.org/3/library/re.html).
- Uses DOTALL, which means the V(.) special character I(can match newlines).
- Does not use MULTILINE, so V(^) and V($) will only match the beginning and end of the file.
type: str
version_added: "2.4"
before:
@ -83,6 +84,7 @@ options:
- Uses Python regular expressions; see
U(https://docs.python.org/3/library/re.html).
- Uses DOTALL, which means the V(.) special character I(can match newlines).
- Does not use MULTILINE, so V(^) and V($) will only match the beginning and end of the file.
type: str
version_added: "2.4"
backup:
@ -124,7 +126,7 @@ EXAMPLES = r'''
regexp: '^(.+)$'
replace: '# \1'
- name: Replace before the expression till the begin of the file (requires Ansible >= 2.4)
- name: Replace before the expression from the beginning of the file (requires Ansible >= 2.4)
ansible.builtin.replace:
path: /etc/apache2/sites-available/default.conf
before: '# live site config'
@ -133,11 +135,12 @@ EXAMPLES = r'''
# Prior to Ansible 2.7.10, using before and after in combination did the opposite of what was intended.
# see https://github.com/ansible/ansible/issues/31354 for details.
# Note (?m) which turns on MULTILINE mode so ^ matches any line's beginning
- name: Replace between the expressions (requires Ansible >= 2.4)
ansible.builtin.replace:
path: /etc/hosts
after: '<VirtualHost [*]>'
before: '</VirtualHost>'
after: '(?m)^<VirtualHost [*]>'
before: '(?m)^</VirtualHost>'
regexp: '^(.+)$'
replace: '# \1'

Loading…
Cancel
Save