X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fapache2%2Fmanifests%2Fsite.pp;h=2a7257ba76e1cd543fa65ec8e1e594539cb0cfe8;hb=f261675d1981a00ed45097531fdc59a5c37ae5b7;hp=708e6fa0133e6462c1336a3e3bff7dae47cb8592;hpb=3eb533e5499e66423bafdedaf6c7d08ead1772de;p=mirror%2Fdsa-puppet.git diff --git a/modules/apache2/manifests/site.pp b/modules/apache2/manifests/site.pp index 708e6fa01..2a7257ba7 100644 --- a/modules/apache2/manifests/site.pp +++ b/modules/apache2/manifests/site.pp @@ -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'], + notify => Exec['service apache2 reload'], } } else { file { $target: ensure => $ensure, - source => $config, + source => $source, require => Package['apache2'], - notify => Service['apache2'], + notify => Exec['service apache2 reload'], } } - 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 => Exec['service apache2 reload'], + } + } + + if $ensure == present { + file { $symlink: + ensure => link, + target => $link_target, + notify => Exec['service apache2 reload'], + } + } else { + file { $symlink: + ensure => absent, + notify => Exec['service apache2 reload'], + } } }