]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - modules/apache2/manifests/site.pp
apache 2.4 sites stuff
[dsa-puppet.git] / modules / apache2 / manifests / site.pp
index 708e6fa0133e6462c1336a3e3bff7dae47cb8592..9ab7635159c0d02f089d349b88017910df73ccb9 100644 (file)
@@ -1,14 +1,20 @@
 define apache2::site (
-       $config = undef,
-       $template = undef,
-       $ensure = present,
-       $site = undef
+       $source=undef,
+       $content=undef,
+       $ensure=present,
+       $site=undef
 ) {
 
        include apache2
 
-       if ! ($config or $template) {
-               err ( "No configuration found for ${name}" )
+       case $ensure {
+               present: {
+                       if ! ($source or $content) {
+                               fail ( "No configuration found for ${name}" )
+                       }
+               }
+               absent:  {}
+               default: { fail ( "Unknown ensure value: '$ensure'" ) }
        }
 
        if $site {
@@ -21,28 +27,46 @@ define apache2::site (
 
        $link_target = $ensure ? {
                present => $target,
-               absent  => absent,
-               default => err ( "Unknown ensure value: '$ensure'" ),
+               absent  => absent
        }
 
-       if $template {
+       if $content {
                file { $target:
                        ensure  => $ensure,
-                       content => template($template),
+                       content => $content,
                        require => Package['apache2'],
                        notify  => Service['apache2'],
                }
        } else {
                file { $target:
                        ensure  => $ensure,
-                       source  => $config,
+                       source  => $source,
                        require => Package['apache2'],
                        notify  => Service['apache2'],
                }
        }
 
-       file { "/etc/apache2/sites-enabled/${name}":
-               ensure => $link_target,
-               notify => Service['apache2'],
+       if $::lsbmajdistrelease <= 7 {
+               $symlink = "/etc/apache2/sites-enabled/${name}":
+       } else {
+               $symlink = "/etc/apache2/sites-enabled/${name}.conf":
+
+               file { "/etc/apache2/sites-enabled/${name}":
+                       ensure => absent,
+                       notify => Service['apache2'],
+               }
+       }
+
+       if $ensure == present {
+               file { $symlink:
+                       ensure => link,
+                       target => $link_target,
+                       notify => Service['apache2'],
+               }
+       } else {
+               file { $symlink:
+                       ensure => absent,
+                       notify => Service['apache2'],
+               }
        }
 }