diff --git a/CHANGELOG.md b/CHANGELOG.md index 626ece0ab7d..c64eb47931a 100644 --- a/CHANGELOG.md +++ b/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) diff --git a/docsite/rst/playbooks_filters.rst b/docsite/rst/playbooks_filters.rst index 70cd908d9b1..b5bff0afe94 100644 --- a/docsite/rst/playbooks_filters.rst +++ b/docsite/rst/playbooks_filters.rst @@ -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::