From: Peter Palfrader Date: Mon, 21 Oct 2019 09:34:07 +0000 (+0200) Subject: Clean up and document apache2::config X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fdsa-puppet.git;a=commitdiff_plain;h=43573e9dd5c646169b4d5ecee3f0137b9467c537 Clean up and document apache2::config --- diff --git a/modules/apache2/manifests/config.pp b/modules/apache2/manifests/config.pp index a3bacd94c..15238a9f3 100644 --- a/modules/apache2/manifests/config.pp +++ b/modules/apache2/manifests/config.pp @@ -1,43 +1,33 @@ +# Install and enable (or disable) an apache config snippet +# +# @param source source of the apache conf file +# @param content content of the apache conf file +# @param ensure present or absent define apache2::config ( - $source=undef, - $content=undef, - $nocontentok=undef, - $ensure=present + Optional[String] $source = undef, + Optional[String] $content = undef, + Enum['present','absent'] $ensure = 'present', ) { - include apache2 case $ensure { present: { - if ! ($source or $content or $nocontentok) { + if ! ($source or $content) { fail ( "No configuration found for ${name}" ) } - - if $content { - file { "/etc/apache2/conf-available/${name}.conf": - ensure => $ensure, - content => $content, - require => Package['apache2'], - notify => Exec['service apache2 reload'], - } - } elsif $source { - file { "/etc/apache2/conf-available/${name}.conf": - ensure => $ensure, - source => $source, - require => Package['apache2'], - notify => Exec['service apache2 reload'], - } - } - } - absent: { - file { "/etc/apache2/conf-available/${name}.conf": - ensure => $ensure, - require => Package['apache2'], - notify => Exec['service apache2 reload'], - } } - default: { fail ( "Unknown ensure value: '$ensure'" ) } + absent: {} + default: { fail ( "Unknown ensure value: ${ensure}" ) } } + + file { "/etc/apache2/conf-available/${name}.conf": + ensure => $ensure, + content => $content, + source => $source, + require => Package['apache2'], + notify => Exec['service apache2 reload'], + } + $link_ensure = $ensure ? { present => link, absent => absent @@ -46,6 +36,6 @@ define apache2::config ( file { "/etc/apache2/conf-enabled/${name}.conf": ensure => $link_ensure, target => "../conf-available/${name}.conf", - notify => Exec['service apache2 reload'], + notify => Exec['service apache2 reload'], } }