Report abuse

modules/php/manifests/init.pp

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
class php {
        include apache
        # default php packages 
        $packagelist = ["php5", "php5-common", "php5-cli", "libapache2-mod-php5",
                "php5-pgsql", "php5-mysql",
                "php5-curl", "php5-suhosin",
                "php5-snmp", "php5-xsl"]

        package { $packagelist:
                ensure => "installed",
        }

        # ensure mode enabled
        apache::module { "php5": }

        # fix pg/curl init bug
        file { "/etc/php5/conf.d/10-pgsql.ini":
                ensure => "present",
                content => "extension=pgsql.so",
                notify => Exec["apache-force-reload"],
                require => Package["php5-pgsql"],
        }
        file { "/etc/php5/conf.d/pgsql.ini":
                ensure => "absent",
                notify => Exec["apache-force-reload"],
                require => Package["php5"],
        }
}
...
define php::config ( 
                $path = "/etc/php5/apache/php.ini",
                $max_execution_time = "30",
                $max_input_time = "60",
                $memory_limit = "40M",
                $display_errors = "Off",
                $post_max_size = "8M",
                $upload_max_filesize = "4M",
                ) {

        file { "/etc/php5/apache/php.ini":
                ensure  => "present",
                content => template("php/php.ini.erb"),
                require => Package["php5"],
        }
}

modules/php/templates/php.ini.erb

1
2
3
4
5
; PUPPET
[PHP]
...
memory_limit = <%= $memory_limit %>
...

node

1
2
3
4
5
6
7
8
9
10
node "www.example.com" {
        include php
        php::config { $fqdn:
            memory_limit => "100M",
        }
        php::config { $fqdn:
            path => "/etc/php5/cli/php.ini",
            memory_limit => "200M",
        }
}