Skip to content

Commit

Permalink
Merge pull request #451 from oranenj/scl
Browse files Browse the repository at this point in the history
Compatibility with Software collections (SCL)
  • Loading branch information
bastelfreak authored May 10, 2018
2 parents 0a69781 + b9f81d7 commit f4863c1
Show file tree
Hide file tree
Showing 12 changed files with 438 additions and 85 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 @@ -15,10 +15,31 @@

assert_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,
}
}
}
49 changes: 35 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,29 @@

# 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| {
$so_name = $multifile_settings ? {
true => downcase($settings_name),
false => pick(downcase($so_name), downcase($name), downcase($settings_name)),
}

php::extension::config { $settings_name:
ensure => $ensure,
provider => $provider,
so_name => $so_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 @@ -111,6 +111,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 @@ -125,8 +131,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 f4863c1

Please sign in to comment.