whitespace: apache2/manifests
[mirror/dsa-puppet.git] / modules / apache2 / manifests / site.pp
1 define apache2::site (
2   $source=undef,
3   $content=undef,
4   $ensure=present,
5   $site=undef
6 ) {
7
8   include apache2
9
10   case $ensure {
11     present: {
12       if ! ($source or $content) {
13         fail ( "No configuration found for ${name}" )
14       }
15     }
16     absent:  {}
17     default: { fail ( "Unknown ensure value: '$ensure'" ) }
18   }
19
20   if $site {
21     $base = $site
22   } else {
23     $base = $name
24   }
25
26   $target = "/etc/apache2/sites-available/${base}"
27
28   $link_target = $ensure ? {
29     present => $target,
30     absent  => absent
31   }
32
33   if $content {
34     file { $target:
35       ensure  => $ensure,
36       content => $content,
37       require => Package['apache2'],
38       notify  => Exec['service apache2 reload'],
39     }
40   } else {
41     file { $target:
42       ensure  => $ensure,
43       source  => $source,
44       require => Package['apache2'],
45       notify  => Exec['service apache2 reload'],
46     }
47   }
48
49   $symlink = "/etc/apache2/sites-enabled/${name}.conf"
50
51   file { "/etc/apache2/sites-enabled/${name}":
52     ensure => absent,
53     notify  => Exec['service apache2 reload'],
54   }
55
56   if $ensure == present {
57     file { $symlink:
58       ensure => link,
59       target => $link_target,
60       notify  => Exec['service apache2 reload'],
61     }
62   } else {
63     file { $symlink:
64       ensure => absent,
65       notify  => Exec['service apache2 reload'],
66     }
67   }
68 }