Skip to content

Commit 0ad3079

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 0ad3079

File tree

16 files changed

+29
-20
lines changed

16 files changed

+29
-20
lines changed

README.md

Lines changed: 5 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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/conf.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
$group_final = $group ? { undef => $user, default => $group }
6767

6868
$fpm_package_name_final = $fpm_package_name ? {
69-
undef => $::php::params::fpm_package_name,
69+
undef => $::php::fpm::daemon::fpm_package_name,
7070
default => $fpm_package_name,
7171
}
7272

manifests/fpm/daemon.pp

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 4 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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_suffix}"
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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
# Handle naming issue of php-apc package on Debian
3131
if ($modname == 'apc' and $pkgname == false) {
3232
# Package name
33-
$ospkgname = $::php::params::php_apc_package_name
33+
$ospkgname = "${::php::php_name}${::php::params::php_apc_package_suffix}"
3434
} else {
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

0 commit comments

Comments
 (0)