Skip to content

Commit

Permalink
add ubuntu 16.04 support
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Feb 3, 2018
1 parent a86b47d commit 0ad7566
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 30 deletions.
21 changes: 16 additions & 5 deletions manifests/dev.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
# The package name for the PHP development files
#
class php::dev(
String $ensure = $::php::ensure,
String $package = "${::php::package_prefix}${::php::params::dev_package_suffix}",
String $ensure = $::php::ensure,
String $package = "${::php::package_prefix}${::php::params::dev_package_suffix}",
Boolean $manage_repos = $php::manage_repos,
) inherits ::php::params {

if $caller_module_name != $module_name {
Expand All @@ -23,21 +24,31 @@
default => $package,
}

if $facts['os']['family'] == 'Debian' {
# we can set the dependency only if we manage repos
$require = $manage_repos ? {
true => Class['::apt::update'],
false => undef,
}
} else {
$require = undef
}

# Default PHP come with xml module and no seperate package for it
if $facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '16.04') >= 0 {
ensure_packages(["${php::package_prefix}xml"], {
ensure => present,
require => Class['::apt::update'],
require => $require,
})

package { $real_package:
ensure => $ensure,
require => Class['::php::packages'],
require => $require,
}
} else {
package { $real_package:
ensure => $ensure,
require => Class['::php::packages'],
require => $require,
}
}
}
10 changes: 8 additions & 2 deletions manifests/pear.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class php::pear (
String $ensure = $::php::pear_ensure,
Optional[String] $package = undef,
Boolean $manage_repos = $php::manage_repos,
) inherits ::php::params {

if $caller_module_name != $module_name {
Expand Down Expand Up @@ -46,16 +47,21 @@
}
}

# the apt module provides apt::update. apt is only included if we manage any repos
$require = $manage_repos ? {
true => Class['::apt::update'],
false => undef,
}
# Default PHP come with xml module and no seperate package for it
if $facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '16.04') >= 0 {
ensure_packages(["${php::package_prefix}xml"], {
ensure => present,
require => Class['::apt::update'],
require => $require,
})

package { $package_name:
ensure => $ensure,
require => [Class['::apt::update'],Class['::php::cli'],Package["${php::package_prefix}xml"]],
require => [$require,Class['::php::cli'],Package["${php::package_prefix}xml"]],
}
} else {
package { $package_name:
Expand Down
3 changes: 2 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"14.04"
"14.04",
"16.04"
]
},
{
Expand Down
14 changes: 7 additions & 7 deletions spec/classes/php_fpm_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# rubocop:disable RSpec/RepeatedExample
case facts[:osfamily]
when 'Debian'
it { is_expected.to contain_service('php5-fpm').with_ensure('running') }
if facts[:operatingsystem] == 'Ubuntu'
if facts[:operatingsystemrelease] == '12.04'
it { is_expected.to contain_service('php5-fpm').without_restart }
else
it { is_expected.to contain_service('php5-fpm').with_restart('service php5-fpm reload') }
end
case facts[:operatingsystemrelease]
when '12.04'
it { is_expected.to contain_service('php5-fpm').with_ensure('running').without_restart }
when '14.04'
it { is_expected.to contain_service('php5-fpm').with_restart('service php5-fpm reload').with_ensure('running') }
when '16.04'
it { is_expected.to contain_service('php7.0-fpm').with_ensure('running') }
end
when 'Suse'
it { is_expected.to contain_service('php-fpm').with_ensure('running') }
Expand Down
20 changes: 12 additions & 8 deletions spec/classes/php_fpm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@
# rubocop:disable RSpec/RepeatedExample
case facts[:osfamily]
when 'Debian'
it { is_expected.to contain_package('php5-fpm').with_ensure('present') }
it { is_expected.to contain_service('php5-fpm').with_ensure('running') }
if facts[:operatingsystem] == 'Ubuntu'
if facts[:operatingsystemrelease] == '14.04'
it { is_expected.to contain_file('/etc/init/php5-fpm.override').with_content('reload signal USR2') }
else
it { is_expected.to contain_file('/etc/init/php5-fpm.override').with_content("reload signal USR2\nmanual") }
end
case facts[:operatingsystemrelease]
when '14.04'
it { is_expected.to contain_file('/etc/init/php5-fpm.override').with_content('reload signal USR2') }
it { is_expected.to contain_package('php5-fpm').with_ensure('present') }
it { is_expected.to contain_service('php5-fpm').with_ensure('running') }
when '12.02'
it { is_expected.to contain_file('/etc/init/php5-fpm.override').with_content("reload signal USR2\nmanual") }
it { is_expected.to contain_package('php5-fpm').with_ensure('present') }
it { is_expected.to contain_service('php5-fpm').with_ensure('running') }
when '16.04'
it { is_expected.to contain_package('php7.0-fpm').with_ensure('present') }
it { is_expected.to contain_service('php7.0-fpm').with_ensure('running') }
end
when 'Suse'
it { is_expected.to contain_package('php5-fpm').with_ensure('present') }
Expand Down
27 changes: 22 additions & 5 deletions spec/classes/php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@
when 'Debian'
it { is_expected.not_to contain_class('php::global') }
it { is_expected.to contain_class('php::fpm') }
it { is_expected.to contain_package('php5-cli').with_ensure('present') }
it { is_expected.to contain_package('php5-fpm').with_ensure('present') }
it { is_expected.to contain_package('php5-dev').with_ensure('present') }
it { is_expected.to contain_package('php-pear').with_ensure('present') }
it { is_expected.to contain_class('php::composer') }
case facts[:os]['release']['major']
when '14.04'
it { is_expected.to contain_package('php5-cli').with_ensure('present') }
it { is_expected.to contain_package('php5-fpm').with_ensure('present') }
it { is_expected.to contain_package('php5-dev').with_ensure('present') }
when '16.04'
it { is_expected.to contain_package('php7.0-cli').with_ensure('present') }
it { is_expected.to contain_package('php7.0-fpm').with_ensure('present') }
it { is_expected.to contain_package('php7.0-dev').with_ensure('present') }
end
when 'Suse'
it { is_expected.to contain_class('php::global') }
it { is_expected.to contain_package('php5').with_ensure('present') }
Expand Down Expand Up @@ -59,7 +66,12 @@

dstfile = case facts[:osfamily]
when 'Debian'
'/etc/php5/fpm/pool.d/www.conf'
case facts[:os]['release']['major']
when '16.04'
'/etc/php/7.0/fpm/pool.d/www.conf'
else
'/etc/php5/fpm/pool.d/www.conf'
end
when 'Archlinux'
'/etc/php/php-fpm.d/www.conf'
when 'Suse'
Expand All @@ -79,7 +91,12 @@
it { is_expected.to contain_php__fpm__pool('www').with(group: 'nginx') }
dstfile = case facts[:osfamily]
when 'Debian'
'/etc/php5/fpm/pool.d/www.conf'
case facts[:os]['release']['major']
when '16.04'
'/etc/php/7.0/fpm/pool.d/www.conf'
else
'/etc/php5/fpm/pool.d/www.conf'
end
when 'Archlinux'
'/etc/php/php-fpm.d/www.conf'
when 'Suse'
Expand Down
7 changes: 6 additions & 1 deletion spec/defines/extension_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
unless facts[:osfamily] == 'Suse' || facts[:osfamily] == 'FreeBSD' # FIXME: something is wrong on these
etcdir = case facts[:osfamily]
when 'Debian'
'/etc/php5/mods-available'
case facts[:os]['release']['major']
when '16.04'
'/etc/php/7.0/mods-available'
else
'/etc/php5/mods-available'
end
when 'Archlinux'
'/etc/php/conf.d'
else
Expand Down
7 changes: 6 additions & 1 deletion spec/defines/fpm_pool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
let(:title) { 'unique-name' }
let(:params) { {} }

it { is_expected.to contain_file('/etc/php5/fpm/pool.d/unique-name.conf') }
case facts[:os]['release']['major']
when '14.04'
it { is_expected.to contain_file('/etc/php5/fpm/pool.d/unique-name.conf') }
when '16.04'
it { is_expected.to contain_file('/etc/php/7.0/fpm/pool.d/unique-name.conf') }
end
end
when 'Debian'
context 'plain config' do
Expand Down

0 comments on commit 0ad7566

Please sign in to comment.