diff --git a/manifests/include_file.pp b/manifests/include_file.pp index 0a13fc0877b8b4e5dc8f13fe6a7a75938955baa2..482dea2d29997ef24b4721d963144df4021314ad 100644 --- a/manifests/include_file.pp +++ b/manifests/include_file.pp @@ -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: {