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

New ensure value 'noinclude' for apache::include_file.

This adds support to the apache::include_file definition for putting
a config file in place in the conf.d directory, but without adding an
Include directive in httpd.conf (it will in fact remove any Include
directive referencing the file from httpd.conf).  This is done by
specifying "ensure => 'noinclude'" to apache::include_file.

This is useful if you want to create a configuration fragment that is
supposed to be Include:d from within e.g. a <VirtualHost> section.  An
example is the NSC munin module which wants to do exactly that.
parent 7e02af4b
No related branches found
No related tags found
No related merge requests found
......@@ -10,13 +10,33 @@
* can be used e.g. for managing global configuration for Apache modules
* (LoadModule directives being a good candidate), and/or virtual host
* declarations.
*
* The parameters 'content' and 'source' have the same meaning as in
* the file type. Exactly one of them must be specified when the
* 'ensure' parameter is set to 'present' (the default).
*/
define apache::include_file($content=undef, $source=undef, $ensure='present')
define apache::include_file(
# The content/source of the include file. These two parameters
# have the same meaning as in the file type. Exactly one of them
# must be specified when the ensure parameter is set to 'present'.
#
$content = undef,
$source = undef,
# One of:
# - 'present'
# The include file should be installed and be included from
# the main httpd.conf file.
#
# - 'absent'
# The include file should be removed. Any Include directive
# mentioning it in the main httpd.conf file will be removed.
#
# - 'noinclude'
# Install the include file, but do not create any Include
# directive for it in the main httpd.conf file. This is
# useful if the file should be included from another include
# file.
#
$ensure = 'present'
)
{
include apache
......@@ -24,10 +44,7 @@ define apache::include_file($content=undef, $source=undef, $ensure='present')
case $ensure
{
'present': {
# Put the included file into place before the Include directive;
# in case the machine reboots in the middle, we do not want to
# needlessly hose up the Apache service.
'present', 'noinclude': {
file {
$includefile:
ensure => file,
......@@ -35,6 +52,25 @@ define apache::include_file($content=undef, $source=undef, $ensure='present')
content => $content, source => $source,
notify => Class[apache::service];
}
}
'absent': {
file {
$includefile:
ensure => absent, notify => Class[apache::service];
}
}
default: {
fail("Apache::Include_file[${title}]: ",
"Bad parameter ensure: ${ensure}")
}
}
case $ensure
{
'present': {
# Put the Include directive in place after the included file; if
# the machine reboots in the middle, we do not want to needlessly
# hose up the Apache service.
ensure_line {
"apache::include_file::include::${name}":
file => $apache::configfile,
......@@ -47,8 +83,7 @@ define apache::include_file($content=undef, $source=undef, $ensure='present')
notify => Class[apache::service];
}
}
'absent': {
'absent', 'noinclude': {
# Remove the Include directive before the included file; in case
# the machine reboots in the middle, we do not want to needlessly
# hose up the Apache service.
......@@ -59,10 +94,6 @@ define apache::include_file($content=undef, $source=undef, $ensure='present')
before => File[$includefile],
notify => Class[apache::service];
}
file {
$includefile:
ensure => absent, notify => Class[apache::service];
}
}
default: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment