Defined Type: apache::vhost::custom

Defined in:
manifests/vhost/custom.pp

Summary

A wrapper around the `apache::custom_config` defined type.

Overview

The ‘apache::vhost::custom` defined type is a thin wrapper around the `apache::custom_config` defined type, and simply overrides some of its default settings specific to the virtual host directory in Apache.

Parameters:

  • content (String)

    Sets the configuration file’s content.

  • ensure (String) (defaults to: 'present')

    Specifies if the virtual host file is present or absent.

  • priority (Apache::Vhost::Priority) (defaults to: 25)

    Sets the relative load order for Apache HTTPD VirtualHost configuration files.

  • verify_config (Boolean) (defaults to: true)

    Specifies whether to validate the configuration file before notifying the Apache service.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'manifests/vhost/custom.pp', line 18

define apache::vhost::custom (
  String $content,
  String $ensure                      = 'present',
  Apache::Vhost::Priority $priority   = 25,
  Boolean $verify_config              = true,
) {
  include apache

  ## Apache include does not always work with spaces in the filename
  $filename = regsubst($name, ' ', '_', 'G')

  ::apache::custom_config { $filename:
    ensure        => $ensure,
    confdir       => $apache::vhost_dir,
    content       => $content,
    priority      => $priority,
    verify_config => $verify_config,
  }

  # NOTE(pabelanger): This code is duplicated in ::apache::vhost and needs to
  # converted into something generic.
  if $apache::vhost_enable_dir {
    $vhost_symlink_ensure = $ensure ? {
      'present' => link,
      default => $ensure,
    }

    file { "${priority}-${filename}.conf symlink":
      ensure  => $vhost_symlink_ensure,
      path    => "${apache::vhost_enable_dir}/${priority}-${filename}.conf",
      target  => "${apache::vhost_dir}/${priority}-${filename}.conf",
      owner   => 'root',
      group   => $apache::params::root_group,
      mode    => $apache::file_mode,
      require => Apache::Custom_config[$filename],
      notify  => Class['apache::service'],
    }
  }
}