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.

Changes do only affect the os RedHat and CentOS.
  • Loading branch information
diLLec committed Jan 27, 2017
1 parent 600e1c2 commit 6c2351f
Show file tree
Hide file tree
Showing 17 changed files with 472 additions and 128 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}"
18 changes: 9 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ matrix:
fast_finish: true
include:
- rvm: 1.9.3
env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test
env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test SYSTEM_TESTS="no"
- rvm: 1.9.3
env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" CHECK=test
env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" CHECK=test SYSTEM_TESTS="no"
- rvm: 2.1.9
env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test
env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test SYSTEM_TESTS="no"
- rvm: 2.1.9
env: PUPPET_VERSION="~> 4.0" CHECK=test
env: PUPPET_VERSION="~> 4.0" CHECK=test SYSTEM_TESTS="no"
- rvm: 2.2.6
env: PUPPET_VERSION="~> 4.0" CHECK=test
env: PUPPET_VERSION="~> 4.0" CHECK=test SYSTEM_TESTS="no"
- rvm: 2.3.3
env: PUPPET_VERSION="~> 4.0" CHECK=build DEPLOY_TO_FORGE=yes
env: PUPPET_VERSION="~> 4.0" CHECK=build DEPLOY_TO_FORGE=yes SYSTEM_TESTS="no"
- rvm: 2.3.3
env: PUPPET_VERSION="~> 4.0" CHECK=rubocop
env: PUPPET_VERSION="~> 4.0" CHECK=rubocop SYSTEM_TESTS="no"
- rvm: 2.3.3
env: PUPPET_VERSION="~> 4.0" CHECK=test
env: PUPPET_VERSION="~> 4.0" CHECK=test SYSTEM_TESTS="no"
- rvm: 2.4.0
env: PUPPET_VERSION="~> 4.0" CHECK=test
env: PUPPET_VERSION="~> 4.0" CHECK=test SYSTEM_TESTS="no"
allow_failures:
- rvm: 2.4.0
branches:
Expand Down
20 changes: 11 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,18 @@ group :development do
end

group :system_tests do
if beaker_version = ENV['BEAKER_VERSION']
gem 'beaker', *location_for(beaker_version)
if ENV['SYSTEM_TESTS'] == 'yes'
if beaker_version = ENV['BEAKER_VERSION']
gem 'beaker', *location_for(beaker_version)
end
if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION']
gem 'beaker-rspec', *location_for(beaker_rspec_version)
else
gem 'beaker-rspec', :require => false
end
gem 'serverspec', :require => false
gem 'beaker-puppet_install_helper', :require => false
end
if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION']
gem 'beaker-rspec', *location_for(beaker_rspec_version)
else
gem 'beaker-rspec', :require => false
end
gem 'serverspec', :require => false
gem 'beaker-puppet_install_helper', :require => false
end


Expand Down
80 changes: 79 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,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 @@ -192,7 +193,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 @@ -213,6 +214,83 @@ 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-php56',
rhscl => true,
}->
class { '::php':
manage_repos => false
}
```

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

```puppet
class { '::php':
...
extensions => {
bz2 => { package_name => 'common', config_file_prefix => '20-'},
calendar => { package_name => 'common', config_file_prefix => '20-'},
}
}
```

By this you tell the module to configure bz2 and calender while ensuring only the package `common`. Further the configs
will be created with the schema `<config_file_prefix><extension_title>`.

A list of commonly used modules:
```puppet
calendar => { package_name => 'common', config_file_prefix => '20-'},
ctype => { package_name => 'common', config_file_prefix => '20-'},
curl => { package_name => 'common', config_file_prefix => '20-'},
exif => { package_name => 'common', config_file_prefix => '20-'},
fileinfo => { package_name => 'common', config_file_prefix => '20-'},
ftp => { package_name => 'common', config_file_prefix => '20-'},
gettext => { package_name => 'common', config_file_prefix => '20-'},
iconv => { package_name => 'common', config_file_prefix => '20-'},
phar => { package_name => 'common', config_file_prefix => '20-'},
sockets => { package_name => 'common', config_file_prefix => '20-'},
tokenizer => { package_name => 'common', config_file_prefix => '20-'},
zip => { package_name => 'common', config_file_prefix => '20-'},
dom => { package_name => 'xml', config_file_prefix => '20-'},
simplexml => { package_name => 'xml', config_file_prefix => '20-'},
xmlwriter => { package_name => 'xml', config_file_prefix => '20-'},
xsl => { package_name => 'xml', config_file_prefix => '20-'},
wddx => { package_name => 'xml', config_file_prefix => '30-'},
xmlreader => { package_name => 'xml', config_file_prefix => '30-'},
soap => { config_file_prefix => '20-'},
pdo => { package_name => 'pdo', config_file_prefix => '20-'},
pdo_sqlite => { package_name => 'pdo', config_file_prefix => '30-'},
sqlite3 => { package_name => 'pdo', config_file_prefix => '20-'},
imap => { config_file_prefix => '20-'},
posix => { package_name => 'process', config_file_prefix => '20-'},
shmop => { package_name => 'process', config_file_prefix => '20-'},
sysvmsg => { package_name => 'process', config_file_prefix => '20-'},
sysvsem => { package_name => 'process', config_file_prefix => '20-'},
sysvshm => { package_name => 'process', config_file_prefix => '20-'},
intl => { config_file_prefix => '20-'},
gd => { config_file_prefix => '20-'},
mysqlnd => { package_name => 'mysqlnd', config_file_prefix => '20-'},
mysql => { package_name => 'mysqlnd', config_file_prefix => '30-'},
mysqli => { package_name => 'mysqlnd', config_file_prefix => '30-'},
pdo_mysql => { package_name => 'mysqlnd', config_file_prefix => '30-'},
mbstring => { config_file_prefix => '20-'},
xmlrpc => { config_file_prefix => '30-'},
json => { provider => 'pecl', package_name => 'jsonc', config_file_prefix => '40-'},
```

### Facts

We deliver a `phpversion` fact with this module. This is explicitly **NOT** intended
Expand Down
15 changes: 15 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,19 @@ task test: [
:metadata_lint,
:release_checks,
]

desc 'Run spec tests of exactly one specfile'
# usage: bundle exec rake spec_single[<path to specfile>]
task :spec_single, [:specfile] do |t, args|
RSpec::Core::RakeTask.new(:spec_onetest) do |t|
t.pattern = args[:specfile]
t.rspec_opts = ['--color']
end

Rake::Task[:spec_prep].invoke
Rake::Task[:spec_onetest].invoke
# Rake::Task[:spec_clean].invoke
end


# vim: syntax=ruby
5 changes: 4 additions & 1 deletion lib/puppet/provider/package/pear.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ def self.pearlist(hash)
list = list.map do |set|
%r{INSTALLED PACKAGES, CHANNEL (.*):}i.match(set) { |m| channel = m[1].downcase }

# if hash[:justme] is specified this should only put something into pearhash if
# the line matched the string in hash[:justme]
if hash[:justme] && set =~ %r{^#{hash[:justme]}}
pearhash = pearsplit(set, channel)
pearhash[:provider] = :pear
pearhash
elsif (pearhash = pearsplit(set, channel))
elsif !hash[:justme] && (pearhash = pearsplit(set, channel))
pearhash[:provider] = :pear
pearhash
end
Expand Down Expand Up @@ -102,6 +104,7 @@ def latest
end

def query
Puppet.debug format("doing the pearlist for '%s'", @resource[:name])
self.class.pearlist(justme: @resource[:name])
end

Expand Down
27 changes: 24 additions & 3 deletions manifests/cli.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,31 @@
validate_absolute_path($inifile)
validate_hash($settings)

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,
}
}
}
14 changes: 9 additions & 5 deletions manifests/embedded.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,21 @@
)

$real_package = $::osfamily ? {
'Debian' => "lib${package}",
'Debian' => "lib${package}",
default => $package,
}

package { $real_package:
ensure => $ensure,
require => Class['::php::packages'],
}->
::php::config { 'embedded':
file => $inifile,
config => $real_settings,
before => Php::Config['embedded'],
}

if $inifile != $php::params::config_root_inifile {
::php::config { 'embedded':
file => $inifile,
config => $real_settings,
}
}

}
Loading

0 comments on commit 6c2351f

Please sign in to comment.