Move apache module configs to apache2::module dir; add compat includes
[mirror/dsa-puppet.git] / modules / apache2 / manifests / config.pp
1 define apache2::config (
2         $source=undef,
3         $content=undef,
4         $nocontentok=undef,
5         $ensure=present
6 ) {
7
8         include apache2
9
10         case $ensure {
11                 present: {
12                         if ! ($source or $content or $nocontentok) {
13                                 fail ( "No configuration found for ${name}" )
14                         }
15
16                         if $content {
17                                 file { "/etc/apache2/conf-available/${name}.conf":
18                                         ensure  => $ensure,
19                                         content => $content,
20                                         require => Package['apache2'],
21                                         notify  => Exec['service apache2 reload'],
22                                 }
23                         } elsif $source {
24                                 file { "/etc/apache2/conf-available/${name}.conf":
25                                         ensure  => $ensure,
26                                         source  => $source,
27                                         require => Package['apache2'],
28                                         notify  => Exec['service apache2 reload'],
29                                 }
30                         }
31                 }
32                 absent:  {
33                         file { "/etc/apache2/conf-available/${name}.conf":
34                                 ensure  => $ensure,
35                                 require => Package['apache2'],
36                                 notify  => Exec['service apache2 reload'],
37                         }
38                 }
39                 default: { fail ( "Unknown ensure value: '$ensure'" ) }
40         }
41         $link_ensure = $ensure ? {
42                 present => link,
43                 absent  => absent
44         }
45
46         file { "/etc/apache2/conf-enabled/${name}.conf":
47                 ensure => $link_ensure,
48                 target => "../conf-available/${name}.conf",
49                 notify  => Exec['service apache2 reload'],
50         }
51 }