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"/>'




Also want to take backup of the file before making these changes and need 
to send a mail once the changes happened as expected with an attachment 
with this file.

tried this, but failed.

- name: Send email
     mail:
        host: smtpserver.com
        port: 25
        username: mydomainID
        password: mypass
        subject: "Ansible test mail"
        attach: /opt/IBM/WebSphere/Plugins/config/WebServer1/Plugin-cfg.xml
        body: "Testing email"
        from: mymailid.com
        to:
          - mymailid.com
        charset: utf8
        secure: never


                  

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e5e1d00d-6fe4-45c9-8984-ff237660033f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to