diff --git a/manifests/fpm.pp b/manifests/fpm.pp index 99203902..7df16cae 100644 --- a/manifests/fpm.pp +++ b/manifests/fpm.pp @@ -98,7 +98,9 @@ # Create an override to use a reload signal as trusty and utopic's # upstart version supports this - if $facts['os']['name'] == 'Ubuntu' and ($facts['os']['release']['major'] == '14') { + if ($facts['os']['name'] == 'Ubuntu' + and versioncmp($facts['os']['release']['full'], '14') >= 0 + and versioncmp($facts['os']['release']['full'], '16') < 0) { if ($service_enable) { $fpm_override = 'reload signal USR2' } diff --git a/manifests/fpm/service.pp b/manifests/fpm/service.pp index e08d1e22..d9748a4d 100644 --- a/manifests/fpm/service.pp +++ b/manifests/fpm/service.pp @@ -27,7 +27,9 @@ $reload = "service ${service_name} reload" - if $facts['os']['name'] == 'Ubuntu' and $facts['os']['release']['major'] == '12' { + if ($facts['os']['name'] == 'Ubuntu' + and versioncmp($facts['os']['release']['full'], '12') >= 0 + and versioncmp($facts['os']['release']['full'], '14') < 0) { # Precise upstart doesn't support reload signals, so use # regular service restart instead $restart = undef diff --git a/spec/classes/php_fpm_service_spec.rb b/spec/classes/php_fpm_service_spec.rb new file mode 100644 index 00000000..1bc45d74 --- /dev/null +++ b/spec/classes/php_fpm_service_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper' + +describe 'php::fpm::service', type: :class do + on_supported_os.each do |os, facts| + context "on #{os}" do + let :facts do + facts + end + + let(:pre_condition) { 'class {"php": fpm => true}' } + + describe 'when called with no parameters' do + # 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 + end + when 'Suse' + it { is_expected.to contain_service('php-fpm').with_ensure('running') } + when 'FreeBSD' + it { is_expected.to contain_service('php-fpm').with_ensure('running') } + else + it { is_expected.to contain_service('php-fpm').with_ensure('running') } + end + end + end + end +end diff --git a/spec/classes/php_fpm_spec.rb b/spec/classes/php_fpm_spec.rb index e9682f9c..37737eb3 100644 --- a/spec/classes/php_fpm_spec.rb +++ b/spec/classes/php_fpm_spec.rb @@ -14,6 +14,13 @@ 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 + end when 'Suse' it { is_expected.to contain_package('php5-fpm').with_ensure('present') } it { is_expected.to contain_service('php-fpm').with_ensure('running') }