Open sefalbe opened 1 year ago
I'm working with ansible to replace some values in web.config file, I'm using community.windows.win_xml module.
community.windows.win_xml
As you can see, I use EntityConn variable to set value:
vars: EntityConn: 'metadata=res://*/Northwind.csdl|res://*/Northwind.ssdl|res://*/Northwind.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\sqlexpress;Initial Catalog=Northwind;Integrated Security=True;MultipleActiveResultSets=True"'
The winxml module works but adds amp_ word when find " having as result &quot, and the final output:
"
&quot
<add name="EntityConn" connectionString="metadata=res://*/Northwind.csdl|res://*/Northwind.ssdl|res://*/Northwind.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\sqlexpress;Initial Catalog=Northwind;Integrated Security=True;MultipleActiveResultSets=True&quot" providerName="System.Data.EntityClient" />
ansible [core 2.13.7]
# /usr/lib/python3/dist-packages/ansible_collections Collection Version ----------------- ------- community.windows 1.10.0 # /home/user/.ansible/collections/ansible_collections Collection Version ----------------- ------- community.windows 1.11.1 # /usr/local/lib/python3.8/dist-packages/ansible_collections Collection Version ----------------- ------- community.windows 1.11.1
Linux 4ansible 5.4.0-132-generic #148-Ubuntu SMP Mon Oct 17 16:02:06 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
- name: Windows Feature hosts: Windows2016 vars: web_projects_path: "C:\\Path\\To\\Project" EntityConn: 'metadata=res://*/Northwind.csdl|res://*/Northwind.ssdl|res://*/Northwind.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\sqlexpress;Initial Catalog=Northwind;Integrated Security=True;MultipleActiveResultSets=True"' tasks: - name: Print values ansible.builtin.debug: msg: MMSPRP5Entities {{ EntityConn}} - name: Change webconfig value community.windows.win_xml: path: "{{ web_projects_path }}\\Web.config" xpath: //configuration/connectionStrings/add[@name="EntityConn"] attribute: connectionString fragment: '{{ EntityConn }}' type: attribute state: present
And here my Web.config file:
<configuration> <connectionStrings> <add name="EntityConn" connectionString="" providerName="System.Data.EntityClient"/> </connectionStrings> </configuration>
The expected result is the connection string without amp string
<configuration> <connectionStrings> <add name="EntityConn" connectionString="metadata=res://*/Northwind.csdl|res://*/Northwind.ssdl|res://*/Northwind.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\sqlexpress;Initial Catalog=Northwind;Integrated Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/> </connectionStrings> </configuration>
<configuration> <connectionStrings> <add name="EntityConn" connectionString="metadata=res://*/Northwind.csdl|res://*/Northwind.ssdl|res://*/Northwind.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\sqlexpress;Initial Catalog=Northwind;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" /> </connectionStrings> </configuration>
SUMMARY
I'm working with ansible to replace some values in web.config file, I'm using
community.windows.win_xml
module.As you can see, I use EntityConn variable to set value:
The winxml module works but adds amp_ word when find
"
having as result&quot
, and the final output:ISSUE TYPE
COMPONENT NAME
community.windows.win_xml
ANSIBLE VERSION
COLLECTION VERSION
OS / ENVIRONMENT
Linux 4ansible 5.4.0-132-generic #148-Ubuntu SMP Mon Oct 17 16:02:06 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
STEPS TO REPRODUCE
And here my Web.config file:
EXPECTED RESULTS
The expected result is the connection string without amp string
ACTUAL RESULTS