From 69aceb650b7930a5fb3d91316882ef3729a10ec2 Mon Sep 17 00:00:00 2001 From: Simon Hoenscheid Date: Sun, 22 Apr 2018 23:15:18 +0200 Subject: [PATCH 1/5] added condition to globals.pp to make module working on debian 9. Note: debians php extension prefix naming is inconsistent, some packages have php7.0- others php-. The user needs to solve this by setting package_prefix for the extension added spec tests for debian 9 updated metadata json, closes #439 --- manifests/globals.pp | 4 ++++ metadata.json | 3 ++- spec/classes/php_spec.rb | 8 ++++++++ spec/defines/extension_spec.rb | 2 ++ spec/defines/fpm_pool_spec.rb | 6 +++++- 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/manifests/globals.pp b/manifests/globals.pp index a2fbcf11..f08ec26b 100644 --- a/manifests/globals.pp +++ b/manifests/globals.pp @@ -23,6 +23,10 @@ /^(1[67].04)$/ => '7.0', default => '5.x', }, + 'Debian' => $facts['os']['release']['major'] ? { + '9' => '7.0', + default => '5.x', + }, default => '5.x', }, default => '5.x', diff --git a/metadata.json b/metadata.json index 877592d6..01532502 100644 --- a/metadata.json +++ b/metadata.json @@ -48,7 +48,8 @@ "operatingsystem": "Debian", "operatingsystemrelease": [ "7", - "8" + "8", + "9" ] }, { diff --git a/spec/classes/php_spec.rb b/spec/classes/php_spec.rb index 75f624ce..86e8abaa 100644 --- a/spec/classes/php_spec.rb +++ b/spec/classes/php_spec.rb @@ -23,6 +23,10 @@ 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') } + when '9' + 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') } @@ -69,6 +73,8 @@ case facts[:os]['release']['major'] when '16.04' '/etc/php/7.0/fpm/pool.d/www.conf' + when '9' + '/etc/php/7.0/fpm/pool.d/www.conf' else '/etc/php5/fpm/pool.d/www.conf' end @@ -94,6 +100,8 @@ case facts[:os]['release']['major'] when '16.04' '/etc/php/7.0/fpm/pool.d/www.conf' + when '9' + '/etc/php/7.0/fpm/pool.d/www.conf' else '/etc/php5/fpm/pool.d/www.conf' end diff --git a/spec/defines/extension_spec.rb b/spec/defines/extension_spec.rb index db74f2ff..41afc8da 100644 --- a/spec/defines/extension_spec.rb +++ b/spec/defines/extension_spec.rb @@ -15,6 +15,8 @@ case facts[:os]['release']['major'] when '16.04' '/etc/php/7.0/mods-available' + when '9' + '/etc/php/7.0/mods-available' else '/etc/php5/mods-available' end diff --git a/spec/defines/fpm_pool_spec.rb b/spec/defines/fpm_pool_spec.rb index dc3c5165..c72274b0 100644 --- a/spec/defines/fpm_pool_spec.rb +++ b/spec/defines/fpm_pool_spec.rb @@ -27,8 +27,12 @@ context 'plain config' do let(:title) { 'unique-name' } let(:params) { {} } - + 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 end end end From a76460875f77906cfba35bc52c12f463855cac4c Mon Sep 17 00:00:00 2001 From: Simon Hoenscheid Date: Mon, 23 Apr 2018 01:40:10 +0200 Subject: [PATCH 2/5] fix tests and make rubocop happy --- spec/classes/php_spec.rb | 51 +++++++++++++++++++++++++---------- spec/defines/fpm_pool_spec.rb | 3 ++- 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/spec/classes/php_spec.rb b/spec/classes/php_spec.rb index 86e8abaa..9acce36b 100644 --- a/spec/classes/php_spec.rb +++ b/spec/classes/php_spec.rb @@ -7,6 +7,40 @@ facts end + php_cli_package = case facts[:osfamily] + when 'Debian' + case facts[:os]['release']['major'] + when '16.04' + 'php7.0-cli' + when '9' + 'php7.0-cli' + else + 'php5-cli' + end + end + php_fpm_ackage = case facts[:osfamily] + when 'Debian' + case facts[:os]['release']['major'] + when '16.04' + 'php7.0-fpm' + when '9' + 'php7.0-fpm' + else + 'php5-fpm' + end + end + php_dev_ackage = case facts[:osfamily] + when 'Debian' + case facts[:os]['release']['major'] + when '16.04' + 'php7.0-dev' + when '9' + 'php7.0-dev' + else + 'php5-dev' + end + end + describe 'when called with no parameters' do case facts[:osfamily] when 'Debian' @@ -14,20 +48,9 @@ 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') } - when '9' - 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') } diff --git a/spec/defines/fpm_pool_spec.rb b/spec/defines/fpm_pool_spec.rb index c72274b0..4c5cc557 100644 --- a/spec/defines/fpm_pool_spec.rb +++ b/spec/defines/fpm_pool_spec.rb @@ -27,11 +27,12 @@ context 'plain config' do let(:title) { 'unique-name' } let(:params) { {} } + 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') } + it { is_expected.to contain_file('/etc/php5/fpm/pool.d/unique-name.conf') } end end end From ff519928518f3989a659070056310de2c812bfb8 Mon Sep 17 00:00:00 2001 From: Simon Hoenscheid Date: Fri, 4 May 2018 14:10:43 +0200 Subject: [PATCH 3/5] cleaned up conditions in globals.pp and spec files to seperate Debian and ubuntu more clearly. Also added conditions for Ubuntu 18.04. Be careful with the facter os.distro hash, its not available in older facter versions --- manifests/globals.pp | 18 ++++--- spec/classes/php_spec.rb | 88 +++++++++++++++++++++++++--------- spec/defines/extension_spec.rb | 37 ++++++++------ spec/defines/fpm_pool_spec.rb | 43 ++++++++--------- 4 files changed, 116 insertions(+), 70 deletions(-) diff --git a/manifests/globals.pp b/manifests/globals.pp index f08ec26b..522a7b41 100644 --- a/manifests/globals.pp +++ b/manifests/globals.pp @@ -17,16 +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', - }, - 'Debian' => $facts['os']['release']['major'] ? { - '9' => '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', diff --git a/spec/classes/php_spec.rb b/spec/classes/php_spec.rb index 9acce36b..7f739e53 100644 --- a/spec/classes/php_spec.rb +++ b/spec/classes/php_spec.rb @@ -7,38 +7,59 @@ facts end - php_cli_package = case facts[:osfamily] + php_cli_package = case facts[:os]['name'] when 'Debian' case facts[:os]['release']['major'] - when '16.04' - 'php7.0-cli' 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[:osfamily] + php_fpm_ackage = case facts[:os]['name'] when 'Debian' case facts[:os]['release']['major'] - when '16.04' - 'php7.0-fpm' 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[:osfamily] + php_dev_ackage = case facts[:os]['name'] when 'Debian' case facts[:os]['release']['major'] - when '16.04' - 'php7.0-dev' 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 @@ -93,13 +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' - when '9' - '/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' @@ -118,15 +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' - when '9' - '/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' diff --git a/spec/defines/extension_spec.rb b/spec/defines/extension_spec.rb index 41afc8da..ea8310c5 100644 --- a/spec/defines/extension_spec.rb +++ b/spec/defines/extension_spec.rb @@ -10,21 +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' - when '9' - '/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' } diff --git a/spec/defines/fpm_pool_spec.rb b/spec/defines/fpm_pool_spec.rb index 4c5cc557..8cb30d32 100644 --- a/spec/defines/fpm_pool_spec.rb +++ b/spec/defines/fpm_pool_spec.rb @@ -8,32 +8,31 @@ 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 '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 + 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 end From 3473a55d8445f1dbe50ad32817ecbec59ce1ac9b Mon Sep 17 00:00:00 2001 From: Simon Hoenscheid Date: Fri, 4 May 2018 14:40:39 +0200 Subject: [PATCH 4/5] added acceptence tests for debian 9 and added travis job --- .travis.yml | 7 +++++++ spec/acceptance/php_spec.rb | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 124d7af6..08b4344f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/spec/acceptance/php_spec.rb b/spec/acceptance/php_spec.rb index 36bc845b..c3857428 100644 --- a/spec/acceptance/php_spec.rb +++ b/spec/acceptance/php_spec.rb @@ -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 } From 4761871b055e0dede3f09f995e328a95eac51cc1 Mon Sep 17 00:00:00 2001 From: Simon Hoenscheid Date: Fri, 4 May 2018 17:03:16 +0200 Subject: [PATCH 5/5] fix debian build in this PR too --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 08b4344f..387e3758 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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