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

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 wrap: on
line source

define website::http(
    $docroot            = undef,
    $docroot_owner      = 'root',
    $docroot_group      = 'root',
    $serveraliases      = [],
    $ensure             = 'present',
    $custom_fragment    = undef
  ) {
  validate_re($ensure, '^(present|absent)$',
  "${ensure} is not supported for ensure.
  Allowed values are 'present' and 'absent'.")

  if ! defined(Class['website']) {
    fail('You must include the website base class before using any website defined resources')
  }

  validate_re($ensure, '^(present|absent)$',
  "${ensure} is not supported for ensure.
  Allowed values are 'present' and 'absent'.")

  $shortname = domain_to_short_name($name)
  $logpart = $shortname

  if $docroot == undef {
    $siteroot = "${website::basedir}/${shortname}"
  } else {
    $siteroot = $docroot
  }

  apache::vhost { $name:
    port            => '80',
    docroot         => $siteroot,
    docroot_owner   => $docroot_owner,
    docroot_group   => $docroot_group,
    custom_fragment => $custom_fragment,
    logroot         => '/var/log/apache/',
    access_log_file => "access_${logpart}.log",
    access_log_format => "%h %l %u %t \\\"%r\\\" %>s %b \\\"%{Referer}i\\\" \\\"%{User-agent}i\\\" %{Host}i",
    serveraliases   => $serveraliases,
    ensure          => $ensure,
  }
}