ansible.builtin.search test fails with "bad escape" error if pattern contains backslash anywhere #1086
Labels
bug
Something isn't working
new_contributor
This PR is the first contribution by a new community member.
Summary
consider the following task that I am trying to run in ansible:
I am trying to loop through a list and only want the task to run if an item in the list contains the string I have specified. While I have used the search test many, many times before, I have never used it with a pattern that contained a backslash, and when I attempt to run the above task in ansible, I get the below error:
I even tried doubling up the backslashes in the pattern to see if that would fix the issue:
but I received an almost identical error:
when I change the conditional so that the pattern will match a string in the list exactly and use "==", the task work perfectly:
So I am lead to conclude that this is an issue with either the ansible.builtin search test and backslashes or tests in general and backslashes.
Issue Type
Bug Report
Component Name
search
Ansible Version
Configuration
OS / Environment
Ubuntu 22.04.3 LTS
Steps to Reproduce
or
Try running either of the above tasks in a playbook
Expected Results
I would expect the search test to complete without error
Actual Results
Code of Conduct
The text was updated successfully, but these errors were encountered: