diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-05 16:16:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-05 16:16:49 +0000 |
commit | 48e387c5c12026a567eb7b293a3a590241c0cecb (patch) | |
tree | 80f2573be2d7d534b8ac4d2a852fe43f7ac35324 /lib/ansible/modules/replace.py | |
parent | Releasing progress-linux version 2.16.6-1~progress7.99u1. (diff) | |
download | ansible-core-48e387c5c12026a567eb7b293a3a590241c0cecb.tar.xz ansible-core-48e387c5c12026a567eb7b293a3a590241c0cecb.zip |
Merging upstream version 2.17.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/ansible/modules/replace.py')
-rw-r--r-- | lib/ansible/modules/replace.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/ansible/modules/replace.py b/lib/ansible/modules/replace.py index fe4cdf0..2fee290 100644 --- a/lib/ansible/modules/replace.py +++ b/lib/ansible/modules/replace.py @@ -4,8 +4,7 @@ # Copyright: (c) 2017, Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -from __future__ import absolute_import, division, print_function -__metaclass__ = type +from __future__ import annotations DOCUMENTATION = r''' @@ -75,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: @@ -84,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: @@ -125,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' @@ -134,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' |