Merge branch 'fordsa' of https://git.adam-barratt.org.uk/git/mirror/dsa-puppet
[mirror/dsa-puppet.git] / modules / apache2 / manifests / site.pp
1 # Install and enable an apache site
2 #
3 # @param source  source of the apache vhost file
4 # @param content content of the apache vhost file
5 # @param ensure  present or absent
6 # @param site    site name
7 define apache2::site (
8   Optional[String] $source = undef,
9   Optional[String] $content = undef,
10   Enum['present','absent'] $ensure = 'present',
11   String $site = $name
12 ) {
13   include apache2
14
15   if $ensure == 'present' {
16     if ! ($source or $content) {
17       fail ( "No configuration (source or content) found for ${name}" )
18     }
19   }
20
21   $target = "/etc/apache2/sites-available/${site}"
22   $symlink = "/etc/apache2/sites-enabled/${name}.conf"
23   $link_ensure = $ensure ? {
24     present => link,
25     absent  => absent,
26   }
27
28   file { $target:
29     ensure  => $ensure,
30     content => $content,
31     source  => $source,
32     require => Package['apache2'],
33     notify  => Exec['service apache2 reload'],
34   }
35   file { $symlink:
36     ensure => $link_ensure,
37     target => $target,
38     notify => Exec['service apache2 reload'],
39   }
40 }