Note that backslash escaping has changed in some places

This commit is contained in:
Toshio Kuratomi 2015-08-31 14:14:41 -07:00
parent a7da25d48b
commit 8cac397841
2 changed files with 16 additions and 3 deletions

View file

@ -25,6 +25,19 @@ Major Changes:
They will retain the value of `None`. To go back to the old behaviour, you can override 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 the `null_representation` setting to an empty string in your config file or by setting the
`ANSIBLE_NULL_REPRESENTATION` environment variable. `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): Deprecated Modules (new ones in parens):
* ec2_ami_search (ec2_ami_find) * ec2_ami_search (ec2_ami_find)

View file

@ -453,8 +453,8 @@ To replace text in a string with regex, use the "regex_replace" filter::
# convert "foobar" to "bar" # convert "foobar" to "bar"
{{ 'foobar' | regex_replace('^f.*o(.*)$', '\\1') }} {{ '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), .. 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 need to escape backreferences (e.g. ``\\1``) with 4 backslashes (``\\\\``) instead of 2 (``\\``). 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:: To escape special characters within a regex, use the "regex_escape" filter::