X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fapache2%2Fmanifests%2Fsite.pp;h=b847c223e4455b5a2bc67b9a1984d0f7160b9496;hb=e65811f82c85fbde0b793450b838e8038bc95b94;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..b847c223e 100644 --- a/modules/apache2/manifests/site.pp +++ b/modules/apache2/manifests/site.pp @@ -1,56 +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'], - } - } - - if $ensure == present { - file { "/etc/apache2/sites-enabled/${name}": - ensure => link, - target => $link_target, - notify => Service['apache2'], - } - } else { - file { "/etc/apache2/sites-enabled/${name}": - ensure => absent, - 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'], + } }