How to apply prefork configuration for Apache in Puppet?

I'm using the puppetlabs apache module to manage my apache configuration.

I got everything configured, except the Server settings for mod_prefork. There is a template for prefork and it gets variable when initializing the class somehow, but I'm not exactly sure how.

I don't want to change the server settings in the template by hand, because I run apache on multiple hosts and don't want to change the value in the template itself.

Do you have any idea how to do that? The link to the module is here.

I had a read through the docs, but I'm unable to figure out how to do it.


Solution 1:

You can set mpm_module to false, to explicitly declare the prefork-class with custom parameters afterwards.

class {
  'apache':
    mpm_module      => false,
}
class {
  'apache::mod::prefork':
    startservers    => "5",
    minspareservers => "3",
    maxspareservers => "3",
    serverlimit     => "64",
    maxclients      => "64",
}

Solution 2:

The settings in prefork.conf are controlled by class parameters set on the apache::mod::prefork class. See manifests/mod/prefork.pp for these parameters and their defaults.

How you will set these depends on how you're actually declaring the apache class. Looks like it's actually a bit difficult if you're starting with class { 'apache': }, since it simply declares apache::mod::prefork with no way to pass parameters through. I'd recommend using Hiera for your node definitions, then setting up the params in your Hiera config, for example: apache::mod::prefork::maxclients: 256