Hello All,
Can anyone please suggest how can i get this done.
Thanks in advance.
On Wednesday, 23 October 2019 12:05:35 UTC+5:30, Ankit wrote:
>
> 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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/37a9dc6b-4039-4370-ac04-97f1a30da1bc%40googlegroups.com.