On 5/11/20 12:45 PM, Kumaresh kulal wrote:
> Hello,
> 
> I have got a task to configure the config file by removing the not required 
> text from the config file. 
> 
> Sample Config File:
> 
> <?xml version="1.0" encoding="utf-8" ?>
> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"; 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
>   <variable name="WorkflowLoggingDirectory" 
> value="${specialfolder:folder=LocalApplicationData}" />
>   <rules>
>     <logger name="WorkflowLogging" writeTo="WorkflowLogFiles" final="true" />
>     <logger minLevel="Info" writeTo="EventLog" />
>   </rules>
>   <targets>
>     <target type="File" name="WorkflowLogFiles" 
> fileName="${WorkflowLoggingDirectory}/${shortdate}_Execution.log"
> layout="${time} ${level} ${message}" concurrentWrites="true" encoding="utf-8" 
> writeBom="true" />
>     <target type="EventLog" name="EventLog" layout="${processname} 
> ${assembly-version} ${newline}${message}"
> log="Application" />
>   </targets>
> </nlog>
> 
> Text to Remove: ${time} ${level} 
> 
> So far I was able to do this using the below win_lineinfile playbook and it 
> works fine:
> 
> ---
> 
> - hosts: all
> 
>   tasks:
> 
>    - name: updating content in config file
> 
>      win_lineinfile:
> 
>        dest: C:\tmp\NLog.config
> 
>        regexp: '^(.*)time(.*)$'
> 
>        line: '    <target type="File" name="WorkflowLogFiles"
> fileName="${WorkflowLoggingDirectory}/${shortdate}_Execution.log" 
> layout="${message}" concurrentWrites="true"
> encoding="utf-8" writeBom="true" />'
> 
>        backrefs: yes
> 
> 
> I would like to know if there is a better way to handle this instead of 
> re-writing the whole line, can I only
> replace/delete the portion of the text?
> 

Lineinfile doesn't make sense for XML files, use (win_)xml module.

Regards
         Racke

> 
> 
> Thank You :-)
> 
> 
> Kumar
> 
> -- 
> 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] 
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/ea6a7f82-5896-4d02-a6a3-5401f0821139%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/ea6a7f82-5896-4d02-a6a3-5401f0821139%40googlegroups.com?utm_medium=email&utm_source=footer>.


-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

-- 
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/3f3b79ea-597d-87c0-1e6b-06f79ce837c9%40linuxia.de.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to