Skip to content

Create a entry point class and enable customized php name #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ change everything in ways which are typical for RHEL, but it also works on
Debian based distributions (such as Ubuntu), and support for others should
be easy to add.

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

## Examples

Declaring the `php` class

include php

Create `php.ini` files for different uses, but based on the same template :

php::ini { '/etc/php.ini':
Expand Down
2 changes: 1 addition & 1 deletion manifests/cli.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
class php::cli (
$ensure = 'installed',
$inifile = '/etc/php.ini',
$cli_package_name = $::php::params::cli_package_name,
) inherits ::php::params {
$cli_package_name = "${::php::php_name}${::php::params::cli_package_suffix}"
package { $cli_package_name:
ensure => $ensure,
require => File[$inifile],
Expand Down
2 changes: 1 addition & 1 deletion manifests/common.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# We can't use a virtual resource, since we have no central place to put it.
#
class php::common (
$common_package_name = $::php::params::common_package_name,
) inherits ::php::params {
$common_package_name = "${::php::php_name}${::php::params::common_package_suffix}"
package { $common_package_name: ensure => 'installed' }
}
2 changes: 1 addition & 1 deletion manifests/fpm/conf.pp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
$group_final = $group ? { undef => $user, default => $group }

$fpm_package_name_final = $fpm_package_name ? {
undef => $::php::params::fpm_package_name,
undef => $::php::fpm::daemon::fpm_package_name,
default => $fpm_package_name,
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/fpm/daemon.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#
class php::fpm::daemon (
$ensure = 'present',
$fpm_package_name = $::php::params::fpm_package_name,
$log_level = 'notice',
$emergency_restart_threshold = '0',
$emergency_restart_interval = '0',
Expand All @@ -18,6 +17,7 @@
$log_group = false,
$log_dir_mode = '0770',
) inherits ::php::params {
$fpm_package_name = "${::php::php_name}-fpm"

# Hack-ish to default to user for group too
$log_group_final = $log_group ? {
Expand Down
4 changes: 0 additions & 4 deletions manifests/ini.pp
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,9 @@
$soap_wsdl_cache_dir = '/tmp',
$soap_wsdl_cache_ttl = '86400',
) {

include '::php::common'

file { $title:
ensure => $ensure,
content => template($template),
}

}

4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class php (
$php_name = $::php::params::php_package_name,
) inherits ::php::params {
}
2 changes: 1 addition & 1 deletion manifests/mod_php5.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
$inifile = '/etc/php.ini',
) inherits ::php::params {

package { $php_package_name:
package { $::php::php_name:
ensure => $ensure,
require => File[$inifile],
notify => Service[$httpd_service_name],
Expand Down
4 changes: 2 additions & 2 deletions manifests/module.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

# Manage the incorrect named php-apc package under Debians
if ($title == 'apc') {
$package = $::php::params::php_apc_package_name
$package = "${::php::php_name}${::php::params::php_apc_package_suffix}"
} else {
# Hack to get pkg prefixes to work, i.e. php56-mcrypt title
$package = $title ? {
/^php/ => $title,
default => "${::php::params::php_package_name}-${title}"
default => "${::php::php_name}-${title}"
}
}

Expand Down
6 changes: 3 additions & 3 deletions manifests/module/ini.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
# Handle naming issue of php-apc package on Debian
if ($modname == 'apc' and $pkgname == false) {
# Package name
$ospkgname = $::php::params::php_apc_package_name
$ospkgname = "${::php::php_name}${::php::params::php_apc_package_suffix}"
} else {
# Package name
$ospkgname = $pkgname ? {
/^php/ => "${pkgname}",
false => "${::php::params::php_package_name}-${title}",
default => "${::php::params::php_package_name}-${pkgname}",
false => "${::php::php_name}-${title}",
default => "${::php::php_name}-${pkgname}",
}
}

Expand Down
11 changes: 5 additions & 6 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
case $::osfamily {
'Debian': {
$php_package_name = 'php5'
$php_apc_package_name = 'php-apc'
$common_package_name = 'php5-common'
$cli_package_name = 'php5-cli'
$php_apc_package_suffix = '-apc'
$php_conf_dir = '/etc/php5/conf.d'
$fpm_package_name = 'php5-fpm'
$fpm_service_name = 'php5-fpm'
Expand All @@ -18,9 +16,7 @@
}
default: {
$php_package_name = 'php'
$php_apc_package_name = 'php-pecl-apc'
$common_package_name = 'php-common'
$cli_package_name = 'php-cli'
$php_apc_package_suffix = '-pecl-apc'
$php_conf_dir = '/etc/php.d'
$fpm_package_name = 'php-fpm'
$fpm_service_name = 'php-fpm'
Expand All @@ -33,4 +29,7 @@
$httpd_conf_dir = '/etc/httpd/conf.d'
}
}

$common_package_suffix = '-common'
$cli_package_suffix = '-cli'
}
1 change: 1 addition & 0 deletions tests/cli.pp
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include php
php::ini { '/etc/php.ini': }
include php::cli
1 change: 1 addition & 0 deletions tests/fpm/conf.pp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include php
include php::fpm::daemon
php::fpm::conf { 'www': ensure => absent }
php::fpm::conf { 'customer1':
Expand Down
1 change: 1 addition & 0 deletions tests/fpm/daemon.pp
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include php
include php::fpm::daemon
1 change: 1 addition & 0 deletions tests/mod_php5.pp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include php
php::ini { '/etc/php-httpd.ini': }
service { 'httpd': }
package { 'httpd': ensure => installed }
Expand Down
1 change: 1 addition & 0 deletions tests/module.pp
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include php
php::module { [ 'ldap', 'mcrypt', 'xml' ]: }