view modules/website/manifests/http.pp @ 182:1df1e161bbb5 puppet-3.6

Set group sticky bit on all sites to ease collaboration
author IBBoard <dev@ibboard.co.uk>
date Fri, 07 Dec 2018 19:52:50 +0000
parents d2b4750e843a
children 13825cc1ec57
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,
    docroot_mode    => '2775',
    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,
  }
}