X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fapache2%2Fmanifests%2Fsite.pp;h=dc9b1ced1f796f00d6e547e391673275f11d43fe;hb=2f220970c8e94dddb50fbdbe72f245d834a4d7bc;hp=34292384e7f83579a774fe3479d7a71025bf981c;hpb=d12e10310ffb896fae1c736a99de385831a7bc90;p=mirror%2Fdsa-puppet.git diff --git a/modules/apache2/manifests/site.pp b/modules/apache2/manifests/site.pp index 34292384e..dc9b1ced1 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,36 +27,42 @@ 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'], } } + $symlink = "/etc/apache2/sites-enabled/${name}.conf" + + file { "/etc/apache2/sites-enabled/${name}": + ensure => absent, + notify => Exec['service apache2 reload'], + } + if $ensure == present { - file { "/etc/apache2/sites-enabled/${name}": + file { $symlink: ensure => link, target => $link_target, - notify => Service['apache2'], + notify => Exec['service apache2 reload'], } } else { - file { "/etc/apache2/sites-enabled/${name}": + file { $symlink: ensure => absent, - notify => Service['apache2'], + notify => Exec['service apache2 reload'], } } }