mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Note that backslash escaping has changed in some places
This commit is contained in:
parent
a7da25d48b
commit
8cac397841
2 changed files with 16 additions and 3 deletions
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -25,6 +25,19 @@ Major Changes:
|
|||
They will retain the value of `None`. To go back to the old behaviour, you can override
|
||||
the `null_representation` setting to an empty string in your config file or by setting the
|
||||
`ANSIBLE_NULL_REPRESENTATION` environment variable.
|
||||
* backslashes used when specifying parameters in jinja2 expressions in YAML
|
||||
dicts sometimes needed to be escaped twice. This has been fixed so that
|
||||
escaping once works. Here's an example of how playbooks need to be modified::
|
||||
|
||||
# Syntax in 1.9.x
|
||||
- debug:
|
||||
msg: "{{ 'test1_junk 1\\\\3' | regex_replace('(.*)_junk (.*)', '\\\\1 \\\\2') }}"
|
||||
# Syntax in 2.0.x
|
||||
- debug:
|
||||
msg: "{{ 'test1_junk 1\\3' | regex_replace('(.*)_junk (.*)', '\\1 \\2') }}"
|
||||
|
||||
# Output:
|
||||
"msg": "test1 1\\3"
|
||||
|
||||
Deprecated Modules (new ones in parens):
|
||||
* ec2_ami_search (ec2_ami_find)
|
||||
|
|
|
@ -448,13 +448,13 @@ To match strings against a regex, use the "match" or "search" filter::
|
|||
To replace text in a string with regex, use the "regex_replace" filter::
|
||||
|
||||
# convert "ansible" to "able"
|
||||
{{ 'ansible' | regex_replace('^a.*i(.*)$', 'a\\1') }}
|
||||
{{ 'ansible' | regex_replace('^a.*i(.*)$', 'a\\1') }}
|
||||
|
||||
# convert "foobar" to "bar"
|
||||
{{ 'foobar' | regex_replace('^f.*o(.*)$', '\\1') }}
|
||||
|
||||
.. note:: If "regex_replace" filter is used with variables inside YAML arguments (as opposed to simpler 'key=value' arguments),
|
||||
then you need to escape backreferences (e.g. ``\\1``) with 4 backslashes (``\\\\``) instead of 2 (``\\``).
|
||||
.. note:: Prior to ansible 2.0, if "regex_replace" filter was used with variables inside YAML arguments (as opposed to simpler 'key=value' arguments),
|
||||
then you needed to escape backreferences (e.g. ``\\1``) with 4 backslashes (``\\\\``) instead of 2 (``\\``).
|
||||
|
||||
To escape special characters within a regex, use the "regex_escape" filter::
|
||||
|
||||
|
|
Loading…
Reference in a new issue