Hello All, I am trying to update a configuration file where there are existing lines (rules) with special characters (:*[]/\. etc.). In normal scenario, i can always manually escape all the characters but in this particular case, i have got pre-populated values in two variables: *var1 *contains the text to replace and *var2 *contains the new text which needs to be updated instead of value in var1.
For Example. The following is one sample config file where i want to replace [monitor://D:\Logs\Org.SNP.Publisher\*] *to *[monitor: //D:\new\path\dir\*] ------------ index = idx_dom_<AIRID>_<APP_NAME> [monitor://D:\logs\inetpub\logs\LogFiles\W3SVC2\*.log] sourcetype = /stg/4552/api/iis_logs disabled = false [monitor://D:\Logs\Org.SNP.Publisher\*] sourcetype = /stg/4552/app/Org.SNP.Publisher disabled = false and my playbook is getting the variables during run time (using awx surveys). --- - 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? *Regards,* *Ankit* -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/3f8cbba3-a200-4fb9-b5fd-fc0e360e9432%40googlegroups.com.