On 23.10.2019 08:35, Ankit wrote:
> ---
> - hosts: all
> gather_facts: false
> vars:
> *var1:* '[monitor://D:\Logs\Org.SNP.Publisher\*]'
> *var2**:* '[monitor://D:\new\path\dir\*]'
> tasks:
> - name: test unsafe variable in the file
> replace:
> path: /home/anks/yaml/filewithcontent
> regexp: '{{ *var1 *| regex_escape() }}'
> replace: "{{ *var2 *}}"
> ...
>
> I have been trying different things like *unsafe!* , *regex_replace()* but
> it doesn't seem to work. Could anyone please suggest how can i achieve this?
Replace module is using Python re[1] module.
Your replace: contain escape sequences, if Python re recognize a escape
sequence it will replace it.
You have \n, \b and \d of these Python re do recognize \n at least, so you need
to be escaped it by putting an extra \ in it so it becomes \\n
[1] https://docs.python.org/2/library/re.html
--
Kai Stian Olstad
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/9dab55f4-2443-88a7-8fda-2c58131254e4%40olstad.com.