view modules/website/manifests/http.pp @ 161:d2b4750e843a

Add custom log format - combined plus requested domain This helps by logging which domain people hit and got redirected by without having per-domain logs
author IBBoard <dev@ibboard.co.uk>
date Sun, 02 Apr 2017 20:09:13 +0100
parents 72466547cc79
children 1df1e161bbb5
line source
1 define website::http(
2 $docroot = undef,
3 $docroot_owner = 'root',
4 $docroot_group = 'root',
5 $serveraliases = [],
6 $ensure = 'present',
7 $custom_fragment = undef
8 ) {
9 validate_re($ensure, '^(present|absent)$',
10 "${ensure} is not supported for ensure.
11 Allowed values are 'present' and 'absent'.")
13 if ! defined(Class['website']) {
14 fail('You must include the website base class before using any website defined resources')
15 }
17 validate_re($ensure, '^(present|absent)$',
18 "${ensure} is not supported for ensure.
19 Allowed values are 'present' and 'absent'.")
21 $shortname = domain_to_short_name($name)
22 $logpart = $shortname
24 if $docroot == undef {
25 $siteroot = "${website::basedir}/${shortname}"
26 } else {
27 $siteroot = $docroot
28 }
30 apache::vhost { $name:
31 port => '80',
32 docroot => $siteroot,
33 docroot_owner => $docroot_owner,
34 docroot_group => $docroot_group,
35 custom_fragment => $custom_fragment,
36 logroot => '/var/log/apache/',
37 access_log_file => "access_${logpart}.log",
38 access_log_format => "%h %l %u %t \\\"%r\\\" %>s %b \\\"%{Referer}i\\\" \\\"%{User-agent}i\\\" %{Host}i",
39 serveraliases => $serveraliases,
40 ensure => $ensure,
41 }
42 }