Increasing tomcat memory using puppets

I am trying to install / install tomcat7 using a puppet.

I did not find a module that allows me to configure the maximum heap memory.

So, I'm trying to enter the line "CATALINA_OPTS = -Xmx2048m" in the file catalina.sh.

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

Any suggestions are welcome.

Update: Some people suggested templates, but I do not need to parameterize anything. I want to be able to take any catalina.sh file that installs tomcat and enter a line into it. If I used templates or replaced the modified copy file, then the next tomcat that I install may have a different catalina.sh file, and this will overwrite the new file format.

Maybe I need a way to insert a row AFTER another row. I believe that I can insert "CATALINA_OPTS =" immediately after the line #! / Bin / bash. Is it possible?

+4
source share
5 answers

Use the file_line parameter matches, so the existing CATALINA_OPTS line in the source file will be replaced with a new line.

  file_line { "Tomcat Memory":
    line => "CATALINA_OPTS=-Xmx2048m",
    path=> "/route/to/catalina.sh",
    notify =>Service['tomcat'],
    match => "CATALINA_OPTS=.*",
  }
+3

. tomcat puppetlabs/tomcat, .

setenv.sh, JAVA

, , :

  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",
  }
+3

debian " ".

file_line { "Tomcat Memory":
  line => 'JAVA_OPTS="-Djava.awt.headless=true -Xmx1024m -XX:+UseConcMarkSweepGC"',
  path=> "/etc/default/tomcat8",
  notify => Service['tomcat8'],
  match => "^JAVA_OPTS=.*",
}
+2

. . :

class your_module_name ($memory='2048m') {
    file { '/where/is/catalina.sh':
        owner   => 'root',
        group   => 'root',
        mode    => '0755',
        content => template('your_module_name/catalina.sh.erb');
    }
}

catalina.sh modules/your_module_name/templates/catalina.sh.erb. :

CATALINA_OPTS=-Xmx<%=memory%>

.

+1

puppetlabs/tomcat, - tomcat::setenv::entry.

puppetlabs/tomcat, - setenv.sh, , catalina.sh . , , stdlib::file_line file.

, CATALINA_OPTS, tomcat, JAVA_OPTS, , tomcat , , , tomcat.

0

Source: https://habr.com/ru/post/1536713/


All Articles