0

I'm using chef to manage a tomcat application. In this application, there is a web.xml file that I need to make 1 minor change to. Up until now, I've been using a template for this file, however the authors of the application like to change the contents of this file with each update, which means I have to change my template on every update. In my mind that defeats the point.

The only thing I care about in the file is this bit near the end:

<!--
  <session-config>
    <session-timeout>30</session-timeout>
  </session-config>
-->

I just need to strip out the comment tags, and insert my own value into the session-timeout tags. I want to keep the rest of the file however the vendor supplies it, maintaining any changes that come with newer versions of the software.

What is the best way to accomplish this?

  • Possible duplicate of [How can I change a file with Chef?](http://stackoverflow.com/questions/14848110/how-can-i-change-a-file-with-chef) – StephenKing Mar 23 '17 at 05:36

2 Answers2

1

Short version, use the line cookbook.

Long version, this is very difficult to do and optimally you would get your app to support some kind of config include system so you can manage the fragment as a template resource.

coderanger
  • 52,400
  • 4
  • 52
  • 75
0

Get the content of the file from the official cookbook add your content programmatically , you could also try xml parser if the config is in xml and then render a template runtime and then deploy that template.

rusia.inc
  • 891
  • 7
  • 10