aboutsummaryrefslogtreecommitdiffstats
path: root/modules/apache/manifests/vhost/base.pp
blob: a7e5720d30d5af19a747ccd0d1b156ed021faaff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
define apache::vhost::base ($content = '',
                            $location = '/dev/null',
                            $use_ssl = false,
                            $vhost = false,
                            $aliases = {},
                            $server_aliases = [],
                            $access_logfile = false,
                            $error_logfile = false,
                            $options = [],
                            $enable_public_html = false) {
    include apache::base
    $httpd_logdir = '/var/log/httpd'
    $filename = "$name.conf"

    if ! $vhost {
        $real_vhost = $name
    } else {
        $real_vhost = $vhost
    }

    if ! $access_logfile {
        $real_access_logfile = "$httpd_logdir/${real_vhost}-access_log"
    } else {
        $real_access_logfile = $access_logfile
    }
    if ! $error_logfile {
        $real_error_logfile = "$httpd_logdir/${real_vhost}-error_log"
    } else {
        $real_error_logfile = $error_logfile
    }

    if $use_ssl {
        include apache::mod::ssl
        if $wildcard_sslcert != true {
            openssl::self_signed_cert{ $real_vhost:
                directory => '/etc/ssl/apache/',
                before    => Apache::Config["/etc/httpd/conf/vhosts.d/$filename"],
            }
        }
    }

    if $enable_public_html {
        include apache::mod::public_html
    }

    apache::config { "/etc/httpd/conf/vhosts.d/$filename":
        content => template('apache/vhost_base.conf')
    }
}