decomission senfter RT#8022
[mirror/dsa-puppet.git] / modules / apache2 / manifests / site.pp
index 708e6fa..b847c22 100644 (file)
@@ -1,48 +1,40 @@
+# Install and enable an apache site
+#
+# @param source  source of the apache vhost file
+# @param content content of the apache vhost file
+# @param ensure  present or absent
+# @param site    site name
 define apache2::site (
-       $config = undef,
-       $template = undef,
-       $ensure = present,
-       $site = undef
+  Optional[String] $source = undef,
+  Optional[String] $content = undef,
+  Enum['present','absent'] $ensure = 'present',
+  String $site = $name
 ) {
+  include apache2
 
-       include apache2
+  if $ensure == 'present' {
+    if ! ($source or $content) {
+      fail ( "No configuration (source or content) found for ${name}" )
+    }
+  }
 
-       if ! ($config or $template) {
-               err ( "No configuration found for ${name}" )
-       }
+  $target = "/etc/apache2/sites-available/${site}"
+  $symlink = "/etc/apache2/sites-enabled/${name}.conf"
+  $link_ensure = $ensure ? {
+    present => link,
+    absent  => absent,
+  }
 
-       if $site {
-               $base = $site
-       } else {
-               $base = $name
-       }
-
-       $target = "/etc/apache2/sites-available/${base}"
-
-       $link_target = $ensure ? {
-               present => $target,
-               absent  => absent,
-               default => err ( "Unknown ensure value: '$ensure'" ),
-       }
-
-       if $template {
-               file { $target:
-                       ensure  => $ensure,
-                       content => template($template),
-                       require => Package['apache2'],
-                       notify  => Service['apache2'],
-               }
-       } else {
-               file { $target:
-                       ensure  => $ensure,
-                       source  => $config,
-                       require => Package['apache2'],
-                       notify  => Service['apache2'],
-               }
-       }
-
-       file { "/etc/apache2/sites-enabled/${name}":
-               ensure => $link_target,
-               notify => Service['apache2'],
-       }
+  file { $target:
+    ensure  => $ensure,
+    content => $content,
+    source  => $source,
+    require => Package['apache2'],
+    notify  => Exec['service apache2 reload'],
+  }
+  file { $symlink:
+    ensure => $link_ensure,
+    target => $target,
+    notify => Exec['service apache2 reload'],
+  }
 }