tried to replace specific path in .conf file with another file using ansible but not getting modified as wanted.
below is my .conf file content
<!-- Server Clusters --><ServerCluster CloneSeparatorChange="false" GetDWLMTable="false" IgnoreAffinityRequests="true" LoadBalance="Round Robin" Name="Shared_3_Cluster_0" PostBufferSize="0" PostSizeLimit="-1" RemoveSpecialHeaders="true" RetryInterval="60" ServerIOTimeoutRetry="-1">
<Server CloneID="0577049b-9886-4e73-8717-1663b85204bb" ConnectTimeout="5" ExtendedHandshake="false" LoadBalanceWeight="20" MaxConnections="-1" Name="default_node_clm_2" ServerIOTimeout="900" WaitForContinue="false">
<Transport Hostname="MYSERVER1DNS" Port="9080" Protocol="http"/>
<Transport Hostname="MYSERVER1DNS" Port="9443" Protocol="https">
<Property Name="keyring" Value="/opt/IBM/WebSphere/Plugins/config/webserver1/plugin-key.kdb"/>
<Property Name="stashfile" Value="/opt/IBM/WebSphere/Plugins/config/webserver1/plugin-key.sth"/>
</Transport>
</Server>
<Server CloneID="a89c5825-ed68-4e64-88a3-af800e1c98aa" ConnectTimeout="5" ExtendedHandshake="false" LoadBalanceWeight="20" MaxConnections="-1" Name="default_node_clm_1" ServerIOTimeout="900" WaitForContinue="false">
<Transport Hostname="MYSERVER2DNS" Port="9080" Protocol="http"/>
<Transport Hostname="MYSERVER2DNS" Port="9443" Protocol="https">
<Property Name="keyring" Value="/opt/IBM/WebSphere/Plugins/config/webserver1/plugin-key.kdb"/>
<Property Name="stashfile" Value="/opt/IBM/WebSphere/Plugins/config/webserver1/plugin-key.sth"/>
</Transport>
</Server>
<Server CloneID="98e33a6f-822c-40b5-90a6-71b6747ed1bd" ConnectTimeout="5" ExtendedHandshake="false" LoadBalanceWeight="20" MaxConnections="-1" Name="default_node_clm_0" ServerIOTimeout="900" WaitForContinue="false">
<Transport Hostname="MYSERVER3DNS" Port="9080" Protocol="http"/>
<Transport Hostname="MYSERVER3DNS" Port="9443" Protocol="https">
<Property Name="keyring" Value="/opt/IBM/WebSphere/Plugins/config/webserver1/plugin-key.kdb"/>
<Property Name="stashfile" Value="/opt/IBM/WebSphere/Plugins/config/webserver1/plugin-key.sth"/>
Here I was trying to modify the repeating strings
From
<Property Name="keyring" Value="/opt/IBM/WebSphere/Plugins/config/webserver1/plugin-key.kdb"/>
<Property Name="stashfile" Value="/opt/IBM/WebSphere/Plugins/config/webserver1/plugin-key.sth"/>
To
<Property Name="keyring" Value="/opt/HTTPServer/key.kdb"/>
<Property Name="stashfile" Value="/opt/HTTPServer/key.sth"/>
Tried with my below play , its changing the value, but the spaces are not coming exactly as it neeed ( the modified line is just staring from the begining) and which is making application down
- name: change ihs plugin
hosts: IHS
tasks:
- name: Ansible replace string example
replace:
path: /opt/IBM/WebSphere/Plugins/config/WebServer1/Plugin-cfg.xml
regexp: '^(.*<Property Name="keyring" Value="/opt/IBM/WebSphere/Plugins/config/webserver1/plugin-key.kdb"/>.*)'
replace: '<Property Name="keyring" Value="/opt/IBM/HTTPServer/key.kdb"/>'
- name: Ansible replace string example
replace:
path: /opt/IBM/WebSphere/Plugins/config/WebServer1/Plugin-cfg.xml
regexp: '^(.*<Property Name="stashfile" Value="/opt/IBM/WebSphere/Plugins/config/webserver1/plugin-key.sth"/>.*)'
replace: '<Property Name="stashfile" Value="/opt/IBM/HTTPServer/key.sth"/>'
Expected output
<!-- Server Clusters --><ServerCluster CloneSeparatorChange="false" GetDWLMTable="false" IgnoreAffinityRequests="true" LoadBalance="Round Robin" Name="Shared_3_Cluster_0" PostBufferSize="0" PostSizeLimit="-1" RemoveSpecialHeaders="true" RetryInterval="60" ServerIOTimeoutRetry="-1">
<Server CloneID="0577049b-9886-4e73-8717-1663b85204bb" ConnectTimeout="5" ExtendedHandshake="false" LoadBalanceWeight="20" MaxConnections="-1" Name="default_node_clm_2" ServerIOTimeout="900" WaitForContinue="false">
<Transport Hostname="MYSERVERDNS" Port="9080" Protocol="http"/>
<Transport Hostname="MYSERVERDNS" Port="9443" Protocol="https">
<Property Name="keyring" Value="/opt/IBM/HTTPServer/key.kdb"/>
<Property Name="stashfile" Value="/opt/IBM/HTTPServer/key.sth"/>
</Transport>
</Server>
<Server CloneID="a89c5825-ed68-4e64-88a3-af800e1c98aa" ConnectTimeout="5" ExtendedHandshake="false" LoadBalanceWeight="20" MaxConnections="-1" Name="default_node_clm_1" ServerIOTimeout="900" WaitForContinue="false">
<Transport Hostname="MYSERVER2DNS" Port="9080" Protocol="http"/>
<Transport Hostname="MYSERVER2DNS" Port="9443" Protocol="https">
<Property Name="keyring" Value="/opt/IBM/HTTPServer/key.kdb"/>
<Property Name="stashfile" Value="/opt/IBM/HTTPServer/key.sth"/>
</Transport>
</Server>
<Server CloneID="98e33a6f-822c-40b5-90a6-71b6747ed1bd" ConnectTimeout="5" ExtendedHandshake="false" LoadBalanceWeight="20" MaxConnections="-1" Name="default_node_clm_0" ServerIOTimeout="900" WaitForContinue="false">
<Transport Hostname="MYSERVER3DNS" Port="9080" Protocol="http"/>
<Transport Hostname="MYSERVER3DNS" Port="9443" Protocol="https">
<Property Name="keyring" Value="/opt/IBM/HTTPServer/key.kdb"/>
<Property Name="stashfile" Value="/opt/IBM/HTTPServer/key.sth"/>
</Transport>
</Server>
<PrimaryServers>
Comments
Post a Comment