Skip to content

Commit 403b23c

Browse files
committed
Create a entry point class and enable customized php name
In order to install other version of php than OS provided, we need to customize the php package name, e.g. php54, php56 To install customized version of php, install third party repo first, e.g. IUS, then using class { 'php': php_name => 'php54' }
1 parent 9ea9906 commit 403b23c

File tree

15 files changed

+27
-18
lines changed

15 files changed

+27
-18
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ change everything in ways which are typical for RHEL, but it also works on
1010
Debian based distributions (such as Ubuntu), and support for others should
1111
be easy to add.
1212

13+
* `php` : The entry point of the module
1314
* `php::cli` : Simple class to install PHP's Command Line Interface
1415
* `php::fpm::daemon` : Simple class to install PHP's FastCGI Process Manager
1516
* `php::fpm::conf` : PHP FPM pool configuration definition
@@ -20,6 +21,10 @@ be easy to add.
2021

2122
## Examples
2223

24+
Declaring the `php` class
25+
26+
include php
27+
2328
Create `php.ini` files for different uses, but based on the same template :
2429

2530
php::ini { '/etc/php.ini':

manifests/cli.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
class php::cli (
1010
$ensure = 'installed',
1111
$inifile = '/etc/php.ini',
12-
$cli_package_name = $::php::params::cli_package_name,
1312
) inherits ::php::params {
13+
$cli_package_name = "${::php::php_name}${::php::params::cli_package_suffix}"
1414
package { $cli_package_name:
1515
ensure => $ensure,
1616
require => File[$inifile],

manifests/common.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# We can't use a virtual resource, since we have no central place to put it.
77
#
88
class php::common (
9-
$common_package_name = $::php::params::common_package_name,
109
) inherits ::php::params {
10+
$common_package_name = "${::php::php_name}${::php::params::common_package_suffix}"
1111
package { $common_package_name: ensure => 'installed' }
1212
}

manifests/fpm/daemon.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#
88
class php::fpm::daemon (
99
$ensure = 'present',
10-
$fpm_package_name = $::php::params::fpm_package_name,
1110
$log_level = 'notice',
1211
$emergency_restart_threshold = '0',
1312
$emergency_restart_interval = '0',
@@ -18,6 +17,7 @@
1817
$log_group = false,
1918
$log_dir_mode = '0770',
2019
) inherits ::php::params {
20+
$fpm_package_name = "${::php::php_name}-fpm"
2121

2222
# Hack-ish to default to user for group too
2323
$log_group_final = $log_group ? {

manifests/ini.pp

-4
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,9 @@
106106
$soap_wsdl_cache_dir = '/tmp',
107107
$soap_wsdl_cache_ttl = '86400',
108108
) {
109-
110-
include '::php::common'
111-
112109
file { $title:
113110
ensure => $ensure,
114111
content => template($template),
115112
}
116-
117113
}
118114

manifests/init.pp

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class php (
2+
$php_name = $::php::params::php_package_name,
3+
) inherits ::php::params {
4+
}

manifests/mod_php5.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
$inifile = '/etc/php.ini',
1313
) inherits ::php::params {
1414

15-
package { $php_package_name:
15+
package { $::php::php_name:
1616
ensure => $ensure,
1717
require => File[$inifile],
1818
notify => Service[$httpd_service_name],

manifests/module.pp

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717
# Manage the incorrect named php-apc package under Debians
1818
if ($title == 'apc') {
19-
$package = $::php::params::php_apc_package_name
19+
$package = "${::php::php_name}${::php::params::php_apc_package_name}"
2020
} else {
2121
# Hack to get pkg prefixes to work, i.e. php56-mcrypt title
2222
$package = $title ? {
2323
/^php/ => $title,
24-
default => "${::php::params::php_package_name}-${title}"
24+
default => "${::php::php_name}-${title}"
2525
}
2626
}
2727

manifests/module/ini.pp

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
# Package name
3636
$ospkgname = $pkgname ? {
3737
/^php/ => "${pkgname}",
38-
false => "${::php::params::php_package_name}-${title}",
39-
default => "${::php::params::php_package_name}-${pkgname}",
38+
false => "${::php::php_name}-${title}",
39+
default => "${::php::php_name}-${pkgname}",
4040
}
4141
}
4242

manifests/params.pp

+5-6
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
case $::osfamily {
33
'Debian': {
44
$php_package_name = 'php5'
5-
$php_apc_package_name = 'php-apc'
6-
$common_package_name = 'php5-common'
7-
$cli_package_name = 'php5-cli'
5+
$php_apc_package_suffix = '-apc'
86
$php_conf_dir = '/etc/php5/conf.d'
97
$fpm_package_name = 'php5-fpm'
108
$fpm_service_name = 'php5-fpm'
@@ -18,9 +16,7 @@
1816
}
1917
default: {
2018
$php_package_name = 'php'
21-
$php_apc_package_name = 'php-pecl-apc'
22-
$common_package_name = 'php-common'
23-
$cli_package_name = 'php-cli'
19+
$php_apc_package_suffix = '-pecl-apc'
2420
$php_conf_dir = '/etc/php.d'
2521
$fpm_package_name = 'php-fpm'
2622
$fpm_service_name = 'php-fpm'
@@ -33,4 +29,7 @@
3329
$httpd_conf_dir = '/etc/httpd/conf.d'
3430
}
3531
}
32+
33+
$common_package_suffix = '-common'
34+
$cli_package_suffix = '-cli'
3635
}

tests/cli.pp

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
include php
12
php::ini { '/etc/php.ini': }
23
include php::cli

tests/fpm/conf.pp

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
include php
12
include php::fpm::daemon
23
php::fpm::conf { 'www': ensure => absent }
34
php::fpm::conf { 'customer1':

tests/fpm/daemon.pp

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
include php
12
include php::fpm::daemon

tests/mod_php5.pp

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
include php
12
php::ini { '/etc/php-httpd.ini': }
23
service { 'httpd': }
34
package { 'httpd': ensure => installed }

tests/module.pp

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
include php
12
php::module { [ 'ldap', 'mcrypt', 'xml' ]: }

0 commit comments

Comments
 (0)