Hi Search and replacing of strings in XML tends to be very fragile, as you experience. Adding win_shell powershell and pipes will only make that worse.
If your desired changes allow, you should use the dedicated XML module: https://docs.ansible.com/ansible/latest/modules/xml_module.html On Fri, 31 Jan 2020 at 14:32, Sai Prasha <[email protected]> wrote: > > I am trying to Replace a String in an xml file . but using win_lineinfile > module only the last occurence of it is replaced > how can i replace a String in all occurences . > One Solution i found is tro run from powershell > (Get-Content C:\Program Files\dd\config.xml).replace('ToReplace','replaced') > | Set-Content C:\Program Files\dd\config.xml > > But when i try to use the same powershell from playbook > win_shell: (Get-Content C:\Program > Files\dd\config.xml).replace('ToReplace','sss') | Set-Content C:\Program > Files\dd\config.xml > > Its executing but chnages are not happening ., Any solutions please > > -- > 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/97458bf6-691e-4407-ad0b-c7b962e79230%40googlegroups.com. -- Dick Visser Trust & Identity Service Operations Manager GÉANT -- 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/CAL8fbwPj9dv7yA7hqGFo9L_Ogxqh739jag-9Au03M2NuVbnZZw%40mail.gmail.com.
