X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fapache2%2Fmanifests%2Fsite.pp;h=46ec1bf756faa69e319e5a35080bfc11b9c1a5f2;hb=6dbff72324d2f806d47ad84f83d434683bb8aa87;hp=8fa5fdf526097df06ce8a681d4acb282848c0c5c;hpb=175c9bc26de888ba32a7677aa393621425d595f5;p=mirror%2Fdsa-puppet.git diff --git a/modules/apache2/manifests/site.pp b/modules/apache2/manifests/site.pp index 8fa5fdf52..46ec1bf75 100644 --- a/modules/apache2/manifests/site.pp +++ b/modules/apache2/manifests/site.pp @@ -1,16 +1,20 @@ define apache2::site ( - $config = undef, - $template = false, - $ensure = present, - $site = undef + $source=undef, + $content=undef, + $ensure=present, + $site=undef ) { include apache2 - if $ensure == present { - if ! ($config or $template) { - fail ( "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 { @@ -23,37 +27,44 @@ define apache2::site ( $link_target = $ensure ? { present => $target, - absent => absent, - default => fail ( "Unknown ensure value: '$ensure'" ), + absent => absent } - case $template { - false: { - file { $target: - ensure => $ensure, - source => $config, - require => Package['apache2'], - notify => Service['apache2'], - } + if $content { + file { $target: + ensure => $ensure, + content => $content, + require => Package['apache2'], + notify => Service['apache2'], } - default: { - file { $target: - ensure => $ensure, - content => template($template), - require => Package['apache2'], - notify => Service['apache2'], - } + } else { + file { $target: + ensure => $ensure, + source => $source, + require => Package['apache2'], + notify => Service['apache2'], } } - if $ensure == present { + 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 { "/etc/apache2/sites-enabled/${name}": + file { $symlink: ensure => absent, notify => Service['apache2'], }