Defined Type: apache::site

Defined in:
puppet/modules/apache/manifests/site.pp

Overview

Define: apache::site

Manages Apache site configurations. This is a very thin wrapper around a File resource for a /etc/apache2/sites-available config file and a symlink pointing to it in /etc/apache/sites-enabled. By using it, you don't have to worry about dependencies and ordering; the resource will take care that Apache & all modules are provisioned before the site is.

Parameters

ensure

If 'present', site will be enabled; if 'absent', disabled. The default is 'present'.

priority

If you need this site to load before or after other sites, you can do so by manipulating this value. In most cases, the default value of 50 should be fine.

content

If defined, will be used as the content of the site configuration file. Undefined by default. Mutually exclusive with 'source'.

source

Path to file containing configuration directives. Undefined by default. Mutually exclusive with 'content'.

Examples

apache::site { 'blog.wikimedia.org':
  ensure  => present,
  content => template('blog/blog-apache-config.erb'),
}

Parameters:

  • ensure (Any) (defaults to: present)
  • priority (Any) (defaults to: 50)
  • content (Any) (defaults to: undef)
  • source (Any) (defaults to: undef)


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'puppet/modules/apache/manifests/site.pp', line 35

define apache::site(
    $ensure   = present,
    $priority = 50,
    $content  = undef,
    $source   = undef,
) {
    include ::apache

    $title_safe = regsubst($title, '[\W_]', '-', 'G')
    $dir_ensure = $ensure ? {
        present => directory,
        default => absent,
    }

    file { "/etc/apache2/site-confs/${title_safe}":
        ensure  => $dir_ensure,
        recurse => true,
        purge   => true,
        force   => true,
    }

    file { "/etc/apache2/site-confs/${title_safe}/00-default.conf":
        ensure  => $ensure,
        content => $content,
        source  => $source,
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
    }

    apache::conf { $title_safe:
        ensure    => $ensure,
        conf_type => 'sites',
        priority  => $priority,
        content   => template('apache/site.conf.erb'),
    }
}