view modules/website/manifests/https/multitld.pp @ 0:956e484adc12

Initial public release of Puppet configs
author IBBoard <dev@ibboard.co.uk>
date Sat, 16 Aug 2014 19:47:38 +0000
parents
children 4b42f65ae875
line wrap: on
line source

define website::https::multitld (
  $docroot         = undef,
  $ip              = $website::primary_ip,
  $priority        = undef,
  $base            = $name,
  $main_tld        = $website::tld,
  $extra_tlds      = $website::extra_tlds,
  $ssl_ca_chain    = undef,
  $docroot_owner   = undef,
  $docroot_group   = undef,
  $custom_fragment = undef,
  $force_no_index  = undef,
  $force_no_www    = undef,
  ) {

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

  validate_array($extra_tlds)
  validate_re($main_tld, '^[a-z]+(\.[a-z]+)?', 'TLD must be in the form "com" or "co.uk"')
  $alias = domain_to_short_domain($base)

  if $base == $alias {
    $main_alias = []
  } else {
    $main_alias = [ "${alias}.${main_tld}" ]
  }
  $main_domain = "${base}.${main_tld}"
  website::https { $main_domain:
    priority        => $priority,
    ip              => $ip,
    serveraliases   => $main_alias,
    docroot         => $docroot,
    docroot_owner   => $docroot_owner,
    docroot_group   => $docroot_group,
    ssl_ca_chain    => $ssl_ca_chain,
    custom_fragment => $custom_fragment,
    force_no_index  => $force_no_index,
    force_no_www    => $force_no_www,
  }

  if count($extra_tlds) > 0 {
    $base_extras = prefix($extra_tlds, "${base}.")

    website::https::multitldredir { $base_extras:
      ip          => $ip,
      main_domain => $main_domain,
      docroot     => $docroot,
      docroot_owner => $docroot_owner,
      docroot_group => $docroot_group,
    }
  }
}