From 3763f1844ae54441d8958429256a3df4a71731c8 Mon Sep 17 00:00:00 2001 From: robruma Date: Sun, 14 Dec 2014 00:27:41 -0500 Subject: [PATCH 01/38] Removing lucid from mailx_package selector --- manifests/params.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index dde5339d..624a40cf 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -16,8 +16,8 @@ $seltype = undef $mailx_package = $::lsbdistcodename ? { - /sarge|etch|lenny|lucid/ => 'mailx', - default => 'bsd-mailx', + /sarge|etch|lenny/ => 'mailx', + default => 'bsd-mailx', } $master_os_template = "${module_name}/master.cf.debian.erb" From 17d424fa49441953827997dfcc647c2d4ff10512 Mon Sep 17 00:00:00 2001 From: dotmaster Date: Fri, 23 Jan 2015 19:04:12 +0100 Subject: [PATCH 02/38] Update service.pp Pls update this, cause otherwise it will fail on CentOS 7/RHEL7, cuse the file /etc/init.d/postfix doesn`t exist there anymore. --- manifests/service.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/service.pp b/manifests/service.pp index c3f185da..c9bc28bb 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -3,6 +3,6 @@ ensure => running, enable => true, hasstatus => true, - restart => '/etc/init.d/postfix reload', + restart => 'service postfix reload', } } From c0d887da57163fcf4d1c2d4508876d5e8bcecc33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 4 Feb 2015 10:31:01 +0100 Subject: [PATCH 03/38] Add puppet-lint-leading_zero-check gem --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index f1bdbfc8..c9823f6b 100644 --- a/Gemfile +++ b/Gemfile @@ -11,6 +11,7 @@ group :development, :unit_tests do gem 'puppet-lint-variable_contains_upcase', :require => false gem 'puppet-lint-absolute_classname-check', :require => false gem 'puppet-lint-undef_in_function-check', :require => false + gem 'puppet-lint-leading_zero-check', :require => false gem 'simplecov', :require => false gem 'rspec-puppet-facts', :require => false gem 'json', :require => false From 509405a55706df011095cc183ce23dea3276d565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Can=C3=A9vet?= Date: Wed, 4 Feb 2015 11:03:54 +0100 Subject: [PATCH 04/38] Update with modulesync --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index c9823f6b..3190b060 100644 --- a/Gemfile +++ b/Gemfile @@ -2,9 +2,9 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" group :development, :unit_tests do gem 'rake', :require => false - gem 'rspec-puppet', :require => false, :git => 'https://github.com/camptocamp/rspec-puppet.git', :branch => 'rspec3' + gem 'rspec-puppet', '~> 2.0', :require => false gem 'puppetlabs_spec_helper', :require => false - gem 'puppet-lint', '~> 1.0.0', :require => false + gem 'puppet-lint', :require => false gem 'puppet-lint-unquoted_string-check', :require => false gem 'puppet-lint-empty_string-check', :require => false gem 'puppet-lint-spaceship_operator_without_tag-check', :require => false From a560b894dcd54430c9bd1d9879d7eb2c3e935b99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Can=C3=A9vet?= Date: Fri, 6 Feb 2015 12:00:29 +0100 Subject: [PATCH 05/38] Clear lint rake task --- Rakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Rakefile b/Rakefile index a81b2c6f..a334275d 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,7 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' +Rake::Task[:lint].clear PuppetLint.configuration.fail_on_warnings PuppetLint.configuration.send('relative') PuppetLint.configuration.send('disable_80chars') From cd880c1174b48112afc330731211fb24c4c0abd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Can=C3=A9vet?= Date: Fri, 6 Feb 2015 13:29:30 +0100 Subject: [PATCH 06/38] [ci skip] Fix hostname in nodesets --- spec/acceptance/nodesets/centos-7-x86_64-docker.yml | 2 +- spec/acceptance/nodesets/centos-7-x86_64-openstack.yml | 2 +- spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml | 2 +- spec/acceptance/nodesets/debian-6-x86_64-docker.yml | 2 +- spec/acceptance/nodesets/debian-7-x86_64-docker.yml | 2 +- spec/acceptance/nodesets/debian-7-x86_64-openstack.yml | 2 +- spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml | 2 +- spec/acceptance/nodesets/debian-8-x86_64-docker.yml | 2 +- spec/acceptance/nodesets/debian-8-x86_64-openstack.yml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/acceptance/nodesets/centos-7-x86_64-docker.yml b/spec/acceptance/nodesets/centos-7-x86_64-docker.yml index 6eb5641a..599a681f 100644 --- a/spec/acceptance/nodesets/centos-7-x86_64-docker.yml +++ b/spec/acceptance/nodesets/centos-7-x86_64-docker.yml @@ -1,5 +1,5 @@ HOSTS: - centos-7-x86_64: + centos-7-x64: default_apply_opts: strict_variables: platform: el-7-x86_64 diff --git a/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml b/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml index 69d1bfc0..37dfc5f9 100644 --- a/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml +++ b/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml @@ -1,5 +1,5 @@ HOSTS: - centos-7-x86_64: + centos-7-x64: default_apply_opts: strict_variables: platform: el-7-x86_64 diff --git a/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml b/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml index d4794280..a9c461ba 100644 --- a/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml +++ b/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml @@ -1,5 +1,5 @@ HOSTS: - centos-7-x86_64: + centos-7-x64: default_apply_opts: strict_variables: platform: el-7-x86_64 diff --git a/spec/acceptance/nodesets/debian-6-x86_64-docker.yml b/spec/acceptance/nodesets/debian-6-x86_64-docker.yml index b6cf1e6d..0296d129 100644 --- a/spec/acceptance/nodesets/debian-6-x86_64-docker.yml +++ b/spec/acceptance/nodesets/debian-6-x86_64-docker.yml @@ -1,5 +1,5 @@ HOSTS: - debian-6-x86_64: + debian-6-x64: default_apply_opts: strict_variables: platform: debian-6-amd64 diff --git a/spec/acceptance/nodesets/debian-7-x86_64-docker.yml b/spec/acceptance/nodesets/debian-7-x86_64-docker.yml index e7b916bc..ef1c9b22 100644 --- a/spec/acceptance/nodesets/debian-7-x86_64-docker.yml +++ b/spec/acceptance/nodesets/debian-7-x86_64-docker.yml @@ -1,5 +1,5 @@ HOSTS: - debian-7-x86_64: + debian-7-x64: default_apply_opts: strict_variables: platform: debian-7-amd64 diff --git a/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml b/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml index 0643d036..e52336be 100644 --- a/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml +++ b/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml @@ -1,5 +1,5 @@ HOSTS: - debian-7-x86_64: + debian-7-x64: default_apply_opts: strict_variables: platform: debian-7-amd64 diff --git a/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml index 30f31ad9..97099de3 100644 --- a/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml +++ b/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml @@ -1,5 +1,5 @@ HOSTS: - debian-7-x86_64: + debian-7-x64: default_apply_opts: strict_variables: platform: debian-7-amd64 diff --git a/spec/acceptance/nodesets/debian-8-x86_64-docker.yml b/spec/acceptance/nodesets/debian-8-x86_64-docker.yml index ef99efb9..28c3e02f 100644 --- a/spec/acceptance/nodesets/debian-8-x86_64-docker.yml +++ b/spec/acceptance/nodesets/debian-8-x86_64-docker.yml @@ -1,5 +1,5 @@ HOSTS: - debian-8-x86_64: + debian-8-x64: default_apply_opts: strict_variables: platform: debian-8-amd64 diff --git a/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml b/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml index 1cc9c6d8..194ca460 100644 --- a/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml +++ b/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml @@ -1,5 +1,5 @@ HOSTS: - debian-8-x86_64: + debian-8-x64: default_apply_opts: strict_variables: platform: debian-8-amd64 From 89055a9946536edd1c010a1450217f1ced4ca8cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Tue, 10 Feb 2015 11:29:25 +0100 Subject: [PATCH 07/38] Modulesync --- Gemfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 3190b060..f0887eca 100644 --- a/Gemfile +++ b/Gemfile @@ -12,14 +12,17 @@ group :development, :unit_tests do gem 'puppet-lint-absolute_classname-check', :require => false gem 'puppet-lint-undef_in_function-check', :require => false gem 'puppet-lint-leading_zero-check', :require => false + gem 'puppet-lint-trailing_comma-check', :require => false + gem 'puppet-lint-file_ensure-check', :require => false gem 'simplecov', :require => false gem 'rspec-puppet-facts', :require => false gem 'json', :require => false gem 'metadata-json-lint', :require => false + gem 'docker-api', '1.15.0', :require => false end group :system_tests do - gem 'beaker', :require => false, :git => 'https://github.com/mcanevet/beaker', :branch => 'openstack' + gem 'beaker', :require => false, :git => 'https://github.com/raphink/beaker', :branch => 'openstack' gem 'beaker-rspec', :require => false gem 'serverspec', :require => false end From b9fe74dad89bd8703f31a6c60f97335e769bd9f7 Mon Sep 17 00:00:00 2001 From: Ben Hocker Date: Wed, 11 Feb 2015 08:26:53 -0600 Subject: [PATCH 08/38] Resolves issue #55 - Adding tests for ldap.pp - Only install postfix-ldap package on Debian based --- manifests/ldap.pp | 8 +++--- spec/classes/postfix_spec.rb | 52 +++++++++++++++++++++++++++++++++--- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/manifests/ldap.pp b/manifests/ldap.pp index d6c40be1..dbc9fd08 100644 --- a/manifests/ldap.pp +++ b/manifests/ldap.pp @@ -14,8 +14,10 @@ # include postfix::ldap # class postfix::ldap { - - package {'postfix-ldap': } + case $::osfamily { + 'debian': { package {'postfix-ldap': } } + default: {} + } if ! $postfix::ldap_base { fail 'Missing $postfix::ldap_base !' @@ -36,6 +38,6 @@ owner => 'root', group => 'postfix', content => template('postfix/postfix-ldap-aliases.cf.erb'), - require => Package['postfix-ldap'], + #TODO: Figure out if should have require package here } } diff --git a/spec/classes/postfix_spec.rb b/spec/classes/postfix_spec.rb index f5e684f4..e5fe635c 100644 --- a/spec/classes/postfix_spec.rb +++ b/spec/classes/postfix_spec.rb @@ -37,6 +37,7 @@ context 'when on RedHat' do let (:facts) { { + :lsbdistcodename => 'Maipo', :fqdn => 'fqdn.example.com', :operatingsystem => 'RedHat', :operatingsystemmajrelease => '7', @@ -162,8 +163,53 @@ end end context 'when enabling ldap' do - it 'should do stuff' do - skip 'need to write this still' + context 'when on Debian' do + let (:params) { { + :ldap => true, + :ldap_base => 'dc=example,dc=com', + :ldap_host => 'host.example.com', + } } + + let (:facts) { { + :operatingsystem => 'Debian', + :osfamily => 'Debian', + :fqdn => 'fqdn.example.com', + :lsbdistcodename => 'wheezy', + } } + + it { should contain_package('postfix-ldap') } + + it { should contain_file('/etc/postfix/ldap-aliases.cf').with( + :owner => 'root', + :group => 'postfix' ).with_content(/search_base = /) + } + end + + context 'when on RedHat' do + let (:params) { { + :ldap => true, + :ldap_base => 'dc=example,dc=com', + :ldap_host => 'host.example.com', + } } + + let (:facts) { { + :operatingsystem => 'RedHat', + :osfamily => 'RedHat', + :operatingsystemmajrelease => '7', + :lsbdistcodename => 'Maipo', + :fqdn => 'fqdn.example.com', + } } + + it do + expect { + should_not contain_package('postfix-ldap') + } + end + + it { should contain_file('/etc/postfix/ldap-aliases.cf').with( + :owner => 'root', + :group => 'postfix').with_content(/search_base = /) + } end end context 'when a custom mail_user is specified' do @@ -195,7 +241,7 @@ :master_smtp => "smtp inet n - - - - smtpd -o smtpd_client_restrictions=check_client_access,hash:/etc/postfix/access,reject", } } - it 'should update master.cf with the specified flags to smtp' do + it 'should update master.cf with the specified flags to smtp' do is_expected.to contain_file('/etc/postfix/master.cf').without('seltype').with_content( /smtp inet n - - - - smtpd/).with_content( /^smtp.*\n.*smtpd_client_restrictions=check_client_access,hash:/ From 9057ca22d7b5addea07ec88ed2ac7fe8fed0fd1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Can=C3=A9vet?= Date: Wed, 18 Feb 2015 09:15:15 +0100 Subject: [PATCH 09/38] Fix puppet-lint configuration --- Rakefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Rakefile b/Rakefile index a334275d..f0f08fcc 100644 --- a/Rakefile +++ b/Rakefile @@ -2,10 +2,11 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' Rake::Task[:lint].clear -PuppetLint.configuration.fail_on_warnings -PuppetLint.configuration.send('relative') -PuppetLint.configuration.send('disable_80chars') -PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp", "vendor/**/*.pp"] +PuppetLint::RakeTask.new :lint do |config| + config.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp", "vendor/**/*.pp"] + config.disable_checks = ['80chars'] + config.fail_on_warnings = true +end PuppetSyntax.exclude_paths = ["spec/fixtures/**/*.pp", "vendor/**/*"] From 0475b2e67c2502ae83f7a1f316ace374e6ebb975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Thu, 19 Feb 2015 11:59:38 +0100 Subject: [PATCH 10/38] Add puppet-lint-version_comparison-check gem --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index f0887eca..09b902f5 100644 --- a/Gemfile +++ b/Gemfile @@ -14,6 +14,7 @@ group :development, :unit_tests do gem 'puppet-lint-leading_zero-check', :require => false gem 'puppet-lint-trailing_comma-check', :require => false gem 'puppet-lint-file_ensure-check', :require => false + gem 'puppet-lint-version_comparison-check', :require => false gem 'simplecov', :require => false gem 'rspec-puppet-facts', :require => false gem 'json', :require => false From b6abe5d418ee71fe795f2a251e43276b0513bc41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Can=C3=A9vet?= Date: Thu, 19 Feb 2015 12:35:37 +0100 Subject: [PATCH 11/38] Use unreleased puppetlabs_spec_helper --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 09b902f5..c7aa4a51 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" group :development, :unit_tests do gem 'rake', :require => false gem 'rspec-puppet', '~> 2.0', :require => false - gem 'puppetlabs_spec_helper', :require => false + gem 'puppetlabs_spec_helper', :require => false, :git => 'https://github.com/puppetlabs/puppetlabs_spec_helper', :branch => 'master' gem 'puppet-lint', :require => false gem 'puppet-lint-unquoted_string-check', :require => false gem 'puppet-lint-empty_string-check', :require => false From b58efdd0fa0a7e4349d51f2a4244a68d4194a076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Can=C3=A9vet?= Date: Thu, 19 Feb 2015 14:11:59 +0100 Subject: [PATCH 12/38] Fix metadata rake task --- Rakefile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Rakefile b/Rakefile index f0f08fcc..f87e6088 100644 --- a/Rakefile +++ b/Rakefile @@ -9,8 +9,3 @@ PuppetLint::RakeTask.new :lint do |config| end PuppetSyntax.exclude_paths = ["spec/fixtures/**/*.pp", "vendor/**/*"] - -desc "Lint metadata.json file" -task :metadata do - sh "metadata-json-lint metadata.json" -end From a9bc4f901c94bf4b538fa671991b1c434d356e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Thu, 19 Feb 2015 17:50:29 +0100 Subject: [PATCH 13/38] Release 1.1.0 --- CHANGELOG.md | 7 +++++++ metadata.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29c65aa9..0f567a40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 2015-02-19 - Release 1.1.0 + +- Various specs improvements +- Fix specs for postfix::config with ensure => blank +- Simplify relationships and avoid spaceship operators +- nexthop parameter is not necessary for postfix::canonical + ## 2015-01-07 - Release 1.0.5 - Fix unquoted strings in cases diff --git a/metadata.json b/metadata.json index 1dcc0576..bef7812b 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "camptocamp-postfix", - "version": "1.0.5", + "version": "1.1.0", "author": "Camptocamp", "summary": "Camptocamp Postfix Module", "license": "Apache-2.0", From c4d9d89b361610c59066ce0f29a96979cde0e362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Can=C3=A9vet?= Date: Tue, 24 Feb 2015 09:37:12 +0100 Subject: [PATCH 14/38] Update with msync --- Gemfile | 8 ++------ spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml | 2 +- spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml | 10 ++++++++++ 3 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml diff --git a/Gemfile b/Gemfile index c7aa4a51..f4364ea1 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" group :development, :unit_tests do gem 'rake', :require => false - gem 'rspec-puppet', '~> 2.0', :require => false + gem 'rspec-puppet', :require => false, :git => 'https://github.com/camptocamp/rspec-puppet', :branch => 'rspec3' gem 'puppetlabs_spec_helper', :require => false, :git => 'https://github.com/puppetlabs/puppetlabs_spec_helper', :branch => 'master' gem 'puppet-lint', :require => false gem 'puppet-lint-unquoted_string-check', :require => false @@ -15,15 +15,11 @@ group :development, :unit_tests do gem 'puppet-lint-trailing_comma-check', :require => false gem 'puppet-lint-file_ensure-check', :require => false gem 'puppet-lint-version_comparison-check', :require => false - gem 'simplecov', :require => false gem 'rspec-puppet-facts', :require => false - gem 'json', :require => false - gem 'metadata-json-lint', :require => false - gem 'docker-api', '1.15.0', :require => false end group :system_tests do - gem 'beaker', :require => false, :git => 'https://github.com/raphink/beaker', :branch => 'openstack' + gem 'beaker', :require => false, :git => 'https://github.com/mcanevet/beaker', :branch => 'openstack' gem 'beaker-rspec', :require => false gem 'serverspec', :require => false end diff --git a/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml b/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml index a9c461ba..6f027690 100644 --- a/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml +++ b/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml @@ -4,7 +4,7 @@ HOSTS: strict_variables: platform: el-7-x86_64 hypervisor : vagrant - box : puppetlabs/centos-6.5-64-nocm + box : camptocamp/centos-7-x86_64 CONFIG: type: foss log_level: debug diff --git a/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml new file mode 100644 index 00000000..71e8194a --- /dev/null +++ b/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml @@ -0,0 +1,10 @@ +HOSTS: + debian-6-x64: + default_apply_opts: + strict_variables: + platform: debian-6-amd64 + hypervisor : vagrant + box : puppetlabs/debian-6.0.9-64-nocm +CONFIG: + type: foss + log_level: debug From d69302c38ae5bbd390ecc589d106dbf65f36a358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Can=C3=A9vet?= Date: Wed, 25 Feb 2015 10:11:26 +0100 Subject: [PATCH 15/38] Use puppetlabs_spec_helper's gem --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index f4364ea1..8d7ba6fd 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" group :development, :unit_tests do gem 'rake', :require => false gem 'rspec-puppet', :require => false, :git => 'https://github.com/camptocamp/rspec-puppet', :branch => 'rspec3' - gem 'puppetlabs_spec_helper', :require => false, :git => 'https://github.com/puppetlabs/puppetlabs_spec_helper', :branch => 'master' + gem 'puppetlabs_spec_helper', :require => false gem 'puppet-lint', :require => false gem 'puppet-lint-unquoted_string-check', :require => false gem 'puppet-lint-empty_string-check', :require => false From 79bddaa09d667f0de4819c89d297158613e55a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Can=C3=A9vet?= Date: Wed, 25 Feb 2015 10:30:07 +0100 Subject: [PATCH 16/38] Add metadata-json-lint to Gemfile --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 8d7ba6fd..6db8c1e4 100644 --- a/Gemfile +++ b/Gemfile @@ -4,6 +4,7 @@ group :development, :unit_tests do gem 'rake', :require => false gem 'rspec-puppet', :require => false, :git => 'https://github.com/camptocamp/rspec-puppet', :branch => 'rspec3' gem 'puppetlabs_spec_helper', :require => false + gem 'metadata-json-lint', :require => false gem 'puppet-lint', :require => false gem 'puppet-lint-unquoted_string-check', :require => false gem 'puppet-lint-empty_string-check', :require => false From 1f688a01666f427571347f8381b4b0317d9dbcc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Can=C3=A9vet?= Date: Wed, 25 Feb 2015 11:15:51 +0100 Subject: [PATCH 17/38] Pin rspec version to 3.1.0 (https://github.com/rspec/rspec-core/issues/1864) --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 6db8c1e4..ad0e31dd 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,7 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" group :development, :unit_tests do gem 'rake', :require => false + gem 'rspec', '~> 3.1.0', :require => false gem 'rspec-puppet', :require => false, :git => 'https://github.com/camptocamp/rspec-puppet', :branch => 'rspec3' gem 'puppetlabs_spec_helper', :require => false gem 'metadata-json-lint', :require => false From daaff52f9c3b1dfcec5c5a63b7589185dd359436 Mon Sep 17 00:00:00 2001 From: Trevor Smith Date: Tue, 3 Mar 2015 19:00:22 -0500 Subject: [PATCH 18/38] add logic to set the restart_cmd variable appropriately for each osfamily and operatingsystemmajrelease for redhat --- manifests/params.pp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/manifests/params.pp b/manifests/params.pp index dde5339d..248719ce 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -7,6 +7,11 @@ default => undef, } + $restart_cmd = $::operatingsystemmajrelease ? { + '7' => '/bin/systemctl reload postfix', + default => '/etc/init.d/postfix reload', + } + $mailx_package = 'mailx' $master_os_template = "${module_name}/master.cf.redhat.erb" @@ -15,6 +20,8 @@ 'Debian': { $seltype = undef + $restart_cmd = '/etc/init.d/postfix reload' + $mailx_package = $::lsbdistcodename ? { /sarge|etch|lenny|lucid/ => 'mailx', default => 'bsd-mailx', @@ -26,6 +33,8 @@ 'Suse': { $seltype = undef + $restart_cmd = '/etc/init.d/postfix reload' + $mailx_package = 'mailx' if $::operatingsystem != 'SLES' { From aae2f6fe54a6bd5f71826d19710467c7ccbe1fe7 Mon Sep 17 00:00:00 2001 From: Trevor Smith Date: Tue, 3 Mar 2015 19:00:43 -0500 Subject: [PATCH 19/38] replace the restart command with the variable from params --- manifests/service.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/service.pp b/manifests/service.pp index c3f185da..9d56cd2e 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -3,6 +3,6 @@ ensure => running, enable => true, hasstatus => true, - restart => '/etc/init.d/postfix reload', + restart => $::postfix::params::restart_cmd, } } From cd2a6f8d0a8807a3f65677b710678e9a491a6ab0 Mon Sep 17 00:00:00 2001 From: Trevor Smith Date: Tue, 3 Mar 2015 19:01:16 -0500 Subject: [PATCH 20/38] fix the test so it checks for the correct restart value for redhat 7 --- spec/classes/postfix_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/classes/postfix_spec.rb b/spec/classes/postfix_spec.rb index f5e684f4..567d1ad2 100644 --- a/spec/classes/postfix_spec.rb +++ b/spec/classes/postfix_spec.rb @@ -67,7 +67,7 @@ :ensure => 'running', :enable => 'true', :hasstatus => 'true', - :restart => '/etc/init.d/postfix reload' + :restart => '/bin/systemctl reload postfix' ) } end end From 9705585ef95ebd47dde091669579870de9c2549e Mon Sep 17 00:00:00 2001 From: ofer Date: Thu, 5 Mar 2015 11:47:57 +0200 Subject: [PATCH 21/38] fix validation for source and content vars --- manifests/hash.pp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/manifests/hash.pp b/manifests/hash.pp index 076f7450..82716697 100644 --- a/manifests/hash.pp +++ b/manifests/hash.pp @@ -31,8 +31,10 @@ include ::postfix::params validate_absolute_path($name) - validate_string($source) - validate_string($content) +# validate_string($source) +# validate_string($content) + if !is_string($source) and !is_array($source) { fail("value for source should be either String type or Array type got ${source}") } + if !is_string($content) and !is_array($content) { fail("value for source should be either String type or Array type got ${content}") } validate_string($ensure) validate_re($ensure, ['present', 'absent'], "\$ensure must be either 'present' or 'absent', got '${ensure}'") From 314b3305a4ea7fc3ab369fb48d9f2d3811f3acc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Can=C3=A9vet?= Date: Thu, 5 Mar 2015 12:46:25 +0100 Subject: [PATCH 22/38] Update beaker pinning as release contains all our patches --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index ad0e31dd..a3a9eca0 100644 --- a/Gemfile +++ b/Gemfile @@ -21,7 +21,7 @@ group :development, :unit_tests do end group :system_tests do - gem 'beaker', :require => false, :git => 'https://github.com/mcanevet/beaker', :branch => 'openstack' + gem 'beaker', :require => false gem 'beaker-rspec', :require => false gem 'serverspec', :require => false end From 5fcb57b8f5af2d3b18b5b4f78bba32f9e9dadc84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Tue, 10 Mar 2015 14:05:56 +0100 Subject: [PATCH 23/38] README includes --- .sync.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.sync.yml b/.sync.yml index ace7fcbc..f87f968e 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,3 +1,5 @@ --- .travis.yml: forge_password: "XAv4O363tng0KuRnu1ZhhwORy+2CF9UQwdwlFmS+NG9jOaTZZN+PMK8iC7OSIvZN6cfKlYjHRHNuxFBnYlnMrLsM9fVxt4NjjznOgIKQpQDleWk4UitZj5ntyHmUtYtofUd5Bhi/sdYXwGN9pVRCrcfFBmsIRq/dOhXD7Wy5KcQ=" +README.md: + include: ['.sync/simple_usage.md', '.sync/classes.md'] From b77a0684e61199845ff659dddff924331d36b201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Tue, 10 Mar 2015 14:06:50 +0100 Subject: [PATCH 24/38] Add .sync --- .sync/classes.md | 24 ++++++++++++++++++++++++ .sync/simple_usage.md | 22 ++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 .sync/classes.md create mode 100644 .sync/simple_usage.md diff --git a/.sync/classes.md b/.sync/classes.md new file mode 100644 index 00000000..1764de09 --- /dev/null +++ b/.sync/classes.md @@ -0,0 +1,24 @@ +## Classes + +### postfix + +The top-level class, to install and configure Postfix. + +## Definitions + +### postfix::config + +Add/alter/remove options in Postfix main configuration file (main.cf) + +### postfix::hash + +Creates Postfix hashed "map" files, and build the corresponding db file. + +### postfix::transport + +Manages content in the transport map. + +### postfix::virtual + +Manages content in the virtual map. + diff --git a/.sync/simple_usage.md b/.sync/simple_usage.md new file mode 100644 index 00000000..34f5e887 --- /dev/null +++ b/.sync/simple_usage.md @@ -0,0 +1,22 @@ +This module requires Augeas. + +## Simple usage + + include postfix + + postfix::config { "relay_domains": value => "localhost host.foo.com" } + +## Exec paths + +In order to not have any path problem, you should add the following line in +some globally included .pp file: + + Exec { + path => '/some/relevant/path:/some/other:...', + } + +For example: + + Exec { + path => '/bin:/sbin:/usr/sbin:/usr/bin', + } From ec47dea02473c33bd937ad859b4de71b88aeb5ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Tue, 10 Mar 2015 14:07:23 +0100 Subject: [PATCH 25/38] Update --- CONTRIBUTING.md | 8 +++++ README.md | 33 ++----------------- .../nodesets/centos-7-x86_64-vagrant.yml | 2 +- .../nodesets/debian-6-x86_64-vagrant.yml | 2 +- .../nodesets/debian-7-x86_64-vagrant.yml | 3 +- .../nodesets/ubuntu-14.04-x86_64-vagrant.yml | 10 ++++++ 6 files changed, 23 insertions(+), 35 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..2c179eb4 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,8 @@ +# How to contribute + +Please report bugs and feature request using [GitHub issue +tracker](https://github.com/camptocamp/puppet-postfix/issues). + +For pull requests, it is very much appreciated to check your Puppet manifest +with [puppet-lint](https://github.com/rodjek/puppet-lint) to follow the recommended Puppet style guidelines from the +[Puppet Labs style guide](http://docs.puppetlabs.com/guides/style_guide.html). diff --git a/README.md b/README.md index 3672aaf3..e4242839 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,7 @@ -# Postfix module for Puppet +# Postfix Puppet Module [![Puppet Forge](http://img.shields.io/puppetforge/v/camptocamp/postfix.svg)](https://forge.puppetlabs.com/camptocamp/postfix) -[![Build Status](https://travis-ci.org/camptocamp/puppet-postfix.png?branch=master)](https://travis-ci.org/camptocamp/puppet-postfix) - -**Manages Postfix configuration.** - -This module is provided by [Camptocamp](http://www.camptocamp.com/) +[![Build Status](https://img.shields.io/travis/camptocamp/puppet-postfix/master.svg)](https://travis-ci.org/camptocamp/puppet-postfix) This module requires Augeas. @@ -54,29 +50,4 @@ Manages content in the transport map. Manages content in the virtual map. -## Contributing - -Please report bugs and feature request using [GitHub issue -tracker](https://github.com/camptocamp/puppet-postfix/issues). - -For pull requests, it is very much appreciated to check your Puppet manifest -with [puppet-lint](https://github.com/camptocamp/puppet-postfix/issues) to follow the recommended Puppet style guidelines from the -[Puppet Labs style guide](http://docs.puppetlabs.com/guides/style_guide.html). - -## License - -Copyright (c) 2013 All rights reserved. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . diff --git a/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml b/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml index 6f027690..fe0f83b8 100644 --- a/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml +++ b/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml @@ -4,7 +4,7 @@ HOSTS: strict_variables: platform: el-7-x86_64 hypervisor : vagrant - box : camptocamp/centos-7-x86_64 + box : puppetlabs/centos-7.0-64-nocm CONFIG: type: foss log_level: debug diff --git a/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml index 71e8194a..23dae1b0 100644 --- a/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml +++ b/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml @@ -4,7 +4,7 @@ HOSTS: strict_variables: platform: debian-6-amd64 hypervisor : vagrant - box : puppetlabs/debian-6.0.9-64-nocm + box : puppetlabs/debian-6.0.10-64-nocm CONFIG: type: foss log_level: debug diff --git a/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml index 97099de3..86c2165d 100644 --- a/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml +++ b/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml @@ -4,8 +4,7 @@ HOSTS: strict_variables: platform: debian-7-amd64 hypervisor : vagrant - box : debian-73-x64-virtualbox-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-nocm.box + box : puppetlabs/debian-7.8-64-nocm CONFIG: type: foss log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml new file mode 100644 index 00000000..a3edb70f --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml @@ -0,0 +1,10 @@ +HOSTS: + ubuntu-14.04-x64: + default_apply_opts: + strict_variables: + platform: ubuntu-14.04-amd64 + hypervisor : vagrant + box : puppetlabs/ubuntu-14.04-64-nocm +CONFIG: + type: foss + log_level: debug From 7ad891b756d605afc9429725ed3dd928937a01f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Can=C3=A9vet?= Date: Tue, 24 Mar 2015 10:03:23 +0100 Subject: [PATCH 26/38] Update .sync.yml --- .sync.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.sync.yml b/.sync.yml index f87f968e..563ac7c2 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,5 +1,5 @@ --- .travis.yml: forge_password: "XAv4O363tng0KuRnu1ZhhwORy+2CF9UQwdwlFmS+NG9jOaTZZN+PMK8iC7OSIvZN6cfKlYjHRHNuxFBnYlnMrLsM9fVxt4NjjznOgIKQpQDleWk4UitZj5ntyHmUtYtofUd5Bhi/sdYXwGN9pVRCrcfFBmsIRq/dOhXD7Wy5KcQ=" -README.md: - include: ['.sync/simple_usage.md', '.sync/classes.md'] +#README.md: +# include: ['.sync/simple_usage.md', '.sync/classes.md'] From d5241eb64ffd34b2dfc0b9dcbf2fa688d6ff3e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Can=C3=A9vet?= Date: Tue, 24 Mar 2015 10:04:52 +0100 Subject: [PATCH 27/38] Update with msync --- Gemfile | 2 +- spec/acceptance/nodesets/centos-7-x86_64-openstack.yml | 2 +- spec/acceptance/nodesets/debian-7-x86_64-openstack.yml | 2 +- spec/acceptance/nodesets/debian-8-x86_64-openstack.yml | 4 ++-- spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml | 10 ++++++++++ 5 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml diff --git a/Gemfile b/Gemfile index a3a9eca0..2cbe1608 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" group :development, :unit_tests do gem 'rake', :require => false gem 'rspec', '~> 3.1.0', :require => false - gem 'rspec-puppet', :require => false, :git => 'https://github.com/camptocamp/rspec-puppet', :branch => 'rspec3' + gem 'rspec-puppet', :require => false gem 'puppetlabs_spec_helper', :require => false gem 'metadata-json-lint', :require => false gem 'puppet-lint', :require => false diff --git a/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml b/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml index 37dfc5f9..2036c0b8 100644 --- a/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml +++ b/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml @@ -4,7 +4,7 @@ HOSTS: strict_variables: platform: el-7-x86_64 hypervisor : openstack - flavor: m1.small + flavor: m1.medium image: centos-7-x86_64-genericcloud-20140929_01 user: centos CONFIG: diff --git a/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml b/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml index e52336be..c44f917e 100644 --- a/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml +++ b/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml @@ -4,7 +4,7 @@ HOSTS: strict_variables: platform: debian-7-amd64 hypervisor : openstack - flavor: m1.small + flavor: m1.medium image: debian-7-amd64-20141121 user: debian CONFIG: diff --git a/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml b/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml index 194ca460..f7b2e500 100644 --- a/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml +++ b/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml @@ -4,10 +4,10 @@ HOSTS: strict_variables: platform: debian-8-amd64 hypervisor : openstack - flavor: m1.small + flavor: m1.medium image: debian-8-amd64-20141121 user: debian CONFIG: type: foss - openstack_network: default log_level: debug + openstack_network: default diff --git a/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml new file mode 100644 index 00000000..38c844be --- /dev/null +++ b/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml @@ -0,0 +1,10 @@ +HOSTS: + debian-8-x64: + default_apply_opts: + strict_variables: + platform: debian-8-amd64 + hypervisor : vagrant + box : camptocamp/debian-8-amd64 +CONFIG: + type: foss + log_level: debug From 60140c1c833c4c06422dacc35d11cfc196bf1926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Tue, 24 Mar 2015 11:24:34 +0100 Subject: [PATCH 28/38] Update README [skip ci] --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e4242839..7ac19f93 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ # Postfix Puppet Module -[![Puppet Forge](http://img.shields.io/puppetforge/v/camptocamp/postfix.svg)](https://forge.puppetlabs.com/camptocamp/postfix) +[![Puppet Forge Version](http://img.shields.io/puppetforge/v/camptocamp/postfix.svg)](https://forge.puppetlabs.com/camptocamp/postfix) +[![Puppet Forge Downloads](http://img.shields.io/puppetforge/dt/camptocamp/postfix.svg)](https://forge.puppetlabs.com/camptocamp/postfix) [![Build Status](https://img.shields.io/travis/camptocamp/puppet-postfix/master.svg)](https://travis-ci.org/camptocamp/puppet-postfix) +[![Gemnasium](https://img.shields.io/gemnasium/camptocamp/puppet-postfix.svg)](https://gemnasium.com/camptocamp/puppet-postfix) +[![By Camptocamp](https://img.shields.io/badge/by-camptocamp-fb7047.svg)](http://www.camptocamp.com) This module requires Augeas. From 55e48b48d6a9787cf0edbc2169194df508f48453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Tue, 24 Mar 2015 11:25:23 +0100 Subject: [PATCH 29/38] Release 1.1.1 --- CHANGELOG.md | 4 ++++ metadata.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f567a40..d4a2ffb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2015-03-24 - Release 1.1.1 + +- Various spec improvements + ## 2015-02-19 - Release 1.1.0 - Various specs improvements diff --git a/metadata.json b/metadata.json index bef7812b..5c0e7bb9 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "camptocamp-postfix", - "version": "1.1.0", + "version": "1.1.1", "author": "Camptocamp", "summary": "Camptocamp Postfix Module", "license": "Apache-2.0", From 12e0ce29aa3b6cdb81c8e1fb080fae0ce687c1c4 Mon Sep 17 00:00:00 2001 From: Erinn Looney-Triggs Date: Wed, 12 Nov 2014 12:55:50 -0800 Subject: [PATCH 30/38] Fix issue with multiple mynetworks. --- manifests/mta.pp | 2 +- spec/classes/postfix_mta_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/mta.pp b/manifests/mta.pp index 7df275eb..b96927d1 100644 --- a/manifests/mta.pp +++ b/manifests/mta.pp @@ -35,7 +35,7 @@ 'Wrong value for $relayhost') validate_re($mydestination, '^\S+(?:,\s*\S+)*$', 'Wrong value for $mydestination') - validate_re($mynetworks, '^\S+$', + validate_re($mynetworks, '^(?:\S+?(?:(?:,\s)|(?:\s))?)*$', 'Wrong value for $mynetworks') # If direct is specified then relayhost should be blank diff --git a/spec/classes/postfix_mta_spec.rb b/spec/classes/postfix_mta_spec.rb index 395beaed..39c01d61 100644 --- a/spec/classes/postfix_mta_spec.rb +++ b/spec/classes/postfix_mta_spec.rb @@ -8,12 +8,12 @@ let :pre_condition do "class { 'postfix': mydestination => 'bar', - mynetworks => 'baz', + mynetworks => '127.0.0.1/8, [::1]/128 ![::2]/128', relayhost => 'foo', }" end it { is_expected.to contain_postfix__config('mydestination').with_value('bar') } - it { is_expected.to contain_postfix__config('mynetworks').with_value('baz') } + it { is_expected.to contain_postfix__config('mynetworks').with_value('127.0.0.1/8, [::1]/128 ![::2]/128') } it { is_expected.to contain_postfix__config('relayhost').with_value('foo') } end From a0958dcf0215370902f3b92634e78186346913d0 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Fri, 6 Mar 2015 14:35:09 +0100 Subject: [PATCH 31/38] Introduce IPv6 supporting defaults for mynetworks --- manifests/init.pp | 2 +- spec/classes/postfix_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index db2a097a..0af6148b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -82,7 +82,7 @@ $master_submission = undef, # postfix_master_submission $mta = false, $mydestination = '$myorigin', # postfix_mydestination - $mynetworks = '127.0.0.0/8', # postfix_mynetworks + $mynetworks = '127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128', # postfix_mynetworks $myorigin = $::fqdn, $relayhost = undef, # postfix_relayhost $root_mail_recipient = 'nobody', # root_mail_recipient diff --git a/spec/classes/postfix_spec.rb b/spec/classes/postfix_spec.rb index f5e684f4..6964e795 100644 --- a/spec/classes/postfix_spec.rb +++ b/spec/classes/postfix_spec.rb @@ -214,7 +214,7 @@ let (:params) { { :mta => true, :mydestination => '1.2.3.4', :relayhost => '2.3.4.5' } } it 'should configure postfix as a minimal MTA, delivering mail to the mydestination param' do is_expected.to contain_postfix__config('mydestination').with_value('1.2.3.4') - is_expected.to contain_postfix__config('mynetworks').with_value('127.0.0.0/8') + is_expected.to contain_postfix__config('mynetworks').with_value('127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128') is_expected.to contain_postfix__config('relayhost').with_value('2.3.4.5') is_expected.to contain_postfix__config('virtual_alias_maps').with_value('hash:/etc/postfix/virtual') is_expected.to contain_postfix__config('transport_maps').with_value('hash:/etc/postfix/transport') @@ -261,7 +261,7 @@ end it 'should configure all local email to be forwarded to $root_mail_recipient delivered through $relayhost' do is_expected.to contain_postfix__config('mydestination').with_value('1.2.3.4') - is_expected.to contain_postfix__config('mynetworks').with_value('127.0.0.0/8') + is_expected.to contain_postfix__config('mynetworks').with_value('127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128') is_expected.to contain_postfix__config('relayhost').with_value('2.3.4.5') is_expected.to contain_postfix__config('virtual_alias_maps').with_value('hash:/etc/postfix/virtual') is_expected.to contain_postfix__config('transport_maps').with_value('hash:/etc/postfix/transport') From 5d2a8d5002f480deb7eda8ca00ff98f09d90a965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Wed, 25 Mar 2015 16:00:37 +0100 Subject: [PATCH 32/38] Quality the postmap command in postfix::hash Fix #75 and #85 --- manifests/hash.pp | 1 + spec/classes/postfix_mta_spec.rb | 1 + spec/defines/postfix_hash_spec.rb | 1 + 3 files changed, 3 insertions(+) diff --git a/manifests/hash.pp b/manifests/hash.pp index 076f7450..3f7521b7 100644 --- a/manifests/hash.pp +++ b/manifests/hash.pp @@ -66,6 +66,7 @@ exec {"generate ${name}.db": command => "postmap ${name}", + path => $::path, #creates => "${name}.db", # this prevents postmap from being run ! subscribe => File[$name], refreshonly => true, diff --git a/spec/classes/postfix_mta_spec.rb b/spec/classes/postfix_mta_spec.rb index 39c01d61..e36911b6 100644 --- a/spec/classes/postfix_mta_spec.rb +++ b/spec/classes/postfix_mta_spec.rb @@ -4,6 +4,7 @@ let (:facts) { { :lsbdistcodename => 'wheezy', :osfamily => 'Debian', + :path => '/foo/bar', } } let :pre_condition do "class { 'postfix': diff --git a/spec/defines/postfix_hash_spec.rb b/spec/defines/postfix_hash_spec.rb index 6a3220e8..f6cf28e5 100644 --- a/spec/defines/postfix_hash_spec.rb +++ b/spec/defines/postfix_hash_spec.rb @@ -5,6 +5,7 @@ let (:facts) { { :lsbdistcodename => 'wheezy', :osfamily => 'Debian', + :path => '/foo/bar', } } let :pre_condition do "class { '::postfix': }" From a1275627f6a66680c9c67f272fbd999b15117f5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Can=C3=A9vet?= Date: Wed, 25 Mar 2015 16:19:56 +0100 Subject: [PATCH 33/38] Revert "Update service.pp" --- manifests/service.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/service.pp b/manifests/service.pp index c9bc28bb..c3f185da 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -3,6 +3,6 @@ ensure => running, enable => true, hasstatus => true, - restart => 'service postfix reload', + restart => '/etc/init.d/postfix reload', } } From e81564f03339369680c6858e4ec9b6ffd6e16ef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Can=C3=A9vet?= Date: Wed, 25 Mar 2015 17:15:37 +0100 Subject: [PATCH 34/38] Manage unit tests with rspec-puppet-facts --- metadata.json | 3 +- spec/classes/postfix_augeas_spec.rb | 45 +- spec/classes/postfix_mailman_spec.rb | 14 + spec/classes/postfix_mta_spec.rb | 20 +- spec/classes/postfix_satellite_spec.rb | 30 +- spec/classes/postfix_spec.rb | 545 ++++++++++++------------- spec/defines/postfix_config_spec.rb | 155 +++---- spec/defines/postfix_hash_spec.rb | 170 ++++---- spec/defines/postfix_transport_spec.rb | 265 ++++++------ spec/defines/postfix_virtual_spec.rb | 257 ++++++------ 10 files changed, 764 insertions(+), 740 deletions(-) diff --git a/metadata.json b/metadata.json index 5c0e7bb9..c50c05d2 100644 --- a/metadata.json +++ b/metadata.json @@ -48,7 +48,8 @@ "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", - "6" + "6", + "7" ] } ], diff --git a/spec/classes/postfix_augeas_spec.rb b/spec/classes/postfix_augeas_spec.rb index ff068e9b..4ea74766 100644 --- a/spec/classes/postfix_augeas_spec.rb +++ b/spec/classes/postfix_augeas_spec.rb @@ -1,28 +1,33 @@ require 'spec_helper' describe 'postfix::augeas' do - let (:facts) { { - :augeasversion => '1.2.0', - :lsbdistcodename => 'wheezy', - :operatingsystem => 'Debian', - :osfamily => 'Debian', - :rubyversion => '1.9.3', - :path => '/foo/bar', - } } + let :pre_condition do "include ::augeas" end - it { is_expected.to contain_augeas__lens('postfix_transport').with( - :ensure => 'present', - :lens_source => 'puppet:///modules/postfix/lenses/postfix_transport.aug', - :test_source => 'puppet:///modules/postfix/lenses/test_postfix_transport.aug', - :stock_since => '1.0.0' - ) } - it { is_expected.to contain_augeas__lens('postfix_virtual').with( - :ensure => 'present', - :lens_source => 'puppet:///modules/postfix/lenses/postfix_virtual.aug', - :test_source => 'puppet:///modules/postfix/lenses/test_postfix_virtual.aug', - :stock_since => '1.0.0' - ) } + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ + :augeasversion => '1.2.0', + }) + end + + it { is_expected.to compile.with_all_deps } + + it { is_expected.to contain_augeas__lens('postfix_transport').with({ + :ensure => 'present', + :lens_source => 'puppet:///modules/postfix/lenses/postfix_transport.aug', + :test_source => 'puppet:///modules/postfix/lenses/test_postfix_transport.aug', + :stock_since => '1.0.0', + } ) } + it { is_expected.to contain_augeas__lens('postfix_virtual').with({ + :ensure => 'present', + :lens_source => 'puppet:///modules/postfix/lenses/postfix_virtual.aug', + :test_source => 'puppet:///modules/postfix/lenses/test_postfix_virtual.aug', + :stock_since => '1.0.0', + }) } + end + end end diff --git a/spec/classes/postfix_mailman_spec.rb b/spec/classes/postfix_mailman_spec.rb index 15217b46..86623d33 100644 --- a/spec/classes/postfix_mailman_spec.rb +++ b/spec/classes/postfix_mailman_spec.rb @@ -1,4 +1,18 @@ require 'spec_helper' describe 'postfix::mailman' do + + let :pre_condition do + "include ::postfix" + end + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts + end + + it { is_expected.to compile.with_all_deps } + end + end end diff --git a/spec/classes/postfix_mta_spec.rb b/spec/classes/postfix_mta_spec.rb index e36911b6..c6be6c75 100644 --- a/spec/classes/postfix_mta_spec.rb +++ b/spec/classes/postfix_mta_spec.rb @@ -1,11 +1,6 @@ require 'spec_helper' describe 'postfix::mta' do - let (:facts) { { - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :path => '/foo/bar', - } } let :pre_condition do "class { 'postfix': mydestination => 'bar', @@ -14,7 +9,16 @@ }" end - it { is_expected.to contain_postfix__config('mydestination').with_value('bar') } - it { is_expected.to contain_postfix__config('mynetworks').with_value('127.0.0.1/8, [::1]/128 ![::2]/128') } - it { is_expected.to contain_postfix__config('relayhost').with_value('foo') } + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts + end + + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_postfix__config('mydestination').with_value('bar') } + it { is_expected.to contain_postfix__config('mynetworks').with_value('127.0.0.1/8, [::1]/128 ![::2]/128') } + it { is_expected.to contain_postfix__config('relayhost').with_value('foo') } + end + end end diff --git a/spec/classes/postfix_satellite_spec.rb b/spec/classes/postfix_satellite_spec.rb index a3cf4d53..ac9489ec 100644 --- a/spec/classes/postfix_satellite_spec.rb +++ b/spec/classes/postfix_satellite_spec.rb @@ -1,14 +1,6 @@ require 'spec_helper' describe 'postfix::satellite' do - let (:node) { 'foo.example.com' } - let (:facts) { { - :augeasversion => '1.2.0', - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :rubyversion => '1.9.3', - :path => '/foo/bar', - } } let :pre_condition do " class { 'augeas': } class { 'postfix': @@ -17,9 +9,21 @@ class { 'postfix': mynetworks => 'baz', }" end - it { is_expected.to contain_class('postfix::mta') } - it { is_expected.to contain_postfix__virtual('@foo.example.com').with( - :ensure => 'present', - :destination => 'root' - ) } + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ + :augeasversion => '1.2.0', + }) + end + + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_class('postfix::mta') } + it { is_expected.to contain_postfix__virtual('@foo.example.com').with( + :ensure => 'present', + :destination => 'root' + ) } + end + end end diff --git a/spec/classes/postfix_spec.rb b/spec/classes/postfix_spec.rb index 1c388a01..5113b89a 100644 --- a/spec/classes/postfix_spec.rb +++ b/spec/classes/postfix_spec.rb @@ -1,306 +1,283 @@ require 'spec_helper' describe 'postfix' do - context 'when using defaults' do - context 'when on Debian' do - let (:facts) { { - :lsbdistcodename => 'wheezy', - :operatingsystem => 'Debian', - :osfamily => 'Debian', - :fqdn => 'fqdn.example.com', - :path => '/foo/bar', - } } - it { is_expected.to contain_package('postfix') } - it { is_expected.to contain_package('mailx') } - - it { is_expected.to contain_file('/etc/mailname').without('seltype').with_content("fqdn.example.com\n") } - it { is_expected.to contain_file('/etc/aliases').without('seltype').with_content("# file managed by puppet\n") } - it { is_expected.to contain_exec('newaliases').with_refreshonly('true') } - it { is_expected.to contain_file('/etc/postfix/master.cf').without('seltype') } - it { is_expected.to contain_file('/etc/postfix/main.cf').without('seltype') } - - it { is_expected.to contain_postfix__config('myorigin').with_value('fqdn.example.com') } - it { is_expected.to contain_postfix__config('alias_maps').with_value('hash:/etc/aliases') } - it { is_expected.to contain_postfix__config('inet_interfaces').with_value('all') } - - it { is_expected.to contain_mailalias('root').with_recipient('nobody') } - - it { - is_expected.to contain_service('postfix').with( - :ensure => 'running', - :enable => 'true', - :hasstatus => 'true', - :restart => '/etc/init.d/postfix reload' - ) } - end - - context 'when on RedHat' do - let (:facts) { { - :fqdn => 'fqdn.example.com', - :operatingsystem => 'RedHat', - :operatingsystemmajrelease => '7', - :osfamily => 'RedHat', - :path => '/foo/bar', - } } - - it { is_expected.to contain_package('postfix') } - it { is_expected.to contain_package('mailx') } + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ + :augeasversion => '1.2.0', + }) + end - it { is_expected.to contain_file('/etc/mailname').with_seltype('postfix_etc_t').with_content("fqdn.example.com\n") } - it { is_expected.to contain_file('/etc/aliases').with_seltype('postfix_etc_t').with_content("# file managed by puppet\n") } - it { is_expected.to contain_exec('newaliases').with_refreshonly('true') } - it { is_expected.to contain_file('/etc/postfix/master.cf').with_seltype('postfix_etc_t') } - it { is_expected.to contain_file('/etc/postfix/main.cf').with_seltype('postfix_etc_t') } + context 'when using defaults' do + it { is_expected.to contain_package('postfix') } + it { is_expected.to contain_package('mailx') } + it { is_expected.to contain_exec('newaliases').with_refreshonly('true') } + it { is_expected.to contain_postfix__config('myorigin').with_value('foo.example.com') } + it { is_expected.to contain_postfix__config('alias_maps').with_value('hash:/etc/aliases') } + it { is_expected.to contain_postfix__config('inet_interfaces').with_value('all') } + it { is_expected.to contain_mailalias('root').with_recipient('nobody') } - it { is_expected.to contain_postfix__config('myorigin').with_value('fqdn.example.com') } - it { is_expected.to contain_postfix__config('alias_maps').with_value('hash:/etc/aliases') } - it { is_expected.to contain_postfix__config('inet_interfaces').with_value('all') } - it { is_expected.to contain_postfix__config('sendmail_path') } - it { is_expected.to contain_postfix__config('newaliases_path') } - it { is_expected.to contain_postfix__config('mailq_path') } + case facts[:osfamily] + when 'Debian' + it { is_expected.to contain_file('/etc/mailname').without('seltype').with_content("foo.example.com\n") } + it { is_expected.to contain_file('/etc/aliases').without('seltype').with_content("# file managed by puppet\n") } + it { is_expected.to contain_file('/etc/postfix/master.cf').without('seltype') } + it { is_expected.to contain_file('/etc/postfix/main.cf').without('seltype') } - it { is_expected.to contain_mailalias('root').with_recipient('nobody') } + it { + is_expected.to contain_service('postfix').with( + :ensure => 'running', + :enable => 'true', + :hasstatus => 'true', + :restart => '/etc/init.d/postfix reload' + ) } + else + it { is_expected.to contain_file('/etc/mailname').with_seltype('postfix_etc_t').with_content("foo.example.com\n") } + it { is_expected.to contain_file('/etc/aliases').with_seltype('postfix_etc_t').with_content("# file managed by puppet\n") } + it { is_expected.to contain_file('/etc/postfix/master.cf').with_seltype('postfix_etc_t') } + it { is_expected.to contain_file('/etc/postfix/main.cf').with_seltype('postfix_etc_t') } - it { - is_expected.to contain_service('postfix').with( - :ensure => 'running', - :enable => 'true', - :hasstatus => 'true', - :restart => '/bin/systemctl reload postfix' - ) } - end - end + it { is_expected.to contain_postfix__config('sendmail_path') } + it { is_expected.to contain_postfix__config('newaliases_path') } + it { is_expected.to contain_postfix__config('mailq_path') } - context 'when setting parameters' do - context 'when on Debian' do - context "when setting smtp_listen to 'all'" do - let (:facts) { { - :lsbdistcodename => 'wheezy', - :operatingsystem => 'Debian', - :osfamily => 'Debian', - :fqdn => 'fqdn.example.com', - :path => '/foo/bar', - } } + case facts[:operatingsystemmajrelease] + when '7' + it { + is_expected.to contain_service('postfix').with( + :ensure => 'running', + :enable => 'true', + :hasstatus => 'true', + :restart => '/bin/systemctl reload postfix' + ) } + else + it { + is_expected.to contain_service('postfix').with( + :ensure => 'running', + :enable => 'true', + :hasstatus => 'true', + :restart => '/etc/init.d/postfix reload' + ) } + end + end + end - let (:params) { { - :smtp_listen => 'all', - :root_mail_recipient => 'foo', - :use_amavisd => true, - :use_dovecot_lda => true, - :use_schleuder => true, - :use_sympa => true, - :mail_user => 'bar', - :myorigin => 'localhost', - :inet_interfaces => 'localhost2', - :master_smtp => "smtp inet n - - - - smtpd + context 'when setting parameters' do + case facts[:osfamily] + when 'Debian' + context "when setting smtp_listen to 'all'" do + let (:params) { { + :smtp_listen => 'all', + :root_mail_recipient => 'foo', + :use_amavisd => true, + :use_dovecot_lda => true, + :use_schleuder => true, + :use_sympa => true, + :mail_user => 'bar', + :myorigin => 'localhost', + :inet_interfaces => 'localhost2', + :master_smtp => "smtp inet n - - - - smtpd -o smtpd_client_restrictions=check_client_access,hash:/etc/postfix/access,reject", - :master_smtps => 'smtps inet n - - - - smtpd', - :master_submission => 'submission inet n - - - - smtpd', - } } + :master_smtps => 'smtps inet n - - - - smtpd', + :master_submission => 'submission inet n - - - - smtpd', + } } - it { is_expected.to contain_package('postfix') } - it { is_expected.to contain_package('mailx') } + it { is_expected.to contain_package('postfix') } + it { is_expected.to contain_package('mailx') } - it { is_expected.to contain_file('/etc/mailname').without('seltype').with_content("fqdn.example.com\n") } - it { is_expected.to contain_file('/etc/aliases').without('seltype').with_content("# file managed by puppet\n") } - it { is_expected.to contain_exec('newaliases').with_refreshonly('true') } - it { - is_expected.to contain_file('/etc/postfix/master.cf').without('seltype').with_content( - /smtp inet n - - - - smtpd/ - ).with_content( - /amavis unix/ - ).with_content( - /dovecot.*\n.* user=bar:bar / - ).with_content( - /schleuder/ - ).with_content( - /sympa/ - ).with_content( - /user=bar/ - ).with_content( - /^smtp.*\n.*smtpd_client_restrictions=check_client_access,hash:/ - ).with_content( - /^smtps inet n/ - ).with_content( - /^submission inet n/ - ) - } - it { is_expected.to contain_file('/etc/postfix/main.cf').without('seltype') } + it { is_expected.to contain_file('/etc/mailname').without('seltype').with_content("foo.example.com\n") } + it { is_expected.to contain_file('/etc/aliases').without('seltype').with_content("# file managed by puppet\n") } + it { is_expected.to contain_exec('newaliases').with_refreshonly('true') } + it { + is_expected.to contain_file('/etc/postfix/master.cf').without('seltype').with_content( + /smtp inet n - - - - smtpd/ + ).with_content( + /amavis unix/ + ).with_content( + /dovecot.*\n.* user=bar:bar / + ).with_content( + /schleuder/ + ).with_content( + /sympa/ + ).with_content( + /user=bar/ + ).with_content( + /^smtp.*\n.*smtpd_client_restrictions=check_client_access,hash:/ + ).with_content( + /^smtps inet n/ + ).with_content( + /^submission inet n/ + ) + } + it { is_expected.to contain_file('/etc/postfix/main.cf').without('seltype') } - it { is_expected.to contain_postfix__config('myorigin').with_value('localhost') } - it { is_expected.to contain_postfix__config('alias_maps').with_value('hash:/etc/aliases') } - it { is_expected.to contain_postfix__config('inet_interfaces').with_value('localhost2') } + it { is_expected.to contain_postfix__config('myorigin').with_value('localhost') } + it { is_expected.to contain_postfix__config('alias_maps').with_value('hash:/etc/aliases') } + it { is_expected.to contain_postfix__config('inet_interfaces').with_value('localhost2') } - it { is_expected.to contain_mailalias('root').with_recipient('foo') } + it { is_expected.to contain_mailalias('root').with_recipient('foo') } - it { - is_expected.to contain_service('postfix').with( - :ensure => 'running', - :enable => 'true', - :hasstatus => 'true', - :restart => '/etc/init.d/postfix reload' - ) } - end - end - context 'when on RedHat' do - let (:facts) { { - :augeasversion => '1.2.0', - :lsbdistcodename => 'wheezy', - :operatingsystem => 'Debian', - :osfamily => 'Debian', - :rubyversion => '1.9.7', - :fqdn => 'fqdn.example.com', - :path => '/foo/bar', - } } - context 'when specifying inet_interfaces' do - let (:params) { { - :inet_interfaces => 'localhost2' - } } - it 'should create a postfix::config defined type with inet_interfaces specified properly' do - is_expected.to contain_postfix__config('inet_interfaces').with_value('localhost2') - end - end - context 'when enabling ldap' do - it 'should do stuff' do - skip 'need to write this still' - end - end - context 'when a custom mail_user is specified' do - let (:params) { { - :mail_user => 'bar' - } } - it 'should adjust the content of /etc/postfix/master.cf specifying the user' do - is_expected.to contain_file('/etc/postfix/master.cf').without('seltype').with_content(/user=bar/) - end - end - context 'when mailman is true' do - let (:params) { { - :mailman => true - } } - it 'should do stuff' do - skip 'need to write this still' - end - end - context 'when specifying a custom mastercf_source' do - let (:params) { { - :mastercf_source => 'testy' - } } - it 'should do stuff' do - skip 'need to write this still' - end - end - context 'when specifying a custom master_smtp' do - let (:params) { { - :master_smtp => "smtp inet n - - - - smtpd + it { + is_expected.to contain_service('postfix').with( + :ensure => 'running', + :enable => 'true', + :hasstatus => 'true', + :restart => '/etc/init.d/postfix reload' + ) } + end + else + context 'when specifying inet_interfaces' do + let (:params) { { + :inet_interfaces => 'localhost2' + } } + it 'should create a postfix::config defined type with inet_interfaces specified properly' do + is_expected.to contain_postfix__config('inet_interfaces').with_value('localhost2') + end + end + context 'when enabling ldap' do + it 'should do stuff' do + skip 'need to write this still' + end + end + context 'when a custom mail_user is specified' do + let (:params) { { + :mail_user => 'bar' + } } + it 'should adjust the content of /etc/postfix/master.cf specifying the user' do + is_expected.to contain_file('/etc/postfix/master.cf').with_seltype('postfix_etc_t').with_content(/user=bar/) + end + end + context 'when mailman is true' do + let (:params) { { + :mailman => true + } } + it 'should do stuff' do + skip 'need to write this still' + end + end + context 'when specifying a custom mastercf_source' do + let (:params) { { + :mastercf_source => 'testy' + } } + it 'should do stuff' do + skip 'need to write this still' + end + end + context 'when specifying a custom master_smtp' do + let (:params) { { + :master_smtp => "smtp inet n - - - - smtpd -o smtpd_client_restrictions=check_client_access,hash:/etc/postfix/access,reject", - } } - it 'should update master.cf with the specified flags to smtp' do - is_expected.to contain_file('/etc/postfix/master.cf').without('seltype').with_content( - /smtp inet n - - - - smtpd/).with_content( - /^smtp.*\n.*smtpd_client_restrictions=check_client_access,hash:/ - ) - end - end - context 'when specifying a custom master_smtps' do - let (:params) { { - :master_smtps => 'smtps inet n - - - - smtpd' - } } - it 'should update master.cf with the specified flags to smtps' do - is_expected.to contain_file('/etc/postfix/master.cf').with_content(/^smtps inet n/) - end - end - context 'when mta is enabled' do - let (:params) { { :mta => true, :mydestination => '1.2.3.4', :relayhost => '2.3.4.5' } } - it 'should configure postfix as a minimal MTA, delivering mail to the mydestination param' do - is_expected.to contain_postfix__config('mydestination').with_value('1.2.3.4') - is_expected.to contain_postfix__config('mynetworks').with_value('127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128') - is_expected.to contain_postfix__config('relayhost').with_value('2.3.4.5') - is_expected.to contain_postfix__config('virtual_alias_maps').with_value('hash:/etc/postfix/virtual') - is_expected.to contain_postfix__config('transport_maps').with_value('hash:/etc/postfix/transport') - end - it { is_expected.to contain_class('postfix::mta') } - context 'and satellite is also enabled' do - let (:params) { { :mta => true, :satellite => true, :mydestination => '1.2.3.4', :relayhost => '2.3.4.5' } } - it 'should fail' do - expect { should compile }.to raise_error(/Please disable one/) + } } + it 'should update master.cf with the specified flags to smtp' do + is_expected.to contain_file('/etc/postfix/master.cf').with_seltype('postfix_etc_t').with_content( + /smtp inet n - - - - smtpd/).with_content( + /^smtp.*\n.*smtpd_client_restrictions=check_client_access,hash:/ + ) + end end - end - end - context 'when specifying mydesitination' do - it 'should do stuff' do - skip 'need to write this still' - end - end - context 'when specifying mynetworks' do - it 'should do stuff' do - skip 'need to write this still' - end - end - context 'when specifying myorigin' do - let (:params) { { :myorigin => 'localhost'} } - it 'should create a postfix::config defined type with myorigin specified properly' do - is_expected.to contain_postfix__config('myorigin').with_value('localhost') - end - end - context 'when specifying relayhost' do - it 'should do stuff' do - skip 'need to write this still' - end - end - context 'when specifying a root_mail_recipient' do - let (:params) { { :root_mail_recipient => 'foo'} } - it 'should contain a Mailalias resource directing roots mail to the required user' do - is_expected.to contain_mailalias('root').with_recipient('foo') - end - end - context 'when specifying satellite' do - let (:params) { { :satellite => true, :mydestination => '1.2.3.4', :relayhost => '2.3.4.5' } } - let :pre_condition do - "class { 'augeas': }" - end - it 'should configure all local email to be forwarded to $root_mail_recipient delivered through $relayhost' do - is_expected.to contain_postfix__config('mydestination').with_value('1.2.3.4') - is_expected.to contain_postfix__config('mynetworks').with_value('127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128') - is_expected.to contain_postfix__config('relayhost').with_value('2.3.4.5') - is_expected.to contain_postfix__config('virtual_alias_maps').with_value('hash:/etc/postfix/virtual') - is_expected.to contain_postfix__config('transport_maps').with_value('hash:/etc/postfix/transport') - end - context 'and mta is also enabled' do - let (:params) { { :mta => true, :satellite => true, :mydestination => '1.2.3.4', :relayhost => '2.3.4.5' } } - it 'should fail' do - expect { should compile }.to raise_error(/Please disable one/) + context 'when specifying a custom master_smtps' do + let (:params) { { + :master_smtps => 'smtps inet n - - - - smtpd' + } } + it 'should update master.cf with the specified flags to smtps' do + is_expected.to contain_file('/etc/postfix/master.cf').with_content(/^smtps inet n/) + end + end + context 'when mta is enabled' do + let (:params) { { :mta => true, :mydestination => '1.2.3.4', :relayhost => '2.3.4.5' } } + it 'should configure postfix as a minimal MTA, delivering mail to the mydestination param' do + is_expected.to contain_postfix__config('mydestination').with_value('1.2.3.4') + is_expected.to contain_postfix__config('mynetworks').with_value('127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128') + is_expected.to contain_postfix__config('relayhost').with_value('2.3.4.5') + is_expected.to contain_postfix__config('virtual_alias_maps').with_value('hash:/etc/postfix/virtual') + is_expected.to contain_postfix__config('transport_maps').with_value('hash:/etc/postfix/transport') + end + it { is_expected.to contain_class('postfix::mta') } + context 'and satellite is also enabled' do + let (:params) { { :mta => true, :satellite => true, :mydestination => '1.2.3.4', :relayhost => '2.3.4.5' } } + it 'should fail' do + expect { should compile }.to raise_error(/Please disable one/) + end + end + end + context 'when specifying mydesitination' do + it 'should do stuff' do + skip 'need to write this still' + end + end + context 'when specifying mynetworks' do + it 'should do stuff' do + skip 'need to write this still' + end + end + context 'when specifying myorigin' do + let (:params) { { :myorigin => 'localhost'} } + it 'should create a postfix::config defined type with myorigin specified properly' do + is_expected.to contain_postfix__config('myorigin').with_value('localhost') + end + end + context 'when specifying relayhost' do + it 'should do stuff' do + skip 'need to write this still' + end + end + context 'when specifying a root_mail_recipient' do + let (:params) { { :root_mail_recipient => 'foo'} } + it 'should contain a Mailalias resource directing roots mail to the required user' do + is_expected.to contain_mailalias('root').with_recipient('foo') + end + end + context 'when specifying satellite' do + let (:params) { { :satellite => true, :mydestination => '1.2.3.4', :relayhost => '2.3.4.5' } } + let :pre_condition do + "class { 'augeas': }" + end + it 'should configure all local email to be forwarded to $root_mail_recipient delivered through $relayhost' do + is_expected.to contain_postfix__config('mydestination').with_value('1.2.3.4') + is_expected.to contain_postfix__config('mynetworks').with_value('127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128') + is_expected.to contain_postfix__config('relayhost').with_value('2.3.4.5') + is_expected.to contain_postfix__config('virtual_alias_maps').with_value('hash:/etc/postfix/virtual') + is_expected.to contain_postfix__config('transport_maps').with_value('hash:/etc/postfix/transport') + end + context 'and mta is also enabled' do + let (:params) { { :mta => true, :satellite => true, :mydestination => '1.2.3.4', :relayhost => '2.3.4.5' } } + it 'should fail' do + expect { should compile }.to raise_error(/Please disable one/) + end + end + end + context 'when specifying smtp_listen' do + let (:params) { { :smtp_listen => 'all' } } + it 'should do stuff' do + skip 'need to write this still' + end + end + context 'when use_amavisd is true' do + let (:params) { { :use_amavisd => true } } + it 'should update master.cf with the specified flags to amavis' do + is_expected.to contain_file('/etc/postfix/master.cf').with_content(/amavis unix/) + end + end + context 'when use_dovecot_lda is true' do + let (:params) { { :use_dovecot_lda => true } } + it 'should update master.cf with the specified flags to dovecot' do + is_expected.to contain_file('/etc/postfix/master.cf').with_content(/dovecot.*\n.* user=vmail:vmail /) + end + end + context 'when use_schleuder is true' do + let (:params) { { :use_schleuder => true } } + it 'should update master.cf with the specified flags to schleuder' do + is_expected.to contain_file('/etc/postfix/master.cf').with_content(/schleuder/) + end + end + context 'when use_sympa is true' do + let (:params) { { :use_sympa => true } } + it 'should update master.cf to include sympa' do + is_expected.to contain_file('/etc/postfix/master.cf').with_content(/sympa/) + end end - end - end - context 'when specifying smtp_listen' do - let (:params) { { :smtp_listen => 'all' } } - it 'should do stuff' do - skip 'need to write this still' - end - end - context 'when use_amavisd is true' do - let (:params) { { :use_amavisd => true } } - it 'should update master.cf with the specified flags to amavis' do - is_expected.to contain_file('/etc/postfix/master.cf').with_content(/amavis unix/) - end - end - context 'when use_dovecot_lda is true' do - let (:params) { { :use_dovecot_lda => true } } - it 'should update master.cf with the specified flags to dovecot' do - is_expected.to contain_file('/etc/postfix/master.cf').with_content(/dovecot.*\n.* user=vmail:vmail /) - end - end - context 'when use_schleuder is true' do - let (:params) { { :use_schleuder => true } } - it 'should update master.cf with the specified flags to schleuder' do - is_expected.to contain_file('/etc/postfix/master.cf').with_content(/schleuder/) - end - end - context 'when use_sympa is true' do - let (:params) { { :use_sympa => true } } - it 'should update master.cf to include sympa' do - is_expected.to contain_file('/etc/postfix/master.cf').with_content(/sympa/) end end end diff --git a/spec/defines/postfix_config_spec.rb b/spec/defines/postfix_config_spec.rb index 75c8edd5..2fe17840 100644 --- a/spec/defines/postfix_config_spec.rb +++ b/spec/defines/postfix_config_spec.rb @@ -2,93 +2,98 @@ describe 'postfix::config' do let (:title) { 'foo' } - let (:facts) { { - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - } } + let :pre_condition do "class { 'postfix': }" end - context 'when not passing value' do - it 'should fail' do - expect { - is_expected.to contain_augeas("set postfix 'foo'") - }.to raise_error(Puppet::Error, /value can not be empty/) - end - end + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts + end - context 'when passing wrong type for value' do - let (:params) { { - :value => ['bar'], - } } - it 'should fail' do - expect { - is_expected.to contain_augeas("set postfix 'foo'") - }.to raise_error(Puppet::Error, /\["bar"\] is not a string/) - end - end + context 'when not passing value' do + it 'should fail' do + expect { + is_expected.to contain_augeas("set postfix 'foo'") + }.to raise_error(Puppet::Error, /value can not be empty/) + end + end - context 'when passing wrong type for ensure' do - let (:params) { { - :value => 'bar', - :ensure => ['present'], - } } - it 'should fail' do - expect { - is_expected.to contain_augeas("set postfix 'foo'") - }.to raise_error(Puppet::Error, /\["present"\] is not a string/) - end - end + context 'when passing wrong type for value' do + let (:params) { { + :value => ['bar'], + } } + it 'should fail' do + expect { + is_expected.to contain_augeas("set postfix 'foo'") + }.to raise_error(Puppet::Error, /\["bar"\] is not a string/) + end + end - context 'when passing wrong value for ensure' do - let (:params) { { - :value => 'bar', - :ensure => 'running', - } } - it 'should fail' do - expect { - is_expected.to contain_augeas("set postfix 'foo'") - }.to raise_error(Puppet::Error, /must be either 'present', 'absent' or 'blank'/) - end - end + context 'when passing wrong type for ensure' do + let (:params) { { + :value => 'bar', + :ensure => ['present'], + } } + it 'should fail' do + expect { + is_expected.to contain_augeas("set postfix 'foo'") + }.to raise_error(Puppet::Error, /\["present"\] is not a string/) + end + end - context 'when ensuring presence' do - let (:params) { { - :value => 'bar', - :ensure => 'present', - } } + context 'when passing wrong value for ensure' do + let (:params) { { + :value => 'bar', + :ensure => 'running', + } } + it 'should fail' do + expect { + is_expected.to contain_augeas("set postfix 'foo'") + }.to raise_error(Puppet::Error, /must be either 'present', 'absent' or 'blank'/) + end + end - it { is_expected.to contain_augeas("manage postfix 'foo'").with( - :incl => '/etc/postfix/main.cf', - :lens => 'Postfix_Main.lns', - :changes => "set foo 'bar'" - ) } - end + context 'when ensuring presence' do + let (:params) { { + :value => 'bar', + :ensure => 'present', + } } - context 'when ensuring absence' do - let (:params) { { - :value => 'bar', - :ensure => 'absent', - } } + it { is_expected.to contain_augeas("manage postfix 'foo'").with( + :incl => '/etc/postfix/main.cf', + :lens => 'Postfix_Main.lns', + :changes => "set foo 'bar'" + ) } + end - it { is_expected.to contain_augeas("manage postfix 'foo'").with( - :incl => '/etc/postfix/main.cf', - :lens => 'Postfix_Main.lns', - :changes => "rm foo" - ) } - end + context 'when ensuring absence' do + let (:params) { { + :value => 'bar', + :ensure => 'absent', + } } + + it { is_expected.to contain_augeas("manage postfix 'foo'").with( + :incl => '/etc/postfix/main.cf', + :lens => 'Postfix_Main.lns', + :changes => "rm foo" + ) } + end - context 'when ensuring blank' do - let (:params) { { - :value => 'bar', - :ensure => 'blank', - } } + context 'when ensuring blank' do + let (:params) { { + :value => 'bar', + :ensure => 'blank', + } } - it { is_expected.to contain_augeas("manage postfix 'foo'").with( - :incl => '/etc/postfix/main.cf', - :lens => 'Postfix_Main.lns', - :changes => "clear foo" - ) } + it { is_expected.to contain_augeas("manage postfix 'foo'").with( + :incl => '/etc/postfix/main.cf', + :lens => 'Postfix_Main.lns', + :changes => "clear foo" + ) } + end + end end end diff --git a/spec/defines/postfix_hash_spec.rb b/spec/defines/postfix_hash_spec.rb index f6cf28e5..ef80b0f5 100644 --- a/spec/defines/postfix_hash_spec.rb +++ b/spec/defines/postfix_hash_spec.rb @@ -2,103 +2,107 @@ describe 'postfix::hash' do let (:title) { '/tmp/foo' } - let (:facts) { { - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :path => '/foo/bar', - } } + let :pre_condition do "class { '::postfix': }" end - context 'when passing wrong type for ensure' do - let (:params) { { - :ensure => ['present'], - } } - it 'should fail' do - expect { - is_expected.to contain_file('/tmp/foo') - }.to raise_error(Puppet::Error, /\["present"\] is not a string/) - end - end + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts + end - context 'when passing wrong value for ensure' do - let (:params) { { - :ensure => 'running', - } } - it 'should fail' do - expect { - is_expected.to contain_file('/tmp/foo') - }.to raise_error(Puppet::Error, /must be either 'present' or 'absent'/) - end - end + context 'when passing wrong type for ensure' do + let (:params) { { + :ensure => ['present'], + } } + it 'should fail' do + expect { + is_expected.to contain_file('/tmp/foo') + }.to raise_error(Puppet::Error, /\["present"\] is not a string/) + end + end - context 'when passing wrong value for title' do - let (:title) { 'foo' } - it 'should fail' do - expect { - is_expected.to contain_file('/tmp/foo') - }.to raise_error(Puppet::Error, /"foo" is not an absolute path/) - end - end + context 'when passing wrong value for ensure' do + let (:params) { { + :ensure => 'running', + } } + it 'should fail' do + expect { + is_expected.to contain_file('/tmp/foo') + }.to raise_error(Puppet::Error, /must be either 'present' or 'absent'/) + end + end - context 'when passing both source and content' do - let (:params) { { - :source => '/tmp/bar', - :content => 'bar', - } } + context 'when passing wrong value for title' do + let (:title) { 'foo' } + it 'should fail' do + expect { + is_expected.to contain_file('/tmp/foo') + }.to raise_error(Puppet::Error, /"foo" is not an absolute path/) + end + end - it 'should fail' do - expect { - is_expected.to contain_file('/tmp/foo') - }.to raise_error(Puppet::Error, /You must provide either 'source' or 'content'/) - end - end + context 'when passing both source and content' do + let (:params) { { + :source => '/tmp/bar', + :content => 'bar', + } } - context 'when passing source' do - let (:params) { { - :source => '/tmp/bar', - } } + it 'should fail' do + expect { + is_expected.to contain_file('/tmp/foo') + }.to raise_error(Puppet::Error, /You must provide either 'source' or 'content'/) + end + end - it { is_expected.to contain_file('/tmp/foo').with( - :ensure => 'present', - :source => '/tmp/bar' - ).without(:content) - } - it { is_expected.to contain_file('/tmp/foo.db').with_ensure('present') } - it { is_expected.to contain_exec('generate /tmp/foo.db') } - end + context 'when passing source' do + let (:params) { { + :source => '/tmp/bar', + } } - context 'when passing content' do - let (:params) { { - :content => 'bar', - } } + it { is_expected.to contain_file('/tmp/foo').with( + :ensure => 'present', + :source => '/tmp/bar' + ).without(:content) + } + it { is_expected.to contain_file('/tmp/foo.db').with_ensure('present') } + it { is_expected.to contain_exec('generate /tmp/foo.db') } + end - it { is_expected.to contain_file('/tmp/foo').with( - :ensure => 'present', - :content => 'bar' - ).without(:source) - } - it { is_expected.to contain_file('/tmp/foo.db').with_ensure('present') } - it { is_expected.to contain_exec('generate /tmp/foo.db') } - end + context 'when passing content' do + let (:params) { { + :content => 'bar', + } } - context 'when not passing source or content' do - it { is_expected.to contain_file('/tmp/foo').with( - :ensure => 'present' - ).without(:source).without(:content) - } - it { is_expected.to contain_file('/tmp/foo.db').with_ensure('present') } - it { is_expected.to contain_exec('generate /tmp/foo.db') } - end + it { is_expected.to contain_file('/tmp/foo').with( + :ensure => 'present', + :content => 'bar' + ).without(:source) + } + it { is_expected.to contain_file('/tmp/foo.db').with_ensure('present') } + it { is_expected.to contain_exec('generate /tmp/foo.db') } + end + + context 'when not passing source or content' do + it { is_expected.to contain_file('/tmp/foo').with( + :ensure => 'present' + ).without(:source).without(:content) + } + it { is_expected.to contain_file('/tmp/foo.db').with_ensure('present') } + it { is_expected.to contain_exec('generate /tmp/foo.db') } + end - context 'when ensuring absence' do - let (:params) { { - :ensure => 'absent', - } } + context 'when ensuring absence' do + let (:params) { { + :ensure => 'absent', + } } - it { is_expected.to contain_file('/tmp/foo').with_ensure('absent') } - it { is_expected.to contain_file('/tmp/foo.db').with_ensure('absent') } - it { is_expected.to contain_exec('generate /tmp/foo.db') } + it { is_expected.to contain_file('/tmp/foo').with_ensure('absent') } + it { is_expected.to contain_file('/tmp/foo.db').with_ensure('absent') } + it { is_expected.to contain_exec('generate /tmp/foo.db') } + end + end end end diff --git a/spec/defines/postfix_transport_spec.rb b/spec/defines/postfix_transport_spec.rb index ad497170..05904998 100644 --- a/spec/defines/postfix_transport_spec.rb +++ b/spec/defines/postfix_transport_spec.rb @@ -2,139 +2,144 @@ describe 'postfix::transport' do let (:title) { 'foo' } - let (:facts) { { - :augeasversion => '1.2.0', - :osfamily => 'Debian', - :rubyversion => '1.9.3', - :path => '/foo/bar', - } } - let :pre_condition do - "class { 'augeas': }" - end - - context 'when sending wrong type for destination' do - let (:params) { { - :destination => ['bar'], - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix transport - foo') - }.to raise_error(Puppet::Error, /\["bar"\] is not a string/) - end - end - - context 'when sending wrong type for nexthop' do - let (:params) { { - :destination => 'bar', - :nexthop => ['baz'], - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix transport - foo') - }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) - end - end - - context 'when sending wrong type for file' do - let (:params) { { - :destination => 'bar', - :file => ['baz'], - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix transport - foo') - }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) - end - end - context 'when sending wrong value for file' do - let (:params) { { - :destination => 'bar', - :file => 'baz', - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix transport - foo') - }.to raise_error(Puppet::Error, /"baz" is not an absolute path/) - end - end - - context 'when sending wrong type for ensure' do - let (:params) { { - :destination => 'bar', - :ensure => ['baz'], - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix transport - foo') - }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) - end + let :pre_condition do + "class { '::augeas': }" end - context 'when sending wrong value for ensure' do - let (:params) { { - :destination => 'bar', - :ensure => 'running', - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix transport - foo') - }.to raise_error(Puppet::Error, /\$ensure must be either/) + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ + :augeasversion => '1.2.0', + }) + end + + context 'when sending wrong type for destination' do + let (:params) { { + :destination => ['bar'], + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix transport - foo') + }.to raise_error(Puppet::Error, /\["bar"\] is not a string/) + end + end + + context 'when sending wrong type for nexthop' do + let (:params) { { + :destination => 'bar', + :nexthop => ['baz'], + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix transport - foo') + }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) + end + end + + context 'when sending wrong type for file' do + let (:params) { { + :destination => 'bar', + :file => ['baz'], + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix transport - foo') + }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) + end + end + + context 'when sending wrong value for file' do + let (:params) { { + :destination => 'bar', + :file => 'baz', + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix transport - foo') + }.to raise_error(Puppet::Error, /"baz" is not an absolute path/) + end + end + + context 'when sending wrong type for ensure' do + let (:params) { { + :destination => 'bar', + :ensure => ['baz'], + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix transport - foo') + }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) + end + end + + context 'when sending wrong value for ensure' do + let (:params) { { + :destination => 'bar', + :ensure => 'running', + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix transport - foo') + }.to raise_error(Puppet::Error, /\$ensure must be either/) + end + end + + context 'when using default values' do + it { is_expected.to contain_class('postfix::augeas') } + it { is_expected.to contain_augeas('Postfix transport - foo').with( + :incl => '/etc/postfix/transport', + :lens => 'Postfix_Transport.lns', + :changes => [ + "set pattern[. = 'foo'] 'foo'", + "clear pattern[. = 'foo']/transport", + "clear pattern[. = 'foo']/nexthop", + ]) + } + end + + context 'when overriding default values' do + let (:params) { { + :destination => 'bar', + :nexthop => 'baz', + :file => '/tmp/transport', + :ensure => 'present', + } } + + it { is_expected.to contain_class('postfix::augeas') } + it { is_expected.to contain_augeas('Postfix transport - foo').with( + :incl => '/tmp/transport', + :lens => 'Postfix_Transport.lns', + :changes => [ + "set pattern[. = 'foo'] 'foo'", + "set pattern[. = 'foo']/transport 'bar'", + "set pattern[. = 'foo']/nexthop 'baz'", + ]) + } + end + + context 'when ensuring absence' do + let (:params) { { + :destination => 'bar', + :ensure => 'absent', + } } + + it { is_expected.to contain_class('postfix::augeas') } + it { is_expected.to contain_augeas('Postfix transport - foo').with( + :incl => '/etc/postfix/transport', + :lens => 'Postfix_Transport.lns', + :changes => [ + "rm pattern[. = 'foo']", + ]) + } + end end end - - context 'when using default values' do - it { is_expected.to contain_class('postfix::augeas') } - it { is_expected.to contain_augeas('Postfix transport - foo').with( - :incl => '/etc/postfix/transport', - :lens => 'Postfix_Transport.lns', - :changes => [ - "set pattern[. = 'foo'] 'foo'", - "clear pattern[. = 'foo']/transport", - "clear pattern[. = 'foo']/nexthop", - ]) - } - end - - context 'when overriding default values' do - let (:params) { { - :destination => 'bar', - :nexthop => 'baz', - :file => '/tmp/transport', - :ensure => 'present', - } } - - it { is_expected.to contain_class('postfix::augeas') } - it { is_expected.to contain_augeas('Postfix transport - foo').with( - :incl => '/tmp/transport', - :lens => 'Postfix_Transport.lns', - :changes => [ - "set pattern[. = 'foo'] 'foo'", - "set pattern[. = 'foo']/transport 'bar'", - "set pattern[. = 'foo']/nexthop 'baz'", - ]) - } - end - - context 'when ensuring absence' do - let (:params) { { - :destination => 'bar', - :ensure => 'absent', - } } - - it { is_expected.to contain_class('postfix::augeas') } - it { is_expected.to contain_augeas('Postfix transport - foo').with( - :incl => '/etc/postfix/transport', - :lens => 'Postfix_Transport.lns', - :changes => [ - "rm pattern[. = 'foo']", - ]) - } - end end diff --git a/spec/defines/postfix_virtual_spec.rb b/spec/defines/postfix_virtual_spec.rb index 36a056b2..38927652 100644 --- a/spec/defines/postfix_virtual_spec.rb +++ b/spec/defines/postfix_virtual_spec.rb @@ -2,135 +2,140 @@ describe 'postfix::virtual' do let (:title) { 'foo' } - let (:facts) { { - :augeasversion => '1.2.0', - :osfamily => 'Debian', - :rubyversion => '1.9.3', - :path => '/foo/bar', - } } - let :pre_condition do - "class { 'augeas': }" - end - - context 'when not sending destination' do - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix virtual - foo') - }.to raise_error(Puppet::Error, /Must pass destination/) - end - end - - context 'when sending wrong type for destination' do - let (:params) { { - :destination => ['bar'], - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix virtual - foo') - }.to raise_error(Puppet::Error, /\["bar"\] is not a string/) - end - end - - context 'when sending wrong type for file' do - let (:params) { { - :destination => 'bar', - :file => ['baz'], - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix virtual - foo') - }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) - end - end - - context 'when sending wrong value for file' do - let (:params) { { - :destination => 'bar', - :file => 'baz', - } } - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix virtual - foo') - }.to raise_error(Puppet::Error, /"baz" is not an absolute path/) - end - end - - context 'when sending wrong type for ensure' do - let (:params) { { - :destination => 'bar', - :ensure => ['baz'], - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix virtual - foo') - }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) - end + let :pre_condition do + "class { '::augeas': }" end - context 'when sending wrong value for ensure' do - let (:params) { { - :destination => 'bar', - :ensure => 'running', - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix virtual - foo') - }.to raise_error(Puppet::Error, /\$ensure must be either/) + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ + :augeasversion => '1.2.0', + }) + end + + context 'when not sending destination' do + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix virtual - foo') + }.to raise_error(Puppet::Error, /Must pass destination/) + end + end + + context 'when sending wrong type for destination' do + let (:params) { { + :destination => ['bar'], + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix virtual - foo') + }.to raise_error(Puppet::Error, /\["bar"\] is not a string/) + end + end + + context 'when sending wrong type for file' do + let (:params) { { + :destination => 'bar', + :file => ['baz'], + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix virtual - foo') + }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) + end + end + + context 'when sending wrong value for file' do + let (:params) { { + :destination => 'bar', + :file => 'baz', + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix virtual - foo') + }.to raise_error(Puppet::Error, /"baz" is not an absolute path/) + end + end + + context 'when sending wrong type for ensure' do + let (:params) { { + :destination => 'bar', + :ensure => ['baz'], + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix virtual - foo') + }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) + end + end + + context 'when sending wrong value for ensure' do + let (:params) { { + :destination => 'bar', + :ensure => 'running', + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix virtual - foo') + }.to raise_error(Puppet::Error, /\$ensure must be either/) + end + end + + context 'when using default values' do + let (:params) { { + :destination => 'bar', + } } + + it { is_expected.to contain_class('postfix::augeas') } + it { is_expected.to contain_augeas('Postfix virtual - foo').with( + :incl => '/etc/postfix/virtual', + :lens => 'Postfix_Virtual.lns', + :changes => [ + "set pattern[. = 'foo'] 'foo'", + "set pattern[. = 'foo']/destination 'bar'", + ]) + } + end + + context 'when overriding default values' do + let (:params) { { + :destination => 'bar', + :file => '/tmp/virtual', + :ensure => 'present', + } } + + it { is_expected.to contain_class('postfix::augeas') } + it { is_expected.to contain_augeas('Postfix virtual - foo').with( + :incl => '/tmp/virtual', + :lens => 'Postfix_Virtual.lns', + :changes => [ + "set pattern[. = 'foo'] 'foo'", + "set pattern[. = 'foo']/destination 'bar'", + ]) + } + end + + context 'when ensuring absence' do + let (:params) { { + :destination => 'bar', + :ensure => 'absent', + } } + + it { is_expected.to contain_class('postfix::augeas') } + it { is_expected.to contain_augeas('Postfix virtual - foo').with( + :incl => '/etc/postfix/virtual', + :lens => 'Postfix_Virtual.lns', + :changes => [ + "rm pattern[. = 'foo']", + ]) + } + end end end - - context 'when using default values' do - let (:params) { { - :destination => 'bar', - } } - - it { is_expected.to contain_class('postfix::augeas') } - it { is_expected.to contain_augeas('Postfix virtual - foo').with( - :incl => '/etc/postfix/virtual', - :lens => 'Postfix_Virtual.lns', - :changes => [ - "set pattern[. = 'foo'] 'foo'", - "set pattern[. = 'foo']/destination 'bar'", - ]) - } - end - - context 'when overriding default values' do - let (:params) { { - :destination => 'bar', - :file => '/tmp/virtual', - :ensure => 'present', - } } - - it { is_expected.to contain_class('postfix::augeas') } - it { is_expected.to contain_augeas('Postfix virtual - foo').with( - :incl => '/tmp/virtual', - :lens => 'Postfix_Virtual.lns', - :changes => [ - "set pattern[. = 'foo'] 'foo'", - "set pattern[. = 'foo']/destination 'bar'", - ]) - } - end - - context 'when ensuring absence' do - let (:params) { { - :destination => 'bar', - :ensure => 'absent', - } } - - it { is_expected.to contain_class('postfix::augeas') } - it { is_expected.to contain_augeas('Postfix virtual - foo').with( - :incl => '/etc/postfix/virtual', - :lens => 'Postfix_Virtual.lns', - :changes => [ - "rm pattern[. = 'foo']", - ]) - } - end end From 37052f43e95934f5ac375e5f7d536186c9cae345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Can=C3=A9vet?= Date: Thu, 26 Mar 2015 11:00:37 +0100 Subject: [PATCH 35/38] Confine rspec pinning to ruby18 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 2cbe1608..57fcd086 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" group :development, :unit_tests do gem 'rake', :require => false - gem 'rspec', '~> 3.1.0', :require => false + gem 'rspec', '< 3.2', :require => false if RUBY_VERSION =~ /^1.8/ gem 'rspec-puppet', :require => false gem 'puppetlabs_spec_helper', :require => false gem 'metadata-json-lint', :require => false From 61761ea01d518cf1563c655787e187777ae56682 Mon Sep 17 00:00:00 2001 From: Ben Hocker Date: Sat, 28 Mar 2015 14:45:15 -0500 Subject: [PATCH 36/38] Cleaning up code - Moving package postfix-ldap to if statement - Trying before package on the /etc/postfix/ldap-aliases.cf file --- manifests/ldap.pp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/manifests/ldap.pp b/manifests/ldap.pp index dbc9fd08..7f75d0b6 100644 --- a/manifests/ldap.pp +++ b/manifests/ldap.pp @@ -14,9 +14,8 @@ # include postfix::ldap # class postfix::ldap { - case $::osfamily { - 'debian': { package {'postfix-ldap': } } - default: {} + if $::osfamily == 'Debian' { + package {'postfix-ldap': } } if ! $postfix::ldap_base { @@ -38,6 +37,6 @@ owner => 'root', group => 'postfix', content => template('postfix/postfix-ldap-aliases.cf.erb'), - #TODO: Figure out if should have require package here + before => Package['postfix-ldap'], } } From 7095378ef32b9b3400ecd3f586895f7aa3162786 Mon Sep 17 00:00:00 2001 From: Ben Hocker Date: Sat, 28 Mar 2015 16:15:08 -0500 Subject: [PATCH 37/38] Updating before --- manifests/ldap.pp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manifests/ldap.pp b/manifests/ldap.pp index 7f75d0b6..679cf1e3 100644 --- a/manifests/ldap.pp +++ b/manifests/ldap.pp @@ -15,7 +15,9 @@ # class postfix::ldap { if $::osfamily == 'Debian' { - package {'postfix-ldap': } + package {'postfix-ldap': + before => File['/etc/postfix/ldap-aliases.cf'], + } } if ! $postfix::ldap_base { @@ -37,6 +39,5 @@ owner => 'root', group => 'postfix', content => template('postfix/postfix-ldap-aliases.cf.erb'), - before => Package['postfix-ldap'], } } From 483bf90cccc5b4da5f02f95ea9fdf599dd712dc7 Mon Sep 17 00:00:00 2001 From: Ben Hocker Date: Sat, 28 Mar 2015 14:45:15 -0500 Subject: [PATCH 38/38] Fixes issue with postfix-ldap package - Should only install on Debian based OS Family - Should not install on RedHat based OS Family --- .sync.yml | 2 + .sync/classes.md | 24 + .sync/simple_usage.md | 22 + CHANGELOG.md | 11 + CONTRIBUTING.md | 8 + Gemfile | 11 +- README.md | 38 +- Rakefile | 14 +- manifests/hash.pp | 7 +- manifests/init.pp | 2 +- manifests/ldap.pp | 8 +- manifests/mta.pp | 2 +- manifests/params.pp | 13 +- manifests/service.pp | 2 +- metadata.json | 5 +- .../nodesets/centos-7-x86_64-openstack.yml | 2 +- .../nodesets/centos-7-x86_64-vagrant.yml | 2 +- .../nodesets/debian-6-x86_64-vagrant.yml | 10 + .../nodesets/debian-7-x86_64-openstack.yml | 2 +- .../nodesets/debian-7-x86_64-vagrant.yml | 3 +- .../nodesets/debian-8-x86_64-openstack.yml | 4 +- .../nodesets/debian-8-x86_64-vagrant.yml | 10 + .../nodesets/ubuntu-14.04-x86_64-vagrant.yml | 10 + spec/classes/postfix_augeas_spec.rb | 45 +- spec/classes/postfix_mailman_spec.rb | 14 + spec/classes/postfix_mta_spec.rb | 21 +- spec/classes/postfix_satellite_spec.rb | 30 +- spec/classes/postfix_spec.rb | 583 ++++++++---------- spec/defines/postfix_config_spec.rb | 155 ++--- spec/defines/postfix_hash_spec.rb | 169 ++--- spec/defines/postfix_transport_spec.rb | 265 ++++---- spec/defines/postfix_virtual_spec.rb | 257 ++++---- 32 files changed, 904 insertions(+), 847 deletions(-) create mode 100644 .sync/classes.md create mode 100644 .sync/simple_usage.md create mode 100644 CONTRIBUTING.md create mode 100644 spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml create mode 100644 spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml create mode 100644 spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml diff --git a/.sync.yml b/.sync.yml index ace7fcbc..563ac7c2 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,3 +1,5 @@ --- .travis.yml: forge_password: "XAv4O363tng0KuRnu1ZhhwORy+2CF9UQwdwlFmS+NG9jOaTZZN+PMK8iC7OSIvZN6cfKlYjHRHNuxFBnYlnMrLsM9fVxt4NjjznOgIKQpQDleWk4UitZj5ntyHmUtYtofUd5Bhi/sdYXwGN9pVRCrcfFBmsIRq/dOhXD7Wy5KcQ=" +#README.md: +# include: ['.sync/simple_usage.md', '.sync/classes.md'] diff --git a/.sync/classes.md b/.sync/classes.md new file mode 100644 index 00000000..1764de09 --- /dev/null +++ b/.sync/classes.md @@ -0,0 +1,24 @@ +## Classes + +### postfix + +The top-level class, to install and configure Postfix. + +## Definitions + +### postfix::config + +Add/alter/remove options in Postfix main configuration file (main.cf) + +### postfix::hash + +Creates Postfix hashed "map" files, and build the corresponding db file. + +### postfix::transport + +Manages content in the transport map. + +### postfix::virtual + +Manages content in the virtual map. + diff --git a/.sync/simple_usage.md b/.sync/simple_usage.md new file mode 100644 index 00000000..34f5e887 --- /dev/null +++ b/.sync/simple_usage.md @@ -0,0 +1,22 @@ +This module requires Augeas. + +## Simple usage + + include postfix + + postfix::config { "relay_domains": value => "localhost host.foo.com" } + +## Exec paths + +In order to not have any path problem, you should add the following line in +some globally included .pp file: + + Exec { + path => '/some/relevant/path:/some/other:...', + } + +For example: + + Exec { + path => '/bin:/sbin:/usr/sbin:/usr/bin', + } diff --git a/CHANGELOG.md b/CHANGELOG.md index 29c65aa9..d4a2ffb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## 2015-03-24 - Release 1.1.1 + +- Various spec improvements + +## 2015-02-19 - Release 1.1.0 + +- Various specs improvements +- Fix specs for postfix::config with ensure => blank +- Simplify relationships and avoid spaceship operators +- nexthop parameter is not necessary for postfix::canonical + ## 2015-01-07 - Release 1.0.5 - Fix unquoted strings in cases diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..2c179eb4 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,8 @@ +# How to contribute + +Please report bugs and feature request using [GitHub issue +tracker](https://github.com/camptocamp/puppet-postfix/issues). + +For pull requests, it is very much appreciated to check your Puppet manifest +with [puppet-lint](https://github.com/rodjek/puppet-lint) to follow the recommended Puppet style guidelines from the +[Puppet Labs style guide](http://docs.puppetlabs.com/guides/style_guide.html). diff --git a/Gemfile b/Gemfile index f0887eca..57fcd086 100644 --- a/Gemfile +++ b/Gemfile @@ -2,8 +2,10 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" group :development, :unit_tests do gem 'rake', :require => false - gem 'rspec-puppet', '~> 2.0', :require => false + gem 'rspec', '< 3.2', :require => false if RUBY_VERSION =~ /^1.8/ + gem 'rspec-puppet', :require => false gem 'puppetlabs_spec_helper', :require => false + gem 'metadata-json-lint', :require => false gem 'puppet-lint', :require => false gem 'puppet-lint-unquoted_string-check', :require => false gem 'puppet-lint-empty_string-check', :require => false @@ -14,15 +16,12 @@ group :development, :unit_tests do gem 'puppet-lint-leading_zero-check', :require => false gem 'puppet-lint-trailing_comma-check', :require => false gem 'puppet-lint-file_ensure-check', :require => false - gem 'simplecov', :require => false + gem 'puppet-lint-version_comparison-check', :require => false gem 'rspec-puppet-facts', :require => false - gem 'json', :require => false - gem 'metadata-json-lint', :require => false - gem 'docker-api', '1.15.0', :require => false end group :system_tests do - gem 'beaker', :require => false, :git => 'https://github.com/raphink/beaker', :branch => 'openstack' + gem 'beaker', :require => false gem 'beaker-rspec', :require => false gem 'serverspec', :require => false end diff --git a/README.md b/README.md index 3672aaf3..7ac19f93 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ -# Postfix module for Puppet +# Postfix Puppet Module -[![Puppet Forge](http://img.shields.io/puppetforge/v/camptocamp/postfix.svg)](https://forge.puppetlabs.com/camptocamp/postfix) -[![Build Status](https://travis-ci.org/camptocamp/puppet-postfix.png?branch=master)](https://travis-ci.org/camptocamp/puppet-postfix) - -**Manages Postfix configuration.** - -This module is provided by [Camptocamp](http://www.camptocamp.com/) +[![Puppet Forge Version](http://img.shields.io/puppetforge/v/camptocamp/postfix.svg)](https://forge.puppetlabs.com/camptocamp/postfix) +[![Puppet Forge Downloads](http://img.shields.io/puppetforge/dt/camptocamp/postfix.svg)](https://forge.puppetlabs.com/camptocamp/postfix) +[![Build Status](https://img.shields.io/travis/camptocamp/puppet-postfix/master.svg)](https://travis-ci.org/camptocamp/puppet-postfix) +[![Gemnasium](https://img.shields.io/gemnasium/camptocamp/puppet-postfix.svg)](https://gemnasium.com/camptocamp/puppet-postfix) +[![By Camptocamp](https://img.shields.io/badge/by-camptocamp-fb7047.svg)](http://www.camptocamp.com) This module requires Augeas. @@ -54,29 +53,4 @@ Manages content in the transport map. Manages content in the virtual map. -## Contributing - -Please report bugs and feature request using [GitHub issue -tracker](https://github.com/camptocamp/puppet-postfix/issues). - -For pull requests, it is very much appreciated to check your Puppet manifest -with [puppet-lint](https://github.com/camptocamp/puppet-postfix/issues) to follow the recommended Puppet style guidelines from the -[Puppet Labs style guide](http://docs.puppetlabs.com/guides/style_guide.html). - -## License - -Copyright (c) 2013 All rights reserved. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . diff --git a/Rakefile b/Rakefile index a334275d..f87e6088 100644 --- a/Rakefile +++ b/Rakefile @@ -2,14 +2,10 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' Rake::Task[:lint].clear -PuppetLint.configuration.fail_on_warnings -PuppetLint.configuration.send('relative') -PuppetLint.configuration.send('disable_80chars') -PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp", "vendor/**/*.pp"] +PuppetLint::RakeTask.new :lint do |config| + config.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp", "vendor/**/*.pp"] + config.disable_checks = ['80chars'] + config.fail_on_warnings = true +end PuppetSyntax.exclude_paths = ["spec/fixtures/**/*.pp", "vendor/**/*"] - -desc "Lint metadata.json file" -task :metadata do - sh "metadata-json-lint metadata.json" -end diff --git a/manifests/hash.pp b/manifests/hash.pp index 076f7450..1d5e6300 100644 --- a/manifests/hash.pp +++ b/manifests/hash.pp @@ -31,8 +31,10 @@ include ::postfix::params validate_absolute_path($name) - validate_string($source) - validate_string($content) +# validate_string($source) +# validate_string($content) + if !is_string($source) and !is_array($source) { fail("value for source should be either String type or Array type got ${source}") } + if !is_string($content) and !is_array($content) { fail("value for source should be either String type or Array type got ${content}") } validate_string($ensure) validate_re($ensure, ['present', 'absent'], "\$ensure must be either 'present' or 'absent', got '${ensure}'") @@ -66,6 +68,7 @@ exec {"generate ${name}.db": command => "postmap ${name}", + path => $::path, #creates => "${name}.db", # this prevents postmap from being run ! subscribe => File[$name], refreshonly => true, diff --git a/manifests/init.pp b/manifests/init.pp index db2a097a..0af6148b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -82,7 +82,7 @@ $master_submission = undef, # postfix_master_submission $mta = false, $mydestination = '$myorigin', # postfix_mydestination - $mynetworks = '127.0.0.0/8', # postfix_mynetworks + $mynetworks = '127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128', # postfix_mynetworks $myorigin = $::fqdn, $relayhost = undef, # postfix_relayhost $root_mail_recipient = 'nobody', # root_mail_recipient diff --git a/manifests/ldap.pp b/manifests/ldap.pp index dbc9fd08..679cf1e3 100644 --- a/manifests/ldap.pp +++ b/manifests/ldap.pp @@ -14,9 +14,10 @@ # include postfix::ldap # class postfix::ldap { - case $::osfamily { - 'debian': { package {'postfix-ldap': } } - default: {} + if $::osfamily == 'Debian' { + package {'postfix-ldap': + before => File['/etc/postfix/ldap-aliases.cf'], + } } if ! $postfix::ldap_base { @@ -38,6 +39,5 @@ owner => 'root', group => 'postfix', content => template('postfix/postfix-ldap-aliases.cf.erb'), - #TODO: Figure out if should have require package here } } diff --git a/manifests/mta.pp b/manifests/mta.pp index 7df275eb..b96927d1 100644 --- a/manifests/mta.pp +++ b/manifests/mta.pp @@ -35,7 +35,7 @@ 'Wrong value for $relayhost') validate_re($mydestination, '^\S+(?:,\s*\S+)*$', 'Wrong value for $mydestination') - validate_re($mynetworks, '^\S+$', + validate_re($mynetworks, '^(?:\S+?(?:(?:,\s)|(?:\s))?)*$', 'Wrong value for $mynetworks') # If direct is specified then relayhost should be blank diff --git a/manifests/params.pp b/manifests/params.pp index dde5339d..74e55d79 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -7,6 +7,11 @@ default => undef, } + $restart_cmd = $::operatingsystemmajrelease ? { + '7' => '/bin/systemctl reload postfix', + default => '/etc/init.d/postfix reload', + } + $mailx_package = 'mailx' $master_os_template = "${module_name}/master.cf.redhat.erb" @@ -15,9 +20,11 @@ 'Debian': { $seltype = undef + $restart_cmd = '/etc/init.d/postfix reload' + $mailx_package = $::lsbdistcodename ? { - /sarge|etch|lenny|lucid/ => 'mailx', - default => 'bsd-mailx', + /sarge|etch|lenny/ => 'mailx', + default => 'bsd-mailx', } $master_os_template = "${module_name}/master.cf.debian.erb" @@ -26,6 +33,8 @@ 'Suse': { $seltype = undef + $restart_cmd = '/etc/init.d/postfix reload' + $mailx_package = 'mailx' if $::operatingsystem != 'SLES' { diff --git a/manifests/service.pp b/manifests/service.pp index c3f185da..9d56cd2e 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -3,6 +3,6 @@ ensure => running, enable => true, hasstatus => true, - restart => '/etc/init.d/postfix reload', + restart => $::postfix::params::restart_cmd, } } diff --git a/metadata.json b/metadata.json index 1dcc0576..c50c05d2 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "camptocamp-postfix", - "version": "1.0.5", + "version": "1.1.1", "author": "Camptocamp", "summary": "Camptocamp Postfix Module", "license": "Apache-2.0", @@ -48,7 +48,8 @@ "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", - "6" + "6", + "7" ] } ], diff --git a/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml b/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml index 37dfc5f9..2036c0b8 100644 --- a/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml +++ b/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml @@ -4,7 +4,7 @@ HOSTS: strict_variables: platform: el-7-x86_64 hypervisor : openstack - flavor: m1.small + flavor: m1.medium image: centos-7-x86_64-genericcloud-20140929_01 user: centos CONFIG: diff --git a/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml b/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml index a9c461ba..fe0f83b8 100644 --- a/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml +++ b/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml @@ -4,7 +4,7 @@ HOSTS: strict_variables: platform: el-7-x86_64 hypervisor : vagrant - box : puppetlabs/centos-6.5-64-nocm + box : puppetlabs/centos-7.0-64-nocm CONFIG: type: foss log_level: debug diff --git a/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml new file mode 100644 index 00000000..23dae1b0 --- /dev/null +++ b/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml @@ -0,0 +1,10 @@ +HOSTS: + debian-6-x64: + default_apply_opts: + strict_variables: + platform: debian-6-amd64 + hypervisor : vagrant + box : puppetlabs/debian-6.0.10-64-nocm +CONFIG: + type: foss + log_level: debug diff --git a/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml b/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml index e52336be..c44f917e 100644 --- a/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml +++ b/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml @@ -4,7 +4,7 @@ HOSTS: strict_variables: platform: debian-7-amd64 hypervisor : openstack - flavor: m1.small + flavor: m1.medium image: debian-7-amd64-20141121 user: debian CONFIG: diff --git a/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml index 97099de3..86c2165d 100644 --- a/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml +++ b/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml @@ -4,8 +4,7 @@ HOSTS: strict_variables: platform: debian-7-amd64 hypervisor : vagrant - box : debian-73-x64-virtualbox-nocm - box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-nocm.box + box : puppetlabs/debian-7.8-64-nocm CONFIG: type: foss log_level: debug diff --git a/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml b/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml index 194ca460..f7b2e500 100644 --- a/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml +++ b/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml @@ -4,10 +4,10 @@ HOSTS: strict_variables: platform: debian-8-amd64 hypervisor : openstack - flavor: m1.small + flavor: m1.medium image: debian-8-amd64-20141121 user: debian CONFIG: type: foss - openstack_network: default log_level: debug + openstack_network: default diff --git a/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml new file mode 100644 index 00000000..38c844be --- /dev/null +++ b/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml @@ -0,0 +1,10 @@ +HOSTS: + debian-8-x64: + default_apply_opts: + strict_variables: + platform: debian-8-amd64 + hypervisor : vagrant + box : camptocamp/debian-8-amd64 +CONFIG: + type: foss + log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml new file mode 100644 index 00000000..a3edb70f --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml @@ -0,0 +1,10 @@ +HOSTS: + ubuntu-14.04-x64: + default_apply_opts: + strict_variables: + platform: ubuntu-14.04-amd64 + hypervisor : vagrant + box : puppetlabs/ubuntu-14.04-64-nocm +CONFIG: + type: foss + log_level: debug diff --git a/spec/classes/postfix_augeas_spec.rb b/spec/classes/postfix_augeas_spec.rb index ff068e9b..4ea74766 100644 --- a/spec/classes/postfix_augeas_spec.rb +++ b/spec/classes/postfix_augeas_spec.rb @@ -1,28 +1,33 @@ require 'spec_helper' describe 'postfix::augeas' do - let (:facts) { { - :augeasversion => '1.2.0', - :lsbdistcodename => 'wheezy', - :operatingsystem => 'Debian', - :osfamily => 'Debian', - :rubyversion => '1.9.3', - :path => '/foo/bar', - } } + let :pre_condition do "include ::augeas" end - it { is_expected.to contain_augeas__lens('postfix_transport').with( - :ensure => 'present', - :lens_source => 'puppet:///modules/postfix/lenses/postfix_transport.aug', - :test_source => 'puppet:///modules/postfix/lenses/test_postfix_transport.aug', - :stock_since => '1.0.0' - ) } - it { is_expected.to contain_augeas__lens('postfix_virtual').with( - :ensure => 'present', - :lens_source => 'puppet:///modules/postfix/lenses/postfix_virtual.aug', - :test_source => 'puppet:///modules/postfix/lenses/test_postfix_virtual.aug', - :stock_since => '1.0.0' - ) } + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ + :augeasversion => '1.2.0', + }) + end + + it { is_expected.to compile.with_all_deps } + + it { is_expected.to contain_augeas__lens('postfix_transport').with({ + :ensure => 'present', + :lens_source => 'puppet:///modules/postfix/lenses/postfix_transport.aug', + :test_source => 'puppet:///modules/postfix/lenses/test_postfix_transport.aug', + :stock_since => '1.0.0', + } ) } + it { is_expected.to contain_augeas__lens('postfix_virtual').with({ + :ensure => 'present', + :lens_source => 'puppet:///modules/postfix/lenses/postfix_virtual.aug', + :test_source => 'puppet:///modules/postfix/lenses/test_postfix_virtual.aug', + :stock_since => '1.0.0', + }) } + end + end end diff --git a/spec/classes/postfix_mailman_spec.rb b/spec/classes/postfix_mailman_spec.rb index 15217b46..86623d33 100644 --- a/spec/classes/postfix_mailman_spec.rb +++ b/spec/classes/postfix_mailman_spec.rb @@ -1,4 +1,18 @@ require 'spec_helper' describe 'postfix::mailman' do + + let :pre_condition do + "include ::postfix" + end + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts + end + + it { is_expected.to compile.with_all_deps } + end + end end diff --git a/spec/classes/postfix_mta_spec.rb b/spec/classes/postfix_mta_spec.rb index 395beaed..c6be6c75 100644 --- a/spec/classes/postfix_mta_spec.rb +++ b/spec/classes/postfix_mta_spec.rb @@ -1,19 +1,24 @@ require 'spec_helper' describe 'postfix::mta' do - let (:facts) { { - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - } } let :pre_condition do "class { 'postfix': mydestination => 'bar', - mynetworks => 'baz', + mynetworks => '127.0.0.1/8, [::1]/128 ![::2]/128', relayhost => 'foo', }" end - it { is_expected.to contain_postfix__config('mydestination').with_value('bar') } - it { is_expected.to contain_postfix__config('mynetworks').with_value('baz') } - it { is_expected.to contain_postfix__config('relayhost').with_value('foo') } + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts + end + + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_postfix__config('mydestination').with_value('bar') } + it { is_expected.to contain_postfix__config('mynetworks').with_value('127.0.0.1/8, [::1]/128 ![::2]/128') } + it { is_expected.to contain_postfix__config('relayhost').with_value('foo') } + end + end end diff --git a/spec/classes/postfix_satellite_spec.rb b/spec/classes/postfix_satellite_spec.rb index a3cf4d53..ac9489ec 100644 --- a/spec/classes/postfix_satellite_spec.rb +++ b/spec/classes/postfix_satellite_spec.rb @@ -1,14 +1,6 @@ require 'spec_helper' describe 'postfix::satellite' do - let (:node) { 'foo.example.com' } - let (:facts) { { - :augeasversion => '1.2.0', - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - :rubyversion => '1.9.3', - :path => '/foo/bar', - } } let :pre_condition do " class { 'augeas': } class { 'postfix': @@ -17,9 +9,21 @@ class { 'postfix': mynetworks => 'baz', }" end - it { is_expected.to contain_class('postfix::mta') } - it { is_expected.to contain_postfix__virtual('@foo.example.com').with( - :ensure => 'present', - :destination => 'root' - ) } + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ + :augeasversion => '1.2.0', + }) + end + + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_class('postfix::mta') } + it { is_expected.to contain_postfix__virtual('@foo.example.com').with( + :ensure => 'present', + :destination => 'root' + ) } + end + end end diff --git a/spec/classes/postfix_spec.rb b/spec/classes/postfix_spec.rb index e5fe635c..878ecf51 100644 --- a/spec/classes/postfix_spec.rb +++ b/spec/classes/postfix_spec.rb @@ -1,352 +1,283 @@ require 'spec_helper' describe 'postfix' do - context 'when using defaults' do - context 'when on Debian' do - let (:facts) { { - :lsbdistcodename => 'wheezy', - :operatingsystem => 'Debian', - :osfamily => 'Debian', - :fqdn => 'fqdn.example.com', - :path => '/foo/bar', - } } - it { is_expected.to contain_package('postfix') } - it { is_expected.to contain_package('mailx') } - - it { is_expected.to contain_file('/etc/mailname').without('seltype').with_content("fqdn.example.com\n") } - it { is_expected.to contain_file('/etc/aliases').without('seltype').with_content("# file managed by puppet\n") } - it { is_expected.to contain_exec('newaliases').with_refreshonly('true') } - it { is_expected.to contain_file('/etc/postfix/master.cf').without('seltype') } - it { is_expected.to contain_file('/etc/postfix/main.cf').without('seltype') } - - it { is_expected.to contain_postfix__config('myorigin').with_value('fqdn.example.com') } - it { is_expected.to contain_postfix__config('alias_maps').with_value('hash:/etc/aliases') } - it { is_expected.to contain_postfix__config('inet_interfaces').with_value('all') } - - it { is_expected.to contain_mailalias('root').with_recipient('nobody') } - - it { - is_expected.to contain_service('postfix').with( - :ensure => 'running', - :enable => 'true', - :hasstatus => 'true', - :restart => '/etc/init.d/postfix reload' - ) } - end - - context 'when on RedHat' do - let (:facts) { { - :lsbdistcodename => 'Maipo', - :fqdn => 'fqdn.example.com', - :operatingsystem => 'RedHat', - :operatingsystemmajrelease => '7', - :osfamily => 'RedHat', - :path => '/foo/bar', - } } - - it { is_expected.to contain_package('postfix') } - it { is_expected.to contain_package('mailx') } - - it { is_expected.to contain_file('/etc/mailname').with_seltype('postfix_etc_t').with_content("fqdn.example.com\n") } - it { is_expected.to contain_file('/etc/aliases').with_seltype('postfix_etc_t').with_content("# file managed by puppet\n") } - it { is_expected.to contain_exec('newaliases').with_refreshonly('true') } - it { is_expected.to contain_file('/etc/postfix/master.cf').with_seltype('postfix_etc_t') } - it { is_expected.to contain_file('/etc/postfix/main.cf').with_seltype('postfix_etc_t') } - - it { is_expected.to contain_postfix__config('myorigin').with_value('fqdn.example.com') } - it { is_expected.to contain_postfix__config('alias_maps').with_value('hash:/etc/aliases') } - it { is_expected.to contain_postfix__config('inet_interfaces').with_value('all') } - it { is_expected.to contain_postfix__config('sendmail_path') } - it { is_expected.to contain_postfix__config('newaliases_path') } - it { is_expected.to contain_postfix__config('mailq_path') } - - it { is_expected.to contain_mailalias('root').with_recipient('nobody') } - - it { - is_expected.to contain_service('postfix').with( - :ensure => 'running', - :enable => 'true', - :hasstatus => 'true', - :restart => '/etc/init.d/postfix reload' - ) } - end - end - - context 'when setting parameters' do - context 'when on Debian' do - context "when setting smtp_listen to 'all'" do - let (:facts) { { - :lsbdistcodename => 'wheezy', - :operatingsystem => 'Debian', - :osfamily => 'Debian', - :fqdn => 'fqdn.example.com', - :path => '/foo/bar', - } } - - let (:params) { { - :smtp_listen => 'all', - :root_mail_recipient => 'foo', - :use_amavisd => true, - :use_dovecot_lda => true, - :use_schleuder => true, - :use_sympa => true, - :mail_user => 'bar', - :myorigin => 'localhost', - :inet_interfaces => 'localhost2', - :master_smtp => "smtp inet n - - - - smtpd - -o smtpd_client_restrictions=check_client_access,hash:/etc/postfix/access,reject", - :master_smtps => 'smtps inet n - - - - smtpd', - :master_submission => 'submission inet n - - - - smtpd', - } } + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ + :augeasversion => '1.2.0', + }) + end + context 'when using defaults' do it { is_expected.to contain_package('postfix') } it { is_expected.to contain_package('mailx') } - - it { is_expected.to contain_file('/etc/mailname').without('seltype').with_content("fqdn.example.com\n") } - it { is_expected.to contain_file('/etc/aliases').without('seltype').with_content("# file managed by puppet\n") } it { is_expected.to contain_exec('newaliases').with_refreshonly('true') } - it { - is_expected.to contain_file('/etc/postfix/master.cf').without('seltype').with_content( - /smtp inet n - - - - smtpd/ - ).with_content( - /amavis unix/ - ).with_content( - /dovecot.*\n.* user=bar:bar / - ).with_content( - /schleuder/ - ).with_content( - /sympa/ - ).with_content( - /user=bar/ - ).with_content( - /^smtp.*\n.*smtpd_client_restrictions=check_client_access,hash:/ - ).with_content( - /^smtps inet n/ - ).with_content( - /^submission inet n/ - ) - } - it { is_expected.to contain_file('/etc/postfix/main.cf').without('seltype') } - - it { is_expected.to contain_postfix__config('myorigin').with_value('localhost') } + it { is_expected.to contain_postfix__config('myorigin').with_value('foo.example.com') } it { is_expected.to contain_postfix__config('alias_maps').with_value('hash:/etc/aliases') } - it { is_expected.to contain_postfix__config('inet_interfaces').with_value('localhost2') } + it { is_expected.to contain_postfix__config('inet_interfaces').with_value('all') } + it { is_expected.to contain_mailalias('root').with_recipient('nobody') } - it { is_expected.to contain_mailalias('root').with_recipient('foo') } + case facts[:osfamily] + when 'Debian' + it { is_expected.to contain_file('/etc/mailname').without('seltype').with_content("foo.example.com\n") } + it { is_expected.to contain_file('/etc/aliases').without('seltype').with_content("# file managed by puppet\n") } + it { is_expected.to contain_file('/etc/postfix/master.cf').without('seltype') } + it { is_expected.to contain_file('/etc/postfix/main.cf').without('seltype') } - it { - is_expected.to contain_service('postfix').with( - :ensure => 'running', - :enable => 'true', - :hasstatus => 'true', - :restart => '/etc/init.d/postfix reload' - ) } - end - end - context 'when on RedHat' do - let (:facts) { { - :augeasversion => '1.2.0', - :lsbdistcodename => 'wheezy', - :operatingsystem => 'Debian', - :osfamily => 'Debian', - :rubyversion => '1.9.7', - :fqdn => 'fqdn.example.com', - :path => '/foo/bar', - } } - context 'when specifying inet_interfaces' do - let (:params) { { - :inet_interfaces => 'localhost2' - } } - it 'should create a postfix::config defined type with inet_interfaces specified properly' do - is_expected.to contain_postfix__config('inet_interfaces').with_value('localhost2') + it { + is_expected.to contain_service('postfix').with( + :ensure => 'running', + :enable => 'true', + :hasstatus => 'true', + :restart => '/etc/init.d/postfix reload' + ) } + else + it { is_expected.to contain_file('/etc/mailname').with_seltype('postfix_etc_t').with_content("foo.example.com\n") } + it { is_expected.to contain_file('/etc/aliases').with_seltype('postfix_etc_t').with_content("# file managed by puppet\n") } + it { is_expected.to contain_file('/etc/postfix/master.cf').with_seltype('postfix_etc_t') } + it { is_expected.to contain_file('/etc/postfix/main.cf').with_seltype('postfix_etc_t') } + + it { is_expected.to contain_postfix__config('sendmail_path') } + it { is_expected.to contain_postfix__config('newaliases_path') } + it { is_expected.to contain_postfix__config('mailq_path') } + + case facts[:operatingsystemmajrelease] + when '7' + it { + is_expected.to contain_service('postfix').with( + :ensure => 'running', + :enable => 'true', + :hasstatus => 'true', + :restart => '/bin/systemctl reload postfix' + ) } + else + it { + is_expected.to contain_service('postfix').with( + :ensure => 'running', + :enable => 'true', + :hasstatus => 'true', + :restart => '/etc/init.d/postfix reload' + ) } + end end end - context 'when enabling ldap' do - context 'when on Debian' do - let (:params) { { - :ldap => true, - :ldap_base => 'dc=example,dc=com', - :ldap_host => 'host.example.com', - } } - let (:facts) { { - :operatingsystem => 'Debian', - :osfamily => 'Debian', - :fqdn => 'fqdn.example.com', - :lsbdistcodename => 'wheezy', - } } + context 'when setting parameters' do + case facts[:osfamily] + when 'Debian' + context "when setting smtp_listen to 'all'" do + let (:params) { { + :smtp_listen => 'all', + :root_mail_recipient => 'foo', + :use_amavisd => true, + :use_dovecot_lda => true, + :use_schleuder => true, + :use_sympa => true, + :mail_user => 'bar', + :myorigin => 'localhost', + :inet_interfaces => 'localhost2', + :master_smtp => "smtp inet n - - - - smtpd + -o smtpd_client_restrictions=check_client_access,hash:/etc/postfix/access,reject", + :master_smtps => 'smtps inet n - - - - smtpd', + :master_submission => 'submission inet n - - - - smtpd', + } } - it { should contain_package('postfix-ldap') } + it { is_expected.to contain_package('postfix') } + it { is_expected.to contain_package('mailx') } - it { should contain_file('/etc/postfix/ldap-aliases.cf').with( - :owner => 'root', - :group => 'postfix' ).with_content(/search_base = /) - } - end + it { is_expected.to contain_file('/etc/mailname').without('seltype').with_content("foo.example.com\n") } + it { is_expected.to contain_file('/etc/aliases').without('seltype').with_content("# file managed by puppet\n") } + it { is_expected.to contain_exec('newaliases').with_refreshonly('true') } + it { + is_expected.to contain_file('/etc/postfix/master.cf').without('seltype').with_content( + /smtp inet n - - - - smtpd/ + ).with_content( + /amavis unix/ + ).with_content( + /dovecot.*\n.* user=bar:bar / + ).with_content( + /schleuder/ + ).with_content( + /sympa/ + ).with_content( + /user=bar/ + ).with_content( + /^smtp.*\n.*smtpd_client_restrictions=check_client_access,hash:/ + ).with_content( + /^smtps inet n/ + ).with_content( + /^submission inet n/ + ) + } + it { is_expected.to contain_file('/etc/postfix/main.cf').without('seltype') } - context 'when on RedHat' do - let (:params) { { - :ldap => true, - :ldap_base => 'dc=example,dc=com', - :ldap_host => 'host.example.com', - } } + it { is_expected.to contain_postfix__config('myorigin').with_value('localhost') } + it { is_expected.to contain_postfix__config('alias_maps').with_value('hash:/etc/aliases') } + it { is_expected.to contain_postfix__config('inet_interfaces').with_value('localhost2') } - let (:facts) { { - :operatingsystem => 'RedHat', - :osfamily => 'RedHat', - :operatingsystemmajrelease => '7', - :lsbdistcodename => 'Maipo', - :fqdn => 'fqdn.example.com', - } } + it { is_expected.to contain_mailalias('root').with_recipient('foo') } - it do - expect { - should_not contain_package('postfix-ldap') - } + it { + is_expected.to contain_service('postfix').with( + :ensure => 'running', + :enable => 'true', + :hasstatus => 'true', + :restart => '/etc/init.d/postfix reload' + ) } end - - it { should contain_file('/etc/postfix/ldap-aliases.cf').with( - :owner => 'root', - :group => 'postfix').with_content(/search_base = /) - } - end - end - context 'when a custom mail_user is specified' do - let (:params) { { - :mail_user => 'bar' - } } - it 'should adjust the content of /etc/postfix/master.cf specifying the user' do - is_expected.to contain_file('/etc/postfix/master.cf').without('seltype').with_content(/user=bar/) - end - end - context 'when mailman is true' do - let (:params) { { - :mailman => true - } } - it 'should do stuff' do - skip 'need to write this still' - end - end - context 'when specifying a custom mastercf_source' do - let (:params) { { - :mastercf_source => 'testy' - } } - it 'should do stuff' do - skip 'need to write this still' - end - end - context 'when specifying a custom master_smtp' do - let (:params) { { - :master_smtp => "smtp inet n - - - - smtpd + else + context 'when specifying inet_interfaces' do + let (:params) { { + :inet_interfaces => 'localhost2' + } } + it 'should create a postfix::config defined type with inet_interfaces specified properly' do + is_expected.to contain_postfix__config('inet_interfaces').with_value('localhost2') + end + end + context 'when enabling ldap' do + it 'should do stuff' do + skip 'need to write this still' + end + end + context 'when a custom mail_user is specified' do + let (:params) { { + :mail_user => 'bar' + } } + it 'should adjust the content of /etc/postfix/master.cf specifying the user' do + is_expected.to contain_file('/etc/postfix/master.cf').with_seltype('postfix_etc_t').with_content(/user=bar/) + end + end + context 'when mailman is true' do + let (:params) { { + :mailman => true + } } + it 'should do stuff' do + skip 'need to write this still' + end + end + context 'when specifying a custom mastercf_source' do + let (:params) { { + :mastercf_source => 'testy' + } } + it 'should do stuff' do + skip 'need to write this still' + end + end + context 'when specifying a custom master_smtp' do + let (:params) { { + :master_smtp => "smtp inet n - - - - smtpd -o smtpd_client_restrictions=check_client_access,hash:/etc/postfix/access,reject", - } } - it 'should update master.cf with the specified flags to smtp' do - is_expected.to contain_file('/etc/postfix/master.cf').without('seltype').with_content( - /smtp inet n - - - - smtpd/).with_content( - /^smtp.*\n.*smtpd_client_restrictions=check_client_access,hash:/ - ) - end - end - context 'when specifying a custom master_smtps' do - let (:params) { { - :master_smtps => 'smtps inet n - - - - smtpd' - } } - it 'should update master.cf with the specified flags to smtps' do - is_expected.to contain_file('/etc/postfix/master.cf').with_content(/^smtps inet n/) - end - end - context 'when mta is enabled' do - let (:params) { { :mta => true, :mydestination => '1.2.3.4', :relayhost => '2.3.4.5' } } - it 'should configure postfix as a minimal MTA, delivering mail to the mydestination param' do - is_expected.to contain_postfix__config('mydestination').with_value('1.2.3.4') - is_expected.to contain_postfix__config('mynetworks').with_value('127.0.0.0/8') - is_expected.to contain_postfix__config('relayhost').with_value('2.3.4.5') - is_expected.to contain_postfix__config('virtual_alias_maps').with_value('hash:/etc/postfix/virtual') - is_expected.to contain_postfix__config('transport_maps').with_value('hash:/etc/postfix/transport') - end - it { is_expected.to contain_class('postfix::mta') } - context 'and satellite is also enabled' do - let (:params) { { :mta => true, :satellite => true, :mydestination => '1.2.3.4', :relayhost => '2.3.4.5' } } - it 'should fail' do - expect { should compile }.to raise_error(/Please disable one/) + } } + it 'should update master.cf with the specified flags to smtp' do + is_expected.to contain_file('/etc/postfix/master.cf').with_seltype('postfix_etc_t').with_content( + /smtp inet n - - - - smtpd/).with_content( + /^smtp.*\n.*smtpd_client_restrictions=check_client_access,hash:/ + ) + end end - end - end - context 'when specifying mydesitination' do - it 'should do stuff' do - skip 'need to write this still' - end - end - context 'when specifying mynetworks' do - it 'should do stuff' do - skip 'need to write this still' - end - end - context 'when specifying myorigin' do - let (:params) { { :myorigin => 'localhost'} } - it 'should create a postfix::config defined type with myorigin specified properly' do - is_expected.to contain_postfix__config('myorigin').with_value('localhost') - end - end - context 'when specifying relayhost' do - it 'should do stuff' do - skip 'need to write this still' - end - end - context 'when specifying a root_mail_recipient' do - let (:params) { { :root_mail_recipient => 'foo'} } - it 'should contain a Mailalias resource directing roots mail to the required user' do - is_expected.to contain_mailalias('root').with_recipient('foo') - end - end - context 'when specifying satellite' do - let (:params) { { :satellite => true, :mydestination => '1.2.3.4', :relayhost => '2.3.4.5' } } - let :pre_condition do - "class { 'augeas': }" - end - it 'should configure all local email to be forwarded to $root_mail_recipient delivered through $relayhost' do - is_expected.to contain_postfix__config('mydestination').with_value('1.2.3.4') - is_expected.to contain_postfix__config('mynetworks').with_value('127.0.0.0/8') - is_expected.to contain_postfix__config('relayhost').with_value('2.3.4.5') - is_expected.to contain_postfix__config('virtual_alias_maps').with_value('hash:/etc/postfix/virtual') - is_expected.to contain_postfix__config('transport_maps').with_value('hash:/etc/postfix/transport') - end - context 'and mta is also enabled' do - let (:params) { { :mta => true, :satellite => true, :mydestination => '1.2.3.4', :relayhost => '2.3.4.5' } } - it 'should fail' do - expect { should compile }.to raise_error(/Please disable one/) + context 'when specifying a custom master_smtps' do + let (:params) { { + :master_smtps => 'smtps inet n - - - - smtpd' + } } + it 'should update master.cf with the specified flags to smtps' do + is_expected.to contain_file('/etc/postfix/master.cf').with_content(/^smtps inet n/) + end + end + context 'when mta is enabled' do + let (:params) { { :mta => true, :mydestination => '1.2.3.4', :relayhost => '2.3.4.5' } } + it 'should configure postfix as a minimal MTA, delivering mail to the mydestination param' do + is_expected.to contain_postfix__config('mydestination').with_value('1.2.3.4') + is_expected.to contain_postfix__config('mynetworks').with_value('127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128') + is_expected.to contain_postfix__config('relayhost').with_value('2.3.4.5') + is_expected.to contain_postfix__config('virtual_alias_maps').with_value('hash:/etc/postfix/virtual') + is_expected.to contain_postfix__config('transport_maps').with_value('hash:/etc/postfix/transport') + end + it { is_expected.to contain_class('postfix::mta') } + context 'and satellite is also enabled' do + let (:params) { { :mta => true, :satellite => true, :mydestination => '1.2.3.4', :relayhost => '2.3.4.5' } } + it 'should fail' do + expect { should compile }.to raise_error(/Please disable one/) + end + end + end + context 'when specifying mydesitination' do + it 'should do stuff' do + skip 'need to write this still' + end + end + context 'when specifying mynetworks' do + it 'should do stuff' do + skip 'need to write this still' + end + end + context 'when specifying myorigin' do + let (:params) { { :myorigin => 'localhost'} } + it 'should create a postfix::config defined type with myorigin specified properly' do + is_expected.to contain_postfix__config('myorigin').with_value('localhost') + end + end + context 'when specifying relayhost' do + it 'should do stuff' do + skip 'need to write this still' + end + end + context 'when specifying a root_mail_recipient' do + let (:params) { { :root_mail_recipient => 'foo'} } + it 'should contain a Mailalias resource directing roots mail to the required user' do + is_expected.to contain_mailalias('root').with_recipient('foo') + end + end + context 'when specifying satellite' do + let (:params) { { :satellite => true, :mydestination => '1.2.3.4', :relayhost => '2.3.4.5' } } + let :pre_condition do + "class { 'augeas': }" + end + it 'should configure all local email to be forwarded to $root_mail_recipient delivered through $relayhost' do + is_expected.to contain_postfix__config('mydestination').with_value('1.2.3.4') + is_expected.to contain_postfix__config('mynetworks').with_value('127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128') + is_expected.to contain_postfix__config('relayhost').with_value('2.3.4.5') + is_expected.to contain_postfix__config('virtual_alias_maps').with_value('hash:/etc/postfix/virtual') + is_expected.to contain_postfix__config('transport_maps').with_value('hash:/etc/postfix/transport') + end + context 'and mta is also enabled' do + let (:params) { { :mta => true, :satellite => true, :mydestination => '1.2.3.4', :relayhost => '2.3.4.5' } } + it 'should fail' do + expect { should compile }.to raise_error(/Please disable one/) + end + end + end + context 'when specifying smtp_listen' do + let (:params) { { :smtp_listen => 'all' } } + it 'should do stuff' do + skip 'need to write this still' + end + end + context 'when use_amavisd is true' do + let (:params) { { :use_amavisd => true } } + it 'should update master.cf with the specified flags to amavis' do + is_expected.to contain_file('/etc/postfix/master.cf').with_content(/amavis unix/) + end + end + context 'when use_dovecot_lda is true' do + let (:params) { { :use_dovecot_lda => true } } + it 'should update master.cf with the specified flags to dovecot' do + is_expected.to contain_file('/etc/postfix/master.cf').with_content(/dovecot.*\n.* user=vmail:vmail /) + end + end + context 'when use_schleuder is true' do + let (:params) { { :use_schleuder => true } } + it 'should update master.cf with the specified flags to schleuder' do + is_expected.to contain_file('/etc/postfix/master.cf').with_content(/schleuder/) + end + end + context 'when use_sympa is true' do + let (:params) { { :use_sympa => true } } + it 'should update master.cf to include sympa' do + is_expected.to contain_file('/etc/postfix/master.cf').with_content(/sympa/) + end end - end - end - context 'when specifying smtp_listen' do - let (:params) { { :smtp_listen => 'all' } } - it 'should do stuff' do - skip 'need to write this still' - end - end - context 'when use_amavisd is true' do - let (:params) { { :use_amavisd => true } } - it 'should update master.cf with the specified flags to amavis' do - is_expected.to contain_file('/etc/postfix/master.cf').with_content(/amavis unix/) - end - end - context 'when use_dovecot_lda is true' do - let (:params) { { :use_dovecot_lda => true } } - it 'should update master.cf with the specified flags to dovecot' do - is_expected.to contain_file('/etc/postfix/master.cf').with_content(/dovecot.*\n.* user=vmail:vmail /) - end - end - context 'when use_schleuder is true' do - let (:params) { { :use_schleuder => true } } - it 'should update master.cf with the specified flags to schleuder' do - is_expected.to contain_file('/etc/postfix/master.cf').with_content(/schleuder/) - end - end - context 'when use_sympa is true' do - let (:params) { { :use_sympa => true } } - it 'should update master.cf to include sympa' do - is_expected.to contain_file('/etc/postfix/master.cf').with_content(/sympa/) end end end diff --git a/spec/defines/postfix_config_spec.rb b/spec/defines/postfix_config_spec.rb index 75c8edd5..2fe17840 100644 --- a/spec/defines/postfix_config_spec.rb +++ b/spec/defines/postfix_config_spec.rb @@ -2,93 +2,98 @@ describe 'postfix::config' do let (:title) { 'foo' } - let (:facts) { { - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - } } + let :pre_condition do "class { 'postfix': }" end - context 'when not passing value' do - it 'should fail' do - expect { - is_expected.to contain_augeas("set postfix 'foo'") - }.to raise_error(Puppet::Error, /value can not be empty/) - end - end + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts + end - context 'when passing wrong type for value' do - let (:params) { { - :value => ['bar'], - } } - it 'should fail' do - expect { - is_expected.to contain_augeas("set postfix 'foo'") - }.to raise_error(Puppet::Error, /\["bar"\] is not a string/) - end - end + context 'when not passing value' do + it 'should fail' do + expect { + is_expected.to contain_augeas("set postfix 'foo'") + }.to raise_error(Puppet::Error, /value can not be empty/) + end + end - context 'when passing wrong type for ensure' do - let (:params) { { - :value => 'bar', - :ensure => ['present'], - } } - it 'should fail' do - expect { - is_expected.to contain_augeas("set postfix 'foo'") - }.to raise_error(Puppet::Error, /\["present"\] is not a string/) - end - end + context 'when passing wrong type for value' do + let (:params) { { + :value => ['bar'], + } } + it 'should fail' do + expect { + is_expected.to contain_augeas("set postfix 'foo'") + }.to raise_error(Puppet::Error, /\["bar"\] is not a string/) + end + end - context 'when passing wrong value for ensure' do - let (:params) { { - :value => 'bar', - :ensure => 'running', - } } - it 'should fail' do - expect { - is_expected.to contain_augeas("set postfix 'foo'") - }.to raise_error(Puppet::Error, /must be either 'present', 'absent' or 'blank'/) - end - end + context 'when passing wrong type for ensure' do + let (:params) { { + :value => 'bar', + :ensure => ['present'], + } } + it 'should fail' do + expect { + is_expected.to contain_augeas("set postfix 'foo'") + }.to raise_error(Puppet::Error, /\["present"\] is not a string/) + end + end - context 'when ensuring presence' do - let (:params) { { - :value => 'bar', - :ensure => 'present', - } } + context 'when passing wrong value for ensure' do + let (:params) { { + :value => 'bar', + :ensure => 'running', + } } + it 'should fail' do + expect { + is_expected.to contain_augeas("set postfix 'foo'") + }.to raise_error(Puppet::Error, /must be either 'present', 'absent' or 'blank'/) + end + end - it { is_expected.to contain_augeas("manage postfix 'foo'").with( - :incl => '/etc/postfix/main.cf', - :lens => 'Postfix_Main.lns', - :changes => "set foo 'bar'" - ) } - end + context 'when ensuring presence' do + let (:params) { { + :value => 'bar', + :ensure => 'present', + } } - context 'when ensuring absence' do - let (:params) { { - :value => 'bar', - :ensure => 'absent', - } } + it { is_expected.to contain_augeas("manage postfix 'foo'").with( + :incl => '/etc/postfix/main.cf', + :lens => 'Postfix_Main.lns', + :changes => "set foo 'bar'" + ) } + end - it { is_expected.to contain_augeas("manage postfix 'foo'").with( - :incl => '/etc/postfix/main.cf', - :lens => 'Postfix_Main.lns', - :changes => "rm foo" - ) } - end + context 'when ensuring absence' do + let (:params) { { + :value => 'bar', + :ensure => 'absent', + } } + + it { is_expected.to contain_augeas("manage postfix 'foo'").with( + :incl => '/etc/postfix/main.cf', + :lens => 'Postfix_Main.lns', + :changes => "rm foo" + ) } + end - context 'when ensuring blank' do - let (:params) { { - :value => 'bar', - :ensure => 'blank', - } } + context 'when ensuring blank' do + let (:params) { { + :value => 'bar', + :ensure => 'blank', + } } - it { is_expected.to contain_augeas("manage postfix 'foo'").with( - :incl => '/etc/postfix/main.cf', - :lens => 'Postfix_Main.lns', - :changes => "clear foo" - ) } + it { is_expected.to contain_augeas("manage postfix 'foo'").with( + :incl => '/etc/postfix/main.cf', + :lens => 'Postfix_Main.lns', + :changes => "clear foo" + ) } + end + end end end diff --git a/spec/defines/postfix_hash_spec.rb b/spec/defines/postfix_hash_spec.rb index 6a3220e8..ef80b0f5 100644 --- a/spec/defines/postfix_hash_spec.rb +++ b/spec/defines/postfix_hash_spec.rb @@ -2,102 +2,107 @@ describe 'postfix::hash' do let (:title) { '/tmp/foo' } - let (:facts) { { - :lsbdistcodename => 'wheezy', - :osfamily => 'Debian', - } } + let :pre_condition do "class { '::postfix': }" end - context 'when passing wrong type for ensure' do - let (:params) { { - :ensure => ['present'], - } } - it 'should fail' do - expect { - is_expected.to contain_file('/tmp/foo') - }.to raise_error(Puppet::Error, /\["present"\] is not a string/) - end - end + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts + end - context 'when passing wrong value for ensure' do - let (:params) { { - :ensure => 'running', - } } - it 'should fail' do - expect { - is_expected.to contain_file('/tmp/foo') - }.to raise_error(Puppet::Error, /must be either 'present' or 'absent'/) - end - end + context 'when passing wrong type for ensure' do + let (:params) { { + :ensure => ['present'], + } } + it 'should fail' do + expect { + is_expected.to contain_file('/tmp/foo') + }.to raise_error(Puppet::Error, /\["present"\] is not a string/) + end + end - context 'when passing wrong value for title' do - let (:title) { 'foo' } - it 'should fail' do - expect { - is_expected.to contain_file('/tmp/foo') - }.to raise_error(Puppet::Error, /"foo" is not an absolute path/) - end - end + context 'when passing wrong value for ensure' do + let (:params) { { + :ensure => 'running', + } } + it 'should fail' do + expect { + is_expected.to contain_file('/tmp/foo') + }.to raise_error(Puppet::Error, /must be either 'present' or 'absent'/) + end + end - context 'when passing both source and content' do - let (:params) { { - :source => '/tmp/bar', - :content => 'bar', - } } + context 'when passing wrong value for title' do + let (:title) { 'foo' } + it 'should fail' do + expect { + is_expected.to contain_file('/tmp/foo') + }.to raise_error(Puppet::Error, /"foo" is not an absolute path/) + end + end - it 'should fail' do - expect { - is_expected.to contain_file('/tmp/foo') - }.to raise_error(Puppet::Error, /You must provide either 'source' or 'content'/) - end - end + context 'when passing both source and content' do + let (:params) { { + :source => '/tmp/bar', + :content => 'bar', + } } - context 'when passing source' do - let (:params) { { - :source => '/tmp/bar', - } } + it 'should fail' do + expect { + is_expected.to contain_file('/tmp/foo') + }.to raise_error(Puppet::Error, /You must provide either 'source' or 'content'/) + end + end - it { is_expected.to contain_file('/tmp/foo').with( - :ensure => 'present', - :source => '/tmp/bar' - ).without(:content) - } - it { is_expected.to contain_file('/tmp/foo.db').with_ensure('present') } - it { is_expected.to contain_exec('generate /tmp/foo.db') } - end + context 'when passing source' do + let (:params) { { + :source => '/tmp/bar', + } } - context 'when passing content' do - let (:params) { { - :content => 'bar', - } } + it { is_expected.to contain_file('/tmp/foo').with( + :ensure => 'present', + :source => '/tmp/bar' + ).without(:content) + } + it { is_expected.to contain_file('/tmp/foo.db').with_ensure('present') } + it { is_expected.to contain_exec('generate /tmp/foo.db') } + end - it { is_expected.to contain_file('/tmp/foo').with( - :ensure => 'present', - :content => 'bar' - ).without(:source) - } - it { is_expected.to contain_file('/tmp/foo.db').with_ensure('present') } - it { is_expected.to contain_exec('generate /tmp/foo.db') } - end + context 'when passing content' do + let (:params) { { + :content => 'bar', + } } - context 'when not passing source or content' do - it { is_expected.to contain_file('/tmp/foo').with( - :ensure => 'present' - ).without(:source).without(:content) - } - it { is_expected.to contain_file('/tmp/foo.db').with_ensure('present') } - it { is_expected.to contain_exec('generate /tmp/foo.db') } - end + it { is_expected.to contain_file('/tmp/foo').with( + :ensure => 'present', + :content => 'bar' + ).without(:source) + } + it { is_expected.to contain_file('/tmp/foo.db').with_ensure('present') } + it { is_expected.to contain_exec('generate /tmp/foo.db') } + end + + context 'when not passing source or content' do + it { is_expected.to contain_file('/tmp/foo').with( + :ensure => 'present' + ).without(:source).without(:content) + } + it { is_expected.to contain_file('/tmp/foo.db').with_ensure('present') } + it { is_expected.to contain_exec('generate /tmp/foo.db') } + end - context 'when ensuring absence' do - let (:params) { { - :ensure => 'absent', - } } + context 'when ensuring absence' do + let (:params) { { + :ensure => 'absent', + } } - it { is_expected.to contain_file('/tmp/foo').with_ensure('absent') } - it { is_expected.to contain_file('/tmp/foo.db').with_ensure('absent') } - it { is_expected.to contain_exec('generate /tmp/foo.db') } + it { is_expected.to contain_file('/tmp/foo').with_ensure('absent') } + it { is_expected.to contain_file('/tmp/foo.db').with_ensure('absent') } + it { is_expected.to contain_exec('generate /tmp/foo.db') } + end + end end end diff --git a/spec/defines/postfix_transport_spec.rb b/spec/defines/postfix_transport_spec.rb index ad497170..05904998 100644 --- a/spec/defines/postfix_transport_spec.rb +++ b/spec/defines/postfix_transport_spec.rb @@ -2,139 +2,144 @@ describe 'postfix::transport' do let (:title) { 'foo' } - let (:facts) { { - :augeasversion => '1.2.0', - :osfamily => 'Debian', - :rubyversion => '1.9.3', - :path => '/foo/bar', - } } - let :pre_condition do - "class { 'augeas': }" - end - - context 'when sending wrong type for destination' do - let (:params) { { - :destination => ['bar'], - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix transport - foo') - }.to raise_error(Puppet::Error, /\["bar"\] is not a string/) - end - end - - context 'when sending wrong type for nexthop' do - let (:params) { { - :destination => 'bar', - :nexthop => ['baz'], - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix transport - foo') - }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) - end - end - - context 'when sending wrong type for file' do - let (:params) { { - :destination => 'bar', - :file => ['baz'], - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix transport - foo') - }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) - end - end - context 'when sending wrong value for file' do - let (:params) { { - :destination => 'bar', - :file => 'baz', - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix transport - foo') - }.to raise_error(Puppet::Error, /"baz" is not an absolute path/) - end - end - - context 'when sending wrong type for ensure' do - let (:params) { { - :destination => 'bar', - :ensure => ['baz'], - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix transport - foo') - }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) - end + let :pre_condition do + "class { '::augeas': }" end - context 'when sending wrong value for ensure' do - let (:params) { { - :destination => 'bar', - :ensure => 'running', - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix transport - foo') - }.to raise_error(Puppet::Error, /\$ensure must be either/) + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ + :augeasversion => '1.2.0', + }) + end + + context 'when sending wrong type for destination' do + let (:params) { { + :destination => ['bar'], + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix transport - foo') + }.to raise_error(Puppet::Error, /\["bar"\] is not a string/) + end + end + + context 'when sending wrong type for nexthop' do + let (:params) { { + :destination => 'bar', + :nexthop => ['baz'], + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix transport - foo') + }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) + end + end + + context 'when sending wrong type for file' do + let (:params) { { + :destination => 'bar', + :file => ['baz'], + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix transport - foo') + }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) + end + end + + context 'when sending wrong value for file' do + let (:params) { { + :destination => 'bar', + :file => 'baz', + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix transport - foo') + }.to raise_error(Puppet::Error, /"baz" is not an absolute path/) + end + end + + context 'when sending wrong type for ensure' do + let (:params) { { + :destination => 'bar', + :ensure => ['baz'], + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix transport - foo') + }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) + end + end + + context 'when sending wrong value for ensure' do + let (:params) { { + :destination => 'bar', + :ensure => 'running', + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix transport - foo') + }.to raise_error(Puppet::Error, /\$ensure must be either/) + end + end + + context 'when using default values' do + it { is_expected.to contain_class('postfix::augeas') } + it { is_expected.to contain_augeas('Postfix transport - foo').with( + :incl => '/etc/postfix/transport', + :lens => 'Postfix_Transport.lns', + :changes => [ + "set pattern[. = 'foo'] 'foo'", + "clear pattern[. = 'foo']/transport", + "clear pattern[. = 'foo']/nexthop", + ]) + } + end + + context 'when overriding default values' do + let (:params) { { + :destination => 'bar', + :nexthop => 'baz', + :file => '/tmp/transport', + :ensure => 'present', + } } + + it { is_expected.to contain_class('postfix::augeas') } + it { is_expected.to contain_augeas('Postfix transport - foo').with( + :incl => '/tmp/transport', + :lens => 'Postfix_Transport.lns', + :changes => [ + "set pattern[. = 'foo'] 'foo'", + "set pattern[. = 'foo']/transport 'bar'", + "set pattern[. = 'foo']/nexthop 'baz'", + ]) + } + end + + context 'when ensuring absence' do + let (:params) { { + :destination => 'bar', + :ensure => 'absent', + } } + + it { is_expected.to contain_class('postfix::augeas') } + it { is_expected.to contain_augeas('Postfix transport - foo').with( + :incl => '/etc/postfix/transport', + :lens => 'Postfix_Transport.lns', + :changes => [ + "rm pattern[. = 'foo']", + ]) + } + end end end - - context 'when using default values' do - it { is_expected.to contain_class('postfix::augeas') } - it { is_expected.to contain_augeas('Postfix transport - foo').with( - :incl => '/etc/postfix/transport', - :lens => 'Postfix_Transport.lns', - :changes => [ - "set pattern[. = 'foo'] 'foo'", - "clear pattern[. = 'foo']/transport", - "clear pattern[. = 'foo']/nexthop", - ]) - } - end - - context 'when overriding default values' do - let (:params) { { - :destination => 'bar', - :nexthop => 'baz', - :file => '/tmp/transport', - :ensure => 'present', - } } - - it { is_expected.to contain_class('postfix::augeas') } - it { is_expected.to contain_augeas('Postfix transport - foo').with( - :incl => '/tmp/transport', - :lens => 'Postfix_Transport.lns', - :changes => [ - "set pattern[. = 'foo'] 'foo'", - "set pattern[. = 'foo']/transport 'bar'", - "set pattern[. = 'foo']/nexthop 'baz'", - ]) - } - end - - context 'when ensuring absence' do - let (:params) { { - :destination => 'bar', - :ensure => 'absent', - } } - - it { is_expected.to contain_class('postfix::augeas') } - it { is_expected.to contain_augeas('Postfix transport - foo').with( - :incl => '/etc/postfix/transport', - :lens => 'Postfix_Transport.lns', - :changes => [ - "rm pattern[. = 'foo']", - ]) - } - end end diff --git a/spec/defines/postfix_virtual_spec.rb b/spec/defines/postfix_virtual_spec.rb index 36a056b2..38927652 100644 --- a/spec/defines/postfix_virtual_spec.rb +++ b/spec/defines/postfix_virtual_spec.rb @@ -2,135 +2,140 @@ describe 'postfix::virtual' do let (:title) { 'foo' } - let (:facts) { { - :augeasversion => '1.2.0', - :osfamily => 'Debian', - :rubyversion => '1.9.3', - :path => '/foo/bar', - } } - let :pre_condition do - "class { 'augeas': }" - end - - context 'when not sending destination' do - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix virtual - foo') - }.to raise_error(Puppet::Error, /Must pass destination/) - end - end - - context 'when sending wrong type for destination' do - let (:params) { { - :destination => ['bar'], - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix virtual - foo') - }.to raise_error(Puppet::Error, /\["bar"\] is not a string/) - end - end - - context 'when sending wrong type for file' do - let (:params) { { - :destination => 'bar', - :file => ['baz'], - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix virtual - foo') - }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) - end - end - - context 'when sending wrong value for file' do - let (:params) { { - :destination => 'bar', - :file => 'baz', - } } - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix virtual - foo') - }.to raise_error(Puppet::Error, /"baz" is not an absolute path/) - end - end - - context 'when sending wrong type for ensure' do - let (:params) { { - :destination => 'bar', - :ensure => ['baz'], - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix virtual - foo') - }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) - end + let :pre_condition do + "class { '::augeas': }" end - context 'when sending wrong value for ensure' do - let (:params) { { - :destination => 'bar', - :ensure => 'running', - } } - - it 'should fail' do - expect { - is_expected.to contain_augeas('Postfix virtual - foo') - }.to raise_error(Puppet::Error, /\$ensure must be either/) + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ + :augeasversion => '1.2.0', + }) + end + + context 'when not sending destination' do + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix virtual - foo') + }.to raise_error(Puppet::Error, /Must pass destination/) + end + end + + context 'when sending wrong type for destination' do + let (:params) { { + :destination => ['bar'], + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix virtual - foo') + }.to raise_error(Puppet::Error, /\["bar"\] is not a string/) + end + end + + context 'when sending wrong type for file' do + let (:params) { { + :destination => 'bar', + :file => ['baz'], + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix virtual - foo') + }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) + end + end + + context 'when sending wrong value for file' do + let (:params) { { + :destination => 'bar', + :file => 'baz', + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix virtual - foo') + }.to raise_error(Puppet::Error, /"baz" is not an absolute path/) + end + end + + context 'when sending wrong type for ensure' do + let (:params) { { + :destination => 'bar', + :ensure => ['baz'], + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix virtual - foo') + }.to raise_error(Puppet::Error, /\["baz"\] is not a string/) + end + end + + context 'when sending wrong value for ensure' do + let (:params) { { + :destination => 'bar', + :ensure => 'running', + } } + + it 'should fail' do + expect { + is_expected.to contain_augeas('Postfix virtual - foo') + }.to raise_error(Puppet::Error, /\$ensure must be either/) + end + end + + context 'when using default values' do + let (:params) { { + :destination => 'bar', + } } + + it { is_expected.to contain_class('postfix::augeas') } + it { is_expected.to contain_augeas('Postfix virtual - foo').with( + :incl => '/etc/postfix/virtual', + :lens => 'Postfix_Virtual.lns', + :changes => [ + "set pattern[. = 'foo'] 'foo'", + "set pattern[. = 'foo']/destination 'bar'", + ]) + } + end + + context 'when overriding default values' do + let (:params) { { + :destination => 'bar', + :file => '/tmp/virtual', + :ensure => 'present', + } } + + it { is_expected.to contain_class('postfix::augeas') } + it { is_expected.to contain_augeas('Postfix virtual - foo').with( + :incl => '/tmp/virtual', + :lens => 'Postfix_Virtual.lns', + :changes => [ + "set pattern[. = 'foo'] 'foo'", + "set pattern[. = 'foo']/destination 'bar'", + ]) + } + end + + context 'when ensuring absence' do + let (:params) { { + :destination => 'bar', + :ensure => 'absent', + } } + + it { is_expected.to contain_class('postfix::augeas') } + it { is_expected.to contain_augeas('Postfix virtual - foo').with( + :incl => '/etc/postfix/virtual', + :lens => 'Postfix_Virtual.lns', + :changes => [ + "rm pattern[. = 'foo']", + ]) + } + end end end - - context 'when using default values' do - let (:params) { { - :destination => 'bar', - } } - - it { is_expected.to contain_class('postfix::augeas') } - it { is_expected.to contain_augeas('Postfix virtual - foo').with( - :incl => '/etc/postfix/virtual', - :lens => 'Postfix_Virtual.lns', - :changes => [ - "set pattern[. = 'foo'] 'foo'", - "set pattern[. = 'foo']/destination 'bar'", - ]) - } - end - - context 'when overriding default values' do - let (:params) { { - :destination => 'bar', - :file => '/tmp/virtual', - :ensure => 'present', - } } - - it { is_expected.to contain_class('postfix::augeas') } - it { is_expected.to contain_augeas('Postfix virtual - foo').with( - :incl => '/tmp/virtual', - :lens => 'Postfix_Virtual.lns', - :changes => [ - "set pattern[. = 'foo'] 'foo'", - "set pattern[. = 'foo']/destination 'bar'", - ]) - } - end - - context 'when ensuring absence' do - let (:params) { { - :destination => 'bar', - :ensure => 'absent', - } } - - it { is_expected.to contain_class('postfix::augeas') } - it { is_expected.to contain_augeas('Postfix virtual - foo').with( - :incl => '/etc/postfix/virtual', - :lens => 'Postfix_Virtual.lns', - :changes => [ - "rm pattern[. = 'foo']", - ]) - } - end end