Hi Visar As for the IHS plugin file modification try using the Ansible's xml module: https://docs.ansible.com/ansible/2.4/xml_module.html As for the mail, you are writing, that your playbook fails, but you don't send us any output. Run your playbook with -vvv and see what's wrong. Also, note, that ansible tasks manipulating files usually make backups automatically on every modification. Check the 'backup' parameter of the xml module.
Piotr niedz., 2 gru 2018 o 08:37 visar <vivuu1...@gmail.com> napisaĆ(a): > Hello Experts, > > Any suggestion here please... > > On Friday, November 30, 2018 at 4:15:06 PM UTC+5:30, visar wrote: >> >> 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 ansible-project+unsubscr...@googlegroups.com. > To post to this group, send email to ansible-project@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/6b254fa8-3f81-4c56-b4c0-d8d30d4a1122%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/6b254fa8-3f81-4c56-b4c0-d8d30d4a1122%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CACHJvyM7D17gftv_%2BkaULkcS474QDNKq_YUrgUipVe12GC2uAg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.