Skip to content
Snippets Groups Projects
Commit 1e3d18cb authored by Thomas Bellman's avatar Thomas Bellman
Browse files

Add definition for managing global module configuration.

This adds the definition apache::module::globalconfig for managing
global module configuration.  It is basically a thin wrapper around
apache::include_file, giving a nicer API for specifying global
configuration of Apache modules.
parent 37d03646
No related branches found
No related tags found
No related merge requests found
...@@ -165,3 +165,59 @@ define apache::include_file($content=undef, $source=undef, $ensure='present') ...@@ -165,3 +165,59 @@ define apache::include_file($content=undef, $source=undef, $ensure='present')
} }
} }
} }
/*
* Define global configuration for an Apache module.
*
* To be used by classes installing and configuring Apache modules.
* Such classes should use this definition to set some reasonable
* default configuration. Users wanting a different configuration
* should inherit that class and override this resource.
*
* Configuration will be written to an "include file" in $apache::configdir,
* and an Include directive will be added to the main Apache
* httpd.conf file loading that specific file. (Therefore, there
* must not be any wildcard Include directive in httpd.conf; the
* apache::base class ensures this.)
*
* Parameters:
*
* - name:
* The name of the config file in /etc/httpd/conf.d that will be
* written. The suffix ".conf" will be automatically added.
*
* - loadmodule:
* Parameters to the LoadModule directive.
*
* - directives:
* List of directive lines. Users should usually use the 'defaultoptions'
* and 'options' parameters, but since some directives can occur multiple
* times, a way of specifying those is needed, thus this parameter.
*
* - defaultoptions, options:
* Hashes of directive names and parameters to them. These two hashes
* will be joined, and settings in the latter will override settings in
* the former. The intent is that a class for an Apache module will set
* 'defaultoptions' to some reasonable defaults, and users wanting to
* add to or override those will set 'options'.
* Setting the value of a specific option to false will exclude it
* from the config file.
*
* - ensure:
* One of 'present' or 'absent'. Setting to 'absent' will remove the
* module configuration file, and remove the Include directive for it
* from the main Apache httpd.conf file.
*/
define apache::module::globalconfig(
$loadmodule, $directives=[], $defaultoptions, $options={},
$ensure='present')
{
apache::include_file {
$name:
ensure => $ensure,
content => template('apache/module.conf.erb');
}
}
LoadModule <%= @loadmodule %>
<% @directives.each do |line| -%>
<%= line %>
<% end -%>
<% @defaultoptions.merge(@options).sort.each do |optname,params| -%>
<% if params != false -%>
<%= (optname + ' ' + params).rstrip() %>
<% end -%>
<% end -%>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment