Clean up and document apache2::config
[mirror/dsa-puppet.git] / modules / apache2 / manifests / config.pp
1 # Install and enable (or disable) an apache config snippet
2 #
3 # @param source  source of the apache conf file
4 # @param content content of the apache conf file
5 # @param ensure  present or absent
6 define apache2::config (
7   Optional[String] $source = undef,
8   Optional[String] $content = undef,
9   Enum['present','absent'] $ensure = 'present',
10 ) {
11   include apache2
12
13   case $ensure {
14     present: {
15       if ! ($source or $content) {
16         fail ( "No configuration found for ${name}" )
17       }
18     }
19     absent:  {}
20     default: { fail ( "Unknown ensure value: ${ensure}" ) }
21   }
22
23   file { "/etc/apache2/conf-available/${name}.conf":
24     ensure  => $ensure,
25     content => $content,
26     source  => $source,
27     require => Package['apache2'],
28     notify  => Exec['service apache2 reload'],
29   }
30
31   $link_ensure = $ensure ? {
32     present => link,
33     absent  => absent
34   }
35
36   file { "/etc/apache2/conf-enabled/${name}.conf":
37     ensure => $link_ensure,
38     target => "../conf-available/${name}.conf",
39     notify => Exec['service apache2 reload'],
40   }
41 }