Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increasing tomcat memory using puppet

I'm trying to install/setup tomcat7 using puppet.

I haven't found a module that lets me set up the max heap memory.

So I've been trying to inject the line "CATALINA_OPTS=-Xmx2048m" into the catalina.sh file.

I'm not really sure what the best way to do this in though. I looked into the file_line resource, but I don't know how to make it insert in the middle of the catalina.sh file.

Any suggestions welcomed.

Update: Some people suggested templates, but I don't need to parameterize anything. I want to be able to take whatever catalina.sh that the tomcat install produces and inject a line into it. If I used templates, or replaced the file with a modified copy, then the next tomcat I install may have a different catalina.sh, and this would overwrite the new file format.

Maybe what I need is a way to insert a line AFTER another line. I believe I can insert "CATALINA_OPTS=" right after the #!/bin/bash line. Is this possible?

like image 533
kane Avatar asked Jan 11 '23 19:01

kane


2 Answers

Use file_line's matches parameter, so existing CATALINA_OPTS line in original file will be replaced with the new line.

  file_line { "Tomcat Memory":
    line => "CATALINA_OPTS=-Xmx2048m",
    path=> "/route/to/catalina.sh",
    notify =>Service['tomcat'],
    match => "CATALINA_OPTS=.*",
  }
like image 184
Raul Andres Avatar answered Jan 25 '23 15:01

Raul Andres


I run to the same issue. I'm installing tomcat using puppetlabs/tomcat, but there is not a word about the way to manage the memory size.

However there is a way to manage the setenv.sh which let you set the JAVA

Here is an example that should do what you want:

  include  'java'
  class { 'tomcat':
    install_from_source => true,
  }

  tomcat::instance{ 'default':
    source_url    => 'http://mirror.nexcess.net/apache/tomcat/tomcat-8/v8.0.23/bin/apache-tomcat-8.0.23.tar.gz',
  } ->
  tomcat::setenv::entry {'JAVA_OPTS':
    value => "-Xmx256m",
  }
like image 21
Piotr Czapla Avatar answered Jan 25 '23 16:01

Piotr Czapla