X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;ds=inline;f=3rdparty%2Fmodules%2Fapache%2Fmanifests%2Fcustom_config.pp;fp=3rdparty%2Fmodules%2Fapache%2Fmanifests%2Fcustom_config.pp;h=ceb1fd077a7f6c5d5f988ad7de97c172af2d1adb;hb=29c25a2dd54b818d590063af535221f98af7d6c8;hp=0000000000000000000000000000000000000000;hpb=943dd63ceab3c595cfdff25de2631d5b74f19dc9;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/apache/manifests/custom_config.pp b/3rdparty/modules/apache/manifests/custom_config.pp new file mode 100644 index 000000000..ceb1fd077 --- /dev/null +++ b/3rdparty/modules/apache/manifests/custom_config.pp @@ -0,0 +1,67 @@ +# See README.md for usage information +define apache::custom_config ( + $ensure = 'present', + $confdir = $::apache::confd_dir, + $content = undef, + $priority = '25', + $source = undef, + $verify_command = $::apache::params::verify_command, + $verify_config = true, +) { + + if $content and $source { + fail('Only one of $content and $source can be specified.') + } + + if $ensure == 'present' and ! $content and ! $source { + fail('One of $content and $source must be specified.') + } + + validate_re($ensure, '^(present|absent)$', + "${ensure} is not supported for ensure. + Allowed values are 'present' and 'absent'.") + + validate_bool($verify_config) + + if $priority { + $priority_prefix = "${priority}-" + } else { + $priority_prefix = '' + } + + ## Apache include does not always work with spaces in the filename + $filename_middle = regsubst($name, ' ', '_', 'G') + $filename = "${priority_prefix}${filename_middle}.conf" + + if ! $verify_config or $ensure == 'absent' { + $notifies = Class['Apache::Service'] + } else { + $notifies = undef + } + + file { "apache_${name}": + ensure => $ensure, + path => "${confdir}/${filename}", + content => $content, + source => $source, + require => Package['httpd'], + notify => $notifies, + } + + if $ensure == 'present' and $verify_config { + exec { "service notify for ${name}": + command => $verify_command, + subscribe => File["apache_${name}"], + refreshonly => true, + notify => Class['Apache::Service'], + before => Exec["remove ${name} if invalid"], + } + + exec { "remove ${name} if invalid": + command => "/bin/rm ${confdir}/${filename}", + unless => $verify_command, + subscribe => File["apache_${name}"], + refreshonly => true, + } + } +}