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 #90 by hard-restarting postfix on configuration changes #94

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions manifests/params.pp
Expand Up @@ -8,8 +8,8 @@
}

$restart_cmd = $::operatingsystemmajrelease ? {
'7' => '/bin/systemctl reload postfix',
default => '/etc/init.d/postfix reload',
'7' => '/bin/systemctl restart postfix',
default => '/etc/init.d/postfix restart',
}

$mailx_package = 'mailx'
Expand All @@ -20,7 +20,7 @@
'Debian': {
$seltype = undef

$restart_cmd = '/etc/init.d/postfix reload'
$restart_cmd = '/etc/init.d/postfix restart'

$mailx_package = $::lsbdistcodename ? {
/sarge|etch|lenny/ => 'mailx',
Expand All @@ -33,7 +33,7 @@
'Suse': {
$seltype = undef

$restart_cmd = '/etc/init.d/postfix reload'
$restart_cmd = '/etc/init.d/postfix restart'

$mailx_package = 'mailx'

Expand Down
1 change: 1 addition & 0 deletions spec/acceptance/nodesets/default.yml
26 changes: 26 additions & 0 deletions spec/acceptance/postfix_spec.rb
@@ -0,0 +1,26 @@
require 'spec_helper_acceptance'

describe 'postfix class' do

context 'default parameters' do
# Using puppet_apply as a helper
it 'should work idempotently with no errors' do
pp = <<-EOS
class { 'postfix': }
EOS

# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end

describe package('postfix') do
it { is_expected.to be_installed }
end

describe service('postfix') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
end
end
8 changes: 4 additions & 4 deletions spec/classes/postfix_spec.rb
Expand Up @@ -31,7 +31,7 @@
:ensure => 'running',
:enable => 'true',
:hasstatus => 'true',
:restart => '/etc/init.d/postfix reload'
:restart => '/etc/init.d/postfix restart'
) }
else
it { is_expected.to contain_file('/etc/mailname').with_seltype('postfix_etc_t').with_content("foo.example.com\n") }
Expand All @@ -50,15 +50,15 @@
:ensure => 'running',
:enable => 'true',
:hasstatus => 'true',
:restart => '/bin/systemctl reload postfix'
:restart => '/bin/systemctl restart postfix'
) }
else
it {
is_expected.to contain_service('postfix').with(
:ensure => 'running',
:enable => 'true',
:hasstatus => 'true',
:restart => '/etc/init.d/postfix reload'
:restart => '/etc/init.d/postfix restart'
) }
end
end
Expand Down Expand Up @@ -124,7 +124,7 @@
:ensure => 'running',
:enable => 'true',
:hasstatus => 'true',
:restart => '/etc/init.d/postfix reload'
:restart => '/etc/init.d/postfix restart'
) }
end
else
Expand Down
31 changes: 31 additions & 0 deletions spec/spec_helper_acceptance.rb
@@ -0,0 +1,31 @@
require 'beaker-rspec/spec_helper'
require 'beaker-rspec/helpers/serverspec'

unless ENV['BEAKER_provision'] == 'no'
hosts.each do |host|
# Install Puppet
if host.is_pe?
install_pe
else
install_puppet
end
end
end

RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))

# Readable test descriptions
c.formatter = :documentation

# Configure all nodes in nodeset
c.before :suite do
# Install module and dependencies
puppet_module_install(:source => proj_root, :module_name => 'postfix')
hosts.each do |host|
on host, puppet('module', 'install', 'puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] }
on host, puppet('module', 'install', 'camptocamp-augeas'), { :acceptable_exit_codes => [0,1] }
end
end
end