Puppet Class: apache

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

Overview

Class: apache

Configures Apache HTTP Server

Parameters:

docroot

Web server docroot directory.

Parameters:

  • docroot (Any)


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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'puppet/modules/apache/manifests/init.pp', line 10

class apache (
    $docroot,
) {
    package { 'apache2':
        ensure  => present,
    }

    include apache::mod::php
    include apache::mod::access_compat

    file { '/etc/apache2/ports.conf':
        content => template('apache/ports.conf.erb'),
        require => Package['apache2'],
        notify  => [
            Exec['apache2 release ports'],
            Service['apache2'],
        ],
    }

    # T183692: A normal restart of Apache2 will not release bound ports. We
    # need to trigger a hard restart to fix that.
    exec { 'apache2 release ports':
        command     => '/usr/sbin/service apache2 stop',
        onlyif      => '/usr/sbin/service apache2 status',
        refreshonly => true,
        notify      => Service['apache2'],
    }

    # Set EnableSendfile to 'Off' to work around a bug with Vagrant.
    # See <https://github.com/hashicorp/vagrant/issues/351>.
    apache::conf { 'disable sendfile':
        content => 'EnableSendfile Off',
    }

    apache::conf { 'errors to syslog':
        content => 'ErrorLog syslog',
    }

    rsyslog::conf { 'apache':
        source   => 'puppet:///modules/apache/rsyslog.conf',
        priority => 40,
    }

    file { [
        '/etc/apache2/conf-available',
        '/etc/apache2/conf-enabled',
        '/etc/apache2/env-available',
        '/etc/apache2/env-enabled',
        '/etc/apache2/sites-available',
        '/etc/apache2/sites-enabled',
        '/etc/apache2/site-confs',
    ]:
        ensure  => directory,
        recurse => true,
        purge   => true,
        force   => true,
        notify  => Service['apache2'],
        require => Package['apache2'],
    }

    file { '/etc/apache2/envvars':
        ensure  => present,
        source  => 'puppet:///modules/apache/envvars',
        require => Package['apache2'],
        notify  => Service['apache2'],
    }

    service { 'apache2':
        ensure  => running,
        enable  => true,
        require => Package['apache2'],
    }

    file { $docroot:
        ensure => directory,
    }

    # compatibility with old location
    if $docroot != '/var/www' {
        file { '/var/www':
            ensure => 'link',
            target => $docroot,
        }
    }

    # make sure all PHP files are available from the host machine so they can be debugged
    file { '/vagrant/srv/docroot':
        ensure             => present,
        source             => $docroot,
        source_permissions => ignore,
        recurse            => remote,
    }
    file { '/vagrant/srv/composer':
        ensure             => present,
        source             => '/usr/local/bin/composer',
        source_permissions => ignore,
        require            => Class['php::composer'],
    }

    Apache::Env <| |> -> Apache::Mod_conf <| |> -> Apache::Conf <| |>
    Apache::Site <| |> -> Apache::Site_conf <| |>

    misc::evergreen { 'apache2': }
}