Skip to content

Commit

Permalink
Merge pull request #440 from SimonHoenscheid/debian_9_support
Browse files Browse the repository at this point in the history
Add Debian 9 support
  • Loading branch information
bastelfreak committed May 5, 2018
2 parents 48f3386 + 4761871 commit 0f49c99
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 58 deletions.
9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ matrix:
- rvm: 2.4.3
bundler_args: --without development release
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/debian-8
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/debian-7
script: 'bundle exec rspec spec/acceptance/php56_spec.rb'
services: docker
sudo: require
Expand Down Expand Up @@ -81,6 +81,13 @@ matrix:
script: 'bundle exec rspec spec/acceptance/php_spec.rb'
services: docker
sudo: require
- rvm: 2.4.3
bundler_args: --without development release
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/debian-9
script: 'bundle exec rspec spec/acceptance/php_spec.rb'
services: docker
sudo: require
branches:
only:
- master
Expand Down
14 changes: 8 additions & 6 deletions manifests/globals.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
Optional[Stdlib::Absolutepath] $fpm_pid_file = undef,
) {

$default_php_version = $facts['os']['family'] ? {
'Debian' => $facts['os']['name'] ? {
'Ubuntu' => $facts['os']['release']['full'] ? {
/^(1[67].04)$/ => '7.0',
default => '5.x',
},
$default_php_version = $facts['os']['name'] ? {
'Debian' => $facts['os']['release']['major'] ? {
'9' => '7.0',
default => '5.x',
},
'Ubuntu' => $facts['os']['release']['major'] ? {
'18.04' => '7.2',
'16.04' => '7.0',
default => '5.x',
},
default => '5.x',
Expand Down
3 changes: 2 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"operatingsystem": "Debian",
"operatingsystemrelease": [
"7",
"8"
"8",
"9"
]
},
{
Expand Down
4 changes: 3 additions & 1 deletion spec/acceptance/php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
packagename = 'php5-fpm'
when %r{el}
packagename = 'php-fpm'
when %r{debian}
when %r{debian-8}
packagename = 'php5-fpm'
when %r{debian-9}
packagename = 'php7.0-fpm'
end
describe package(packagename) do
it { is_expected.to be_installed }
Expand Down
113 changes: 93 additions & 20 deletions spec/classes/php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,71 @@
facts
end

php_cli_package = case facts[:os]['name']
when 'Debian'
case facts[:os]['release']['major']
when '9'
'php7.0-cli'
else
'php5-cli'
end
when 'Ubuntu'
case facts[:os]['release']['major']
when '18.04'
'php7.2-cli'
when '16.04'
'php7.0-cli'
else
'php5-cli'
end
end
php_fpm_ackage = case facts[:os]['name']
when 'Debian'
case facts[:os]['release']['major']
when '9'
'php7.0-fpm'
else
'php5-fpm'
end
when 'Ubuntu'
case facts[:os]['release']['major']
when '18.04'
'php7.2-fpm'
when '16.04'
'php7.0-fpm'
else
'php5-fpm'
end
end
php_dev_ackage = case facts[:os]['name']
when 'Debian'
case facts[:os]['release']['major']
when '9'
'php7.0-dev'
else
'php5-dev'
end
when 'Ubuntu'
case facts[:os]['release']['major']
when '18.04'
'php7.2-dev'
when '16.04'
'php7.0-dev'
else
'php5-dev'
end
end

describe 'when called with no parameters' do
case facts[:osfamily]
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('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
it { is_expected.to contain_package(php_cli_package).with_ensure('present') }
it { is_expected.to contain_package(php_fpm_ackage).with_ensure('present') }
it { is_expected.to contain_package(php_dev_ackage).with_ensure('present') }
when 'Suse'
it { is_expected.to contain_class('php::global') }
it { is_expected.to contain_package('php5').with_ensure('present') }
Expand Down Expand Up @@ -66,11 +114,23 @@

dstfile = case facts[:osfamily]
when 'Debian'
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'
case facts[:os]['name']
when 'Debian'
case facts[:os]['release']['major']
when '9'
'/etc/php/7.0/fpm/pool.d/www.conf'
else
'/etc/php5/fpm/pool.d/www.conf'
end
when 'Ubuntu'
case facts[:os]['release']['major']
when '18.04'
'/etc/php/7.2/fpm/pool.d/www.conf'
when '16.04'
'/etc/php/7.0/fpm/pool.d/www.conf'
else
'/etc/php5/fpm/pool.d/www.conf'
end
end
when 'Archlinux'
'/etc/php/php-fpm.d/www.conf'
Expand All @@ -89,13 +149,26 @@

it { is_expected.to contain_class('php::fpm').with(group: 'nginx') }
it { is_expected.to contain_php__fpm__pool('www').with(group: 'nginx') }

dstfile = case facts[:osfamily]
when 'Debian'
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'
case facts[:os]['name']
when 'Debian'
case facts[:os]['release']['major']
when '9'
'/etc/php/7.0/fpm/pool.d/www.conf'
else
'/etc/php5/fpm/pool.d/www.conf'
end
when 'Ubuntu'
case facts[:os]['release']['major']
when '18.04'
'/etc/php/7.2/fpm/pool.d/www.conf'
when '16.04'
'/etc/php/7.0/fpm/pool.d/www.conf'
else
'/etc/php5/fpm/pool.d/www.conf'
end
end
when 'Archlinux'
'/etc/php/php-fpm.d/www.conf'
Expand Down
35 changes: 22 additions & 13 deletions spec/defines/extension_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,28 @@
let(:pre_condition) { 'include php' }

unless facts[:osfamily] == 'Suse' || facts[:osfamily] == 'FreeBSD' # FIXME: something is wrong on these
etcdir = case facts[:osfamily]
when 'Debian'
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
'/etc/php.d'
end
etcdir = case facts[:os]['name']
when 'Debian'
case facts[:os]['release']['major']
when '9'
'/etc/php/7.0/mods-available'
else
'/etc/php5/mods-available'
end
when 'Ubuntu'
case facts[:os]['release']['major']
when '18.04'
'/etc/php/7.0/mods-available'
when '16.04'
'/etc/php/7.0/mods-available'
else
'/etc/php5/mods-available'
end
when 'Archlinux'
'/etc/php/conf.d'
else
'/etc/php.d'
end

context 'installation from repository' do
let(:title) { 'json' }
Expand Down
36 changes: 20 additions & 16 deletions spec/defines/fpm_pool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,30 @@
end
let(:pre_condition) { 'include php' }

case facts[:osfamily]
case facts[:os]['name']
when 'Debian'
case facts[:operatingsystem]
when 'Ubuntu'
context 'plain config' do
let(:title) { 'unique-name' }
let(:params) { {} }
context 'plain config' do
let(:title) { 'unique-name' }
let(:params) { {} }

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
case facts[:os]['release']['major']
when '9'
it { is_expected.to contain_file('/etc/php/7.0/fpm/pool.d/unique-name.conf') }
else
it { is_expected.to contain_file('/etc/php5/fpm/pool.d/unique-name.conf') }
end
when 'Debian'
context 'plain config' do
let(:title) { 'unique-name' }
let(:params) { {} }
end
when 'Ubuntu'
context 'plain config' do
let(:title) { 'unique-name' }
let(:params) { {} }

case facts[:os]['release']['major']
when '18.04'
it { is_expected.to contain_file('/etc/php/7.2/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') }
else
it { is_expected.to contain_file('/etc/php5/fpm/pool.d/unique-name.conf') }
end
end
Expand Down

0 comments on commit 0f49c99

Please sign in to comment.