Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OS fact comparison for Ubuntu 12 and 14 #375

Merged
merged 1 commit into from
Aug 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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