|
|
@ -74,6 +74,7 @@ options:
|
|
|
|
- Uses Python regular expressions; see
|
|
|
|
- Uses Python regular expressions; see
|
|
|
|
U(https://docs.python.org/3/library/re.html).
|
|
|
|
U(https://docs.python.org/3/library/re.html).
|
|
|
|
- Uses DOTALL, which means the V(.) special character I(can match newlines).
|
|
|
|
- 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
|
|
|
|
type: str
|
|
|
|
version_added: "2.4"
|
|
|
|
version_added: "2.4"
|
|
|
|
before:
|
|
|
|
before:
|
|
|
@ -83,6 +84,7 @@ options:
|
|
|
|
- Uses Python regular expressions; see
|
|
|
|
- Uses Python regular expressions; see
|
|
|
|
U(https://docs.python.org/3/library/re.html).
|
|
|
|
U(https://docs.python.org/3/library/re.html).
|
|
|
|
- Uses DOTALL, which means the V(.) special character I(can match newlines).
|
|
|
|
- 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
|
|
|
|
type: str
|
|
|
|
version_added: "2.4"
|
|
|
|
version_added: "2.4"
|
|
|
|
backup:
|
|
|
|
backup:
|
|
|
@ -124,7 +126,7 @@ EXAMPLES = r'''
|
|
|
|
regexp: '^(.+)$'
|
|
|
|
regexp: '^(.+)$'
|
|
|
|
replace: '# \1'
|
|
|
|
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:
|
|
|
|
ansible.builtin.replace:
|
|
|
|
path: /etc/apache2/sites-available/default.conf
|
|
|
|
path: /etc/apache2/sites-available/default.conf
|
|
|
|
before: '# live site config'
|
|
|
|
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.
|
|
|
|
# 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.
|
|
|
|
# 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)
|
|
|
|
- name: Replace between the expressions (requires Ansible >= 2.4)
|
|
|
|
ansible.builtin.replace:
|
|
|
|
ansible.builtin.replace:
|
|
|
|
path: /etc/hosts
|
|
|
|
path: /etc/hosts
|
|
|
|
after: '<VirtualHost [*]>'
|
|
|
|
after: '(?m)^<VirtualHost [*]>'
|
|
|
|
before: '</VirtualHost>'
|
|
|
|
before: '(?m)^</VirtualHost>'
|
|
|
|
regexp: '^(.+)$'
|
|
|
|
regexp: '^(.+)$'
|
|
|
|
replace: '# \1'
|
|
|
|
replace: '# \1'
|
|
|
|
|
|
|
|
|
|
|
|