Skip to content

Commit

Permalink
PR#292 Compatibility with Softwarecollections (SCL)
Browse files Browse the repository at this point in the history
This adds RedHat SCL compatibility to this puppet module
by adding the rhscl_mode parameter to ::php::globals. By
specifying this parameter the module itself configures
path specifications on its own based on the php_version
string. Further the ::php::extensions define was extended
by the ability to prefix configs and stack up extensions
which are merged into one os package.
  • Loading branch information
diLLec authored and Michael Kluge committed Mar 19, 2018
1 parent 6389761 commit 8c6a601
Show file tree
Hide file tree
Showing 12 changed files with 435 additions and 86 deletions.
10 changes: 5 additions & 5 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
fixtures:
repositories:
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
apt: "git://github.com/puppetlabs/puppetlabs-apt.git"
zypprepo: "git://github.com/deadpoint/puppet-zypprepo.git"
inifile: "git://github.com/puppetlabs/puppetlabs-inifile.git"
archive: "git://github.com/voxpupuli/puppet-archive.git"
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
apt: "https://github.com/puppetlabs/puppetlabs-apt.git"
zypprepo: "https://github.com/deadpoint/puppet-zypprepo.git"
inifile: "https://github.com/puppetlabs/puppetlabs-inifile.git"
archive: "https://github.com/voxpupuli/puppet-archive.git"
symlinks:
php: "#{source_dir}"
121 changes: 120 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ Alternative to the Puppet DSL code examples above, you may optionally define you
Below are all the examples you see above, but defined in YAML format for use with Hiera.

```yaml

---
php::ensure: latest
php::manage_repos: true
Expand Down Expand Up @@ -259,7 +260,7 @@ The older Ubuntu PPAs run by Ondřej have been deprecated (ondrej/php5, ondrej/p
in favor of a new PPA: ondrej/php which contains all 3 versions of PHP: 5.5, 5.6, and 7.0
Here's an example in hiera of getting PHP 5.6 installed with php-fpm, pear/pecl, and composer:

```
```puppet
php::globals::php_version: '5.6'
php::fpm: true
php::dev: true
Expand All @@ -280,6 +281,124 @@ We prefer using php-fpm. You can find an example Apache vhost in
`manifests/apache_vhost.pp` that shows you how to use `mod_proxy_fcgi` to
connect to php-fpm.


### RedHat/CentOS SCL Users
If you plan to use the SCL repositories with this module you must do the following adjustments:

#### General config
This ensures that the module will create configurations in the directory ``/etc/opt/rh/<php_version>/` (also in php.d/
for extensions). Anyway you have to manage the SCL repo's by your own.

```puppet
class { '::php::globals':
php_version => 'rh-php71',
rhscl => true,
}->
class { '::php':
manage_repos => false
}
```

#### Extensions
Extensions in SCL are being installed with packages that cover 1 or more .so files. This is kinda incompatible with
this module, since this module specifies an extension by name and derives the name of the package and the config (.ini)
from it. To manage extensions of SCL packages you must use the following parameters:

```puppet
class { '::php':
...
extensions => {
'soap' => {
ini_prefix => '20-',
},
}
}
```

By this you tell the module to configure bz2 and calender while ensuring only the package `common`. Additionally to the
installation of 'common' the inifiles 'calender.ini' and 'bz2.ini' will be created by the scheme
`<config_file_prefix><extension_title>`.

A list of commonly used modules:
```puppet
{
extensions => {
'xml' => {
ini_prefix => '20-',
multifile_settings => true,
settings => {
'dom' => {},
'simplexml' => {},
'xmlwriter' => {},
'xsl' => {},
'wddx' => {},
'xmlreader' => {},
},
},
'soap' => {
ini_prefix => '20-',
},
'imap' => {
ini_prefix => '20-',
},
'intl' => {
ini_prefix => '20-',
},
'gd' => {
ini_prefix => '20-',
},
'mbstring' => {
ini_prefix => '20-',
},
'xmlrpc' => {
ini_prefix => '20-',
},
'pdo' => {
ini_prefix => '20-',
multifile_settings => true,
settings => {
'pdo' => {},
'pdo_sqlite' => {},
'sqlite3' => {},
},
},
'process' => {
ini_prefix => '20-',
multifile_settings => true,
settings => {
'posix' => {},
'shmop' => {},
'sysvmsg' => {},
'sysvsem' => {},
'sysvshm' => {},
},
},
'mysqlnd' => {
ini_prefix => '30-',
multifile_settings => true,
settings => {
'mysqlnd' => {},
'mysql' => {},
'mysqli' => {},
'pdo_mysql' => {},
'sysvshm' => {},
},
},
'mysqlnd' => {
ini_prefix => '30-',
multifile_settings => true,
settings => {
'mysqlnd' => {},
'mysql' => {},
'mysqli' => {},
'pdo_mysql' => {},
'sysvshm' => {},
},
},
}
}
```

### Facts

We deliver a `phpversion` fact with this module. This is explicitly **NOT** intended
Expand Down
27 changes: 24 additions & 3 deletions manifests/cli.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,31 @@
warning('php::cli is private')
}

if $php::globals::rhscl_mode {
# stupid fixes for scl
file {'/usr/bin/pear':
ensure => 'link',
target => "${$php::params::php_bin_dir}/pear",
}

file {'/usr/bin/pecl':
ensure => 'link',
target => "${$php::params::php_bin_dir}/pecl",
}

file {'/usr/bin/php':
ensure => 'link',
target => "${$php::params::php_bin_dir}/php",
}
}

$real_settings = deep_merge($settings, hiera_hash('php::cli::settings', {}))

::php::config { 'cli':
file => $inifile,
config => $real_settings,
if $inifile != $php::params::config_root_inifile {
# only create a cli specific inifile if the filenames are different
::php::config { 'cli':
file => $inifile,
config => $real_settings,
}
}
}
46 changes: 32 additions & 14 deletions manifests/extension.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@
# Defaults to false.
#
# [*settings*]
# Nested hash of global config parameters for php.ini
# Hash of parameters for the specific extension, which will be written to the extensions config file by
# php::extension::config or a hash of mutliple settings files, each with parameters
# (multifile_settings must be true)
# (f.ex. {p => '..'} or {'bz2' => {..}, {'math' => {...}})
#
# [*multifile_settings*]
# Set this to true if you specify multiple setting files in *settings*. This must be used when the PHP package
# distribution bundles extensions in a single package (like 'common' bundles extensions 'bz2', ...) and each of
# the extension comes with a separate settings file.
#
# [*settings_prefix*]
# Boolean/String parameter, whether to prefix all setting keys with
Expand All @@ -62,12 +70,13 @@
String $ensure = 'installed',
Optional[Php::Provider] $provider = undef,
Optional[String] $source = undef,
Optional[String] $so_name = downcase($name),
Optional[String] $so_name = undef,
Optional[String] $ini_prefix = undef,
Optional[String] $php_api_version = undef,
String $package_prefix = $::php::package_prefix,
Boolean $zend = false,
Hash $settings = {},
Variant[Hash, Hash[String, Hash]] $settings = {},
Boolean $multifile_settings = false,
Php::Sapi $sapi = 'ALL',
Variant[Boolean, String] $settings_prefix = false,
Optional[Stdlib::AbsolutePath] $responsefile = undef,
Expand All @@ -93,17 +102,26 @@

# PEAR packages don't require any further configuration, they just need to "be there".
if $provider != 'pear' {
php::extension::config { $title:
ensure => $ensure,
provider => $provider,
so_name => $so_name,
ini_prefix => $ini_prefix,
php_api_version => $php_api_version,
zend => $zend,
settings => $settings,
settings_prefix => $settings_prefix,
sapi => $sapi,
subscribe => Php::Extension::Install[$title],
$_settings = $multifile_settings ? {
true => $settings,
false => { downcase($title) => $settings } # emulate a hash if no multifile settings
}

$_settings.each |$settings_name, $settings_hash| {
php::extension::config { $settings_name:
ensure => $ensure,
provider => $provider,
# for multifile_settings $name/so_name here makes no sence
# for all other this may be a option
so_name => pick(downcase($name), downcase($so_name), downcase($settings_name)),
ini_prefix => $ini_prefix,
php_api_version => $php_api_version,
zend => $zend,
settings => $settings_hash,
settings_prefix => $settings_prefix,
sapi => $sapi,
subscribe => Php::Extension::Install[$title],
}
}
}
}
1 change: 1 addition & 0 deletions manifests/fpm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
log_group => $log_group,
require => Package[$real_package],
}

contain '::php::fpm::config'
contain '::php::fpm::service'

Expand Down
14 changes: 11 additions & 3 deletions manifests/fpm/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@
mode => '0644',
}

ensure_resource('file', ['/var/run/php-fpm/', '/var/log/php-fpm/'], {
ensure => directory,
owner => $user,
group => $group,
})

file { $pool_base_dir:
ensure => directory,
owner => root,
Expand All @@ -127,8 +133,10 @@
}
}

::php::config { 'fpm':
file => $inifile,
config => $settings,
if $inifile != $php::params::config_root_inifile {
::php::config { 'fpm':
file => $inifile,
config => $settings,
}
}
}
Loading

0 comments on commit 8c6a601

Please sign in to comment.