Skip to content

Commit

Permalink
Merge pull request #375 from dbeckham/fix_os_version_comparison
Browse files Browse the repository at this point in the history
Fix OS fact comparison for Ubuntu 12 and 14
  • Loading branch information
alexjfisher authored Aug 11, 2017
2 parents ee5534e + 192fd21 commit 91a42b9
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
4 changes: 3 additions & 1 deletion manifests/fpm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
4 changes: 3 additions & 1 deletion manifests/fpm/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions spec/classes/php_fpm_service_spec.rb
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions spec/classes/php_fpm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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') }
Expand Down

0 comments on commit 91a42b9

Please sign in to comment.