how to edit tomcat xml using xml module in ansible..

Hi ,

I am trying to use the xml module to edit the tomcat’s server.xml to add few lines .but it not getting idea as what to provide the xpath. In the below ,want to add few line( like acceptCount=“somecontent”, **maxConnections=“somecontent”,**connectionTimeout=“some content” ) under the .Currently using the blockinfile but thats not the right way of editing it. Could you please help in knowing how to use xml module to implement.

<``Service name``=``"Catalina">
**##to add few lines here using xml module###**

````<Connector` `port="8080"` `protocol="HTTP/1.1"

*<br> | *```connectionTimeout=``“20000”` |

  • | - |

*<br> | *```redirectPort=``“8443” />` |

  • | - |

*<br> | *`<Connector port=“8009” protocol=“AJP/1.3” redirectPort=“8443” /` |

  • | - |

<``Engine name``=``"Catalina" defaultHost``=``"localhost"``>

``**##to add few more lines here using xml module###** | |

  • | - |

<br> | `<Realm className=“org.apache.catalina.realm.LockOutRealm”``>` |

  • | - |

<br> | `<Realm className=“org.apache.catalina.realm.UserDatabaseRealm”` |

  • | - |

<br> | `resourceName="UserDatabase"/>` |

  • | - |

<br> | `</Realm``>` |

  • | - |

I am using blockinfile as below :

  • blockinfile:
    path: /etc/tomcat/server.xml
    insertafter: ‘’
    marker: “# {mark} ANSIBLE MANAGED BLOCK insertion 1”
    content: |
    acceptCount=“somecontent”

maxConnections=“somecontent”
connectionTimeout=“some content”

Thank you.

I would recommend using template module instead - maybe you have lots of different tomcat configurations to support, or tomcat versions, so it might not work for you, but unless you are changing server.xml a great deal it might be quicker to just use template and move on to solving other problems.

Hope this helps

Jon

Thank you for the reply Jon, thats a better suggestion but i wanted to know how to editing couple of lines using xml modules…

also the examples on how to use xml module is very vague if we search in google and in anisble docs…i would request if anyone can give some insight into it.