diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 048d2b55..8b466cfb 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -124,7 +124,7 @@ If you have Ruby 2.x or want a specific version of Puppet, you must set an environment variable such as: ```sh -export PUPPET_VERSION="~> 5.5.6" +export PUPPET_GEM_VERSION="~> 6.1.0" ``` You can install all needed gems for spec tests into the modules directory by @@ -232,17 +232,16 @@ simple tests against it after applying the module. You can run this with: ```sh -BEAKER_setfile=debian10-x64 bundle exec rake beaker +BEAKER_setfile=debian11-64 bundle exec rake beaker ``` You can replace the string `debian10` with any common operating system. The following strings are known to work: -* ubuntu1604 * ubuntu1804 * ubuntu2004 -* debian9 * debian10 +* debian11 * centos7 * centos8 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d08d05e8..8a077911 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,84 +7,12 @@ name: CI on: pull_request concurrency: - group: ${{ github.head_ref }} + group: ${{ github.ref_name }} cancel-in-progress: true jobs: - setup_matrix: - name: 'Setup Test Matrix' - runs-on: ubuntu-latest - timeout-minutes: 40 - outputs: - puppet_unit_test_matrix: ${{ steps.get-outputs.outputs.puppet_unit_test_matrix }} - github_action_test_matrix: ${{ steps.get-outputs.outputs.github_action_test_matrix }} - env: - BUNDLE_WITHOUT: development:system_tests:release - steps: - - uses: actions/checkout@v2 - - name: Setup ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.0' - bundler-cache: true - - name: Run static validations - run: bundle exec rake validate lint check - - name: Run rake rubocop - run: bundle exec rake rubocop - - name: Setup Test Matrix - id: get-outputs - run: bundle exec metadata2gha --use-fqdn --pidfile-workaround false - - unit: - needs: setup_matrix - runs-on: ubuntu-latest - timeout-minutes: 40 - strategy: - fail-fast: false - matrix: - include: ${{fromJson(needs.setup_matrix.outputs.puppet_unit_test_matrix)}} - env: - BUNDLE_WITHOUT: development:system_tests:release - PUPPET_VERSION: "~> ${{ matrix.puppet }}.0" - name: Puppet ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }}) - steps: - - uses: actions/checkout@v2 - - name: Setup ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - bundler-cache: true - - name: Run tests - run: bundle exec rake parallel_spec - - acceptance: - needs: setup_matrix - runs-on: ubuntu-latest - env: - BUNDLE_WITHOUT: development:test:release - strategy: - fail-fast: false - matrix: - include: ${{fromJson(needs.setup_matrix.outputs.github_action_test_matrix)}} - name: ${{ matrix.puppet.name }} - ${{ matrix.setfile.name }} - steps: - - uses: actions/checkout@v2 - - name: Setup ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.0' - bundler-cache: true - - name: Run tests - run: bundle exec rake beaker - env: - BEAKER_PUPPET_COLLECTION: ${{ matrix.puppet.collection }} - BEAKER_setfile: ${{ matrix.setfile.value }} - - tests: - needs: - - unit - - acceptance - runs-on: ubuntu-latest - name: Test suite - steps: - - run: echo Test suite completed + puppet: + name: Puppet + uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v1 + with: + pidfile_workaround: 'false' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 664ba694..15f17213 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,26 +9,14 @@ on: tags: - '*' -env: - BUNDLE_WITHOUT: development:test:system_tests - jobs: - deploy: - name: 'deploy to forge' - runs-on: ubuntu-latest - if: github.repository_owner == 'voxpupuli' - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '2.7' - bundler-cache: true - - name: Build and Deploy - env: - # Configure secrets here: - # https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets - BLACKSMITH_FORGE_USERNAME: '${{ secrets.PUPPET_FORGE_USERNAME }}' - BLACKSMITH_FORGE_API_KEY: '${{ secrets.PUPPET_FORGE_API_KEY }}' - run: bundle exec rake module:push + release: + name: Release + uses: voxpupuli/gha-puppet/.github/workflows/release.yml@v1 + with: + allowed_owner: 'voxpupuli' + secrets: + # Configure secrets here: + # https://docs.github.com/en/actions/security-guides/encrypted-secrets + username: ${{ secrets.PUPPET_FORGE_USERNAME }} + api_key: ${{ secrets.PUPPET_FORGE_API_KEY }} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 81e6d762..00000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -stages: - - syntax - - unit - -cache: - paths: - - vendor/bundle - -before_script: - - bundle -v - - rm Gemfile.lock || true - - gem update --system $RUBYGEMS_VERSION - - gem --version - - bundle -v - - bundle install --without system_tests --path vendor/bundle --jobs $(nproc) - -syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop-Ruby 2.5.3-Puppet ~> 6: - stage: syntax - image: ruby:2.5.3 - script: - - bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop - variables: - PUPPET_GEM_VERSION: '~> 6' - -parallel_spec-Ruby 2.5.3-Puppet ~> 6: - stage: unit - image: ruby:2.5.3 - script: - - bundle exec rake parallel_spec - variables: - PUPPET_GEM_VERSION: '~> 6' - -parallel_spec-Ruby 2.4.5-Puppet ~> 5: - stage: unit - image: ruby:2.4.5 - script: - - bundle exec rake parallel_spec - variables: - PUPPET_GEM_VERSION: '~> 5' - diff --git a/.msync.yml b/.msync.yml index 43966c2f..968a9367 100644 --- a/.msync.yml +++ b/.msync.yml @@ -2,4 +2,4 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -modulesync_config_version: '4.2.0' +modulesync_config_version: '5.2.0' diff --git a/.pdkignore b/.pdkignore deleted file mode 100644 index e6215cd0..00000000 --- a/.pdkignore +++ /dev/null @@ -1,42 +0,0 @@ -.git/ -.*.sw[op] -.metadata -.yardoc -.yardwarns -*.iml -/.bundle/ -/.idea/ -/.vagrant/ -/coverage/ -/bin/ -/doc/ -/Gemfile.local -/Gemfile.lock -/junit/ -/log/ -/pkg/ -/spec/fixtures/manifests/ -/spec/fixtures/modules/ -/tmp/ -/vendor/ -/convert_report.txt -/update_report.txt -.DS_Store -.project -.envrc -/inventory.yaml -/appveyor.yml -/.fixtures.yml -/Gemfile -/.gitattributes -/.gitignore -/.gitlab-ci.yml -/.pdkignore -/Rakefile -/rakelib/ -/.rspec -/.rubocop.yml -/.travis.yml -/.yardopts -/spec/ -/.vscode/ diff --git a/.puppet-lint.rc b/.puppet-lint.rc index cc96ece0..dd8272c7 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1 +1,3 @@ ---relative +--fail-on-warnings +--no-parameter_documentation-check +--no-parameter_types-check diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d3f6ea0..f3899d6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,39 @@ All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module. +## [v3.0.0](https://github.com/voxpupuli/puppet-postfix/tree/v3.0.0) (2022-05-05) + +[Full Changelog](https://github.com/voxpupuli/puppet-postfix/compare/v2.0.0...v3.0.0) + +**Breaking changes:** + +- Drop support for FreeBSD 11 \(EOL\) [\#306](https://github.com/voxpupuli/puppet-postfix/pull/306) ([smortex](https://github.com/smortex)) + +**Implemented enhancements:** + +- Declare CentOS 9 Support, Install s-nail on 9 [\#322](https://github.com/voxpupuli/puppet-postfix/pull/322) ([traylenator](https://github.com/traylenator)) +- Add support for FreeBSD 13 [\#307](https://github.com/voxpupuli/puppet-postfix/pull/307) ([smortex](https://github.com/smortex)) +- allow hiera driven transport/virtual/hash/conffile [\#296](https://github.com/voxpupuli/puppet-postfix/pull/296) ([cringdahl](https://github.com/cringdahl)) + +**Closed issues:** + +- increase dependency of puppet/alternatives to next major version [\#324](https://github.com/voxpupuli/puppet-postfix/issues/324) +- smtp\_listen to take multiple addresses [\#203](https://github.com/voxpupuli/puppet-postfix/issues/203) + +**Merged pull requests:** + +- Add switches for simple domain masquerade [\#326](https://github.com/voxpupuli/puppet-postfix/pull/326) ([jcpunk](https://github.com/jcpunk)) +- increase dependency of puppet/alternatives to next major version [\#325](https://github.com/voxpupuli/puppet-postfix/pull/325) ([KoenDierckx](https://github.com/KoenDierckx)) +- Comply to rubocop 1.22.3 [\#321](https://github.com/voxpupuli/puppet-postfix/pull/321) ([traylenator](https://github.com/traylenator)) +- remove unneeded tests; provide error message for raise\_error [\#318](https://github.com/voxpupuli/puppet-postfix/pull/318) ([kenyon](https://github.com/kenyon)) +- map: handle regexp type [\#317](https://github.com/voxpupuli/puppet-postfix/pull/317) ([kenyon](https://github.com/kenyon)) +- allow creation of postfix::map resources with hiera [\#316](https://github.com/voxpupuli/puppet-postfix/pull/316) ([kenyon](https://github.com/kenyon)) +- init.pp: correct param numbers and use of optional [\#315](https://github.com/voxpupuli/puppet-postfix/pull/315) ([kenyon](https://github.com/kenyon)) +- Allow parameter smtp\_listen to accept multiple IPs [\#313](https://github.com/voxpupuli/puppet-postfix/pull/313) ([wobblesprout](https://github.com/wobblesprout)) +- Add manage\_mailname parameter to README \(\#186\) [\#312](https://github.com/voxpupuli/puppet-postfix/pull/312) ([wobblesprout](https://github.com/wobblesprout)) +- fixtures.yml: Migrate to git URLs [\#309](https://github.com/voxpupuli/puppet-postfix/pull/309) ([bastelfreak](https://github.com/bastelfreak)) +- puppet-lint: fix top\_scope\_facts warnings [\#304](https://github.com/voxpupuli/puppet-postfix/pull/304) ([bastelfreak](https://github.com/bastelfreak)) + ## [v2.0.0](https://github.com/voxpupuli/puppet-postfix/tree/v2.0.0) (2021-08-26) [Full Changelog](https://github.com/voxpupuli/puppet-postfix/compare/1.12.0...v2.0.0) diff --git a/Dockerfile b/Dockerfile index e3cf307f..8dd82d63 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ WORKDIR /opt/puppet # https://github.com/puppetlabs/puppet/blob/06ad255754a38f22fb3a22c7c4f1e2ce453d01cb/lib/puppet/provider/service/runit.rb#L39 RUN mkdir -p /etc/sv -ARG PUPPET_VERSION="~> 6.0" +ARG PUPPET_GEM_VERSION="~> 6.0" ARG PARALLEL_TEST_PROCESSORS=4 # Cache gems diff --git a/Gemfile b/Gemfile index d825989b..f026cbc7 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,10 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -source ENV['GEM_SOURCE'] || "https://rubygems.org" +source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'voxpupuli-test', '~> 2.5', :require => false + gem 'voxpupuli-test', '~> 5.0', :require => false gem 'coveralls', :require => false gem 'simplecov-console', :require => false gem 'puppet_metadata', '~> 1.0', :require => false @@ -22,14 +22,14 @@ end group :release do gem 'github_changelog_generator', '>= 1.16.1', :require => false if RUBY_VERSION >= '2.5' - gem 'voxpupuli-release', '>= 1.0.2', :require => false + gem 'voxpupuli-release', '>= 1.2.0', :require => false gem 'puppet-strings', '>= 2.2', :require => false end gem 'rake', :require => false gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test] -puppetversion = ENV['PUPPET_VERSION'] || '>= 6.0' +puppetversion = ENV['PUPPET_GEM_VERSION'] || '>= 6.0' gem 'puppet', puppetversion, :require => false, :groups => [:test] # vim: syntax=ruby diff --git a/README.md b/README.md index d678469f..a1543efa 100644 --- a/README.md +++ b/README.md @@ -104,12 +104,35 @@ A Boolean defining whether the puppet module should replace the configuration fi Default: true. +##### `manage_mailname` + +A Boolean defining whether the puppet module should manage '/etc/mailname'. +See also $manage_conffiles + +Default: true. + ##### `manage_mailx` A Boolean defining whether the puppet module should manage the mailx package. See also $mailx_ensure. Default: true. +##### `masquerade_classes` +An array defining the masquerade_classes to use. +Default: Undefined. +Example: ['envelope_sender', 'envelope_recipient', 'header_sender', 'header_recipient'] + +##### `masquerade_domains` +An array defining the masquerade_domains to use. +The order of elements matters here, so be aware of how you define the elements. +Default: Undefined. +Example: ['foo.example.com', 'example.com'] + +##### `masquerade_exceptions` +An array defining the masquerade_exceptions to use. +Default: Undefined. +Example: ['root'] + ##### `mastercf_source` A string defining the location of a skeleton master.cf file to be used. Default: Undefined. @@ -136,7 +159,7 @@ Default: Undefined. Example: 'submission inet n - n - - smtpd'. ##### `mta` -A Boolean to define whether to configure Postfix as a mail transfer agent. This option is mutually exclusive with the satellite Boolean. +A Boolean to define whether to configure Postfix as a mail transfer agent. This option is mutually exclusive with the satellite Boolean and relayhost String. Default: False. ##### `mydestination` @@ -155,7 +178,7 @@ Default: The FQDN of the host. Example: 'example.com' ##### `relayhost` -A string to define the relayhost parameter (postconf(5)). +A string to define the relayhost parameter (postconf(5)). This setting is mutually exclusive with the mta Boolean. Default: Undefined. Example: 'smtp.example.com'. @@ -170,11 +193,11 @@ Default: Undefined. Example: true ##### `satellite` -A Boolean to define whether to configure postfix as a satellite relay host. This setting is mutually exclusive with the mta Boolean. +A Boolean to define whether to configure postfix as a satellite relay host. This setting is mutually exclusive with the mta Boolean. Default: False. ##### `smtp_listen` -A string to define the IP on which to listen in master.cf. This can also be set to 'all' to listen on all interfaces. If master_smtp is defined smtp_listen will not be used. +A string or an array of strings to define the IPs on which to listen in master.cf. This can also be set to 'all' to listen on all interfaces. If master_smtp is defined smtp_listen will not be used. Default: '127.0.0.1'. Example: '::1'. diff --git a/Rakefile b/Rakefile index 80b799d6..f92f0516 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ -# Attempt to load voxupuli-test (which pulls in puppetlabs_spec_helper), +# Attempt to load voxpupuli-test (which pulls in puppetlabs_spec_helper), # otherwise attempt to load it directly. begin require 'voxpupuli/test/rake' diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index ec389492..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,56 +0,0 @@ ---- -version: 1.1.x.{build} -branches: - only: - - master - - release -skip_commits: - message: /^\(?doc\)?.*/ -clone_depth: 10 -init: - - SET - - 'mkdir C:\ProgramData\PuppetLabs\code && exit 0' - - 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0' - - 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0' - - 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0' -environment: - matrix: - - - RUBY_VERSION: 24-x64 - CHECK: syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop - - - PUPPET_GEM_VERSION: ~> 5.0 - RUBY_VERSION: 24 - CHECK: parallel_spec - - - PUPPET_GEM_VERSION: ~> 5.0 - RUBY_VERSION: 24-x64 - CHECK: parallel_spec - - - PUPPET_GEM_VERSION: ~> 6.0 - RUBY_VERSION: 25 - CHECK: parallel_spec - - - PUPPET_GEM_VERSION: ~> 6.0 - RUBY_VERSION: 25-x64 - CHECK: parallel_spec -matrix: - fast_finish: true -install: - - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH% - - bundle install --jobs 4 --retry 2 --without system_tests - - type Gemfile.lock -build: off -test_script: - - bundle exec puppet -V - - ruby -v - - gem -v - - bundle -v - - bundle exec rake %CHECK% -notifications: - - provider: Email - to: - - nobody@nowhere.com - on_build_success: false - on_build_failure: false - on_build_status_changed: false diff --git a/data/osfamily/RedHat/9.yaml b/data/osfamily/RedHat/9.yaml new file mode 100644 index 00000000..d3c6617b --- /dev/null +++ b/data/osfamily/RedHat/9.yaml @@ -0,0 +1,3 @@ +--- + +postfix::params::mailx_package: 's-nail' diff --git a/manifests/init.pp b/manifests/init.pp index cc26949e..289a878c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -10,13 +10,15 @@ # # [*configs*] - (hash) # -# [*hash*] - (hash) A hash of postfix::hash resources +# [*hashes*] - (hash) A hash of postfix::hash resources # -# [*transport*] - (hash) A hash of postfix::transport resources +# [*transports*] - (hash) A hash of postfix::transport resources # -# [*virtual*] - (hash) A hash of postfix::virtual resources +# [*virtuals*] - (hash) A hash of postfix::virtual resources # -# [*conffile*] - (hash) A hash of postfix::conffile resources +# [*conffiles*] - (hash) A hash of postfix::conffile resources +# +# [*maps*] - (hash) A hash of postfix::map resources # # [*amavis_procs*] - (integer) Number of amavis scanners to spawn # @@ -40,8 +42,16 @@ # # [*manage_conffiles*] - (boolean) Whether config files are to be replaced # +# [*manage_mailname*] - (boolean) Whether to manage /etc/mailname. +# # [*manage_mailx*] - (boolean) Whether to manage mailx package. # +# [*masquerade_classes*] - (array) +# +# [*masquerade_domains*] - (array) +# +# [*masquerade_exceptions*] - (array) +# # [*mastercf_source*] - (string) # # [*mastercf_content*] - (string) @@ -104,11 +114,12 @@ Stdlib::Absolutepath $confdir = '/etc/postfix', String $root_group = 'root', String $alias_maps = 'hash:/etc/aliases', - Optional[Hash] $configs = {}, - Optional[Hash] $hash = {}, - Optional[Hash] $transport = {}, - Optional[Hash] $virtual = {}, - Optional[Hash] $conffile = {}, + Hash $configs = {}, + Hash $hashes = {}, + Hash $transports = {}, + Hash $virtuals = {}, + Hash $conffiles = {}, + Hash $maps = {}, Integer $amavis_procs = 2, String $inet_interfaces = 'all', String $inet_protocols = 'all', @@ -122,13 +133,16 @@ Boolean $manage_conffiles = true, Boolean $manage_mailname = true, Boolean $manage_mailx = true, + Optional[Array[String[1]]] $masquerade_classes = undef, + Optional[Array[String[1]]] $masquerade_domains = undef, + Optional[Array[String[1]]] $masquerade_exceptions = undef, Optional[String] $mastercf_source = undef, Optional[String] $mastercf_content = undef, Optional[String] $mastercf_template = undef, Optional[String] $master_smtp = undef, # postfix_master_smtp Optional[String] $master_smtps = undef, # postfix_master_smtps Optional[String] $master_submission = undef, # postfix_master_submission - Optional[Array[String]] $master_entries = undef, # postfix_master_entries + Array[String] $master_entries = [], # postfix_master_entries String $master_bounce_command = 'bounce', String $master_defer_command = 'bounce', Boolean $mta = false, @@ -141,7 +155,7 @@ Variant[Array[String], String] $root_mail_recipient = 'nobody', # root_mail_recipient Optional[Boolean] $chroot = undef, Boolean $satellite = false, - String $smtp_listen = '127.0.0.1', # postfix_smtp_listen + Variant[Array[String[1]], String[1]] $smtp_listen = '127.0.0.1', # postfix_smtp_listen Boolean $use_amavisd = false, # postfix_use_amavisd Boolean $use_dovecot_lda = false, # postfix_use_dovecot_lda Variant[Integer[2, 3], Boolean] $use_schleuder = false, # postfix_use_schleuder @@ -151,10 +165,12 @@ String $service_ensure = 'running', Boolean $service_enabled = true, ) inherits postfix::params { - if (($mastercf_source and $mastercf_content) or + if ( + ($mastercf_source and $mastercf_content) or ($mastercf_source and $mastercf_template) or ($mastercf_content and $mastercf_template) or - ($mastercf_source and $mastercf_content and $mastercf_template)) { + ($mastercf_source and $mastercf_content and $mastercf_template) + ) { fail('mastercf_source, mastercf_content and mastercf_template are mutually exclusive') } @@ -168,11 +184,41 @@ true => "${alias_maps}, ldap:${confdir}/ldap-aliases.cf", } - create_resources('::postfix::config', $configs) - create_resources('::postfix::transport', $transport) - create_resources('::postfix::virtual', $virtual) - create_resources('::postfix::hash', $hash) - create_resources('::postfix::conffile', $conffile) + $configs.each |$key, $value| { + postfix::config { $key: + * => $value, + } + } + + $transports.each |$key, $value| { + postfix::transport { $key: + * => $value, + } + } + + $virtuals.each |$key, $value| { + postfix::virtual { $key: + * => $value, + } + } + + $hashes.each |$key, $value| { + postfix::hash { $key: + * => $value, + } + } + + $conffiles.each |$key, $value| { + postfix::conffile { $key: + * => $value, + } + } + + $maps.each |$key, $value| { + postfix::map { $key: + * => $value, + } + } contain 'postfix::packages' contain 'postfix::files' @@ -193,9 +239,9 @@ include postfix::mta } - if $satellite { + if $satellite or $relayhost { if $mta { - fail('enabling both the $mta and $satellite parameters is not supported. Please disable one.') + fail('enabling both the $mta and $satellite or $relayhost parameters is not supported. Please disable one.') } include postfix::satellite } diff --git a/manifests/map.pp b/manifests/map.pp index eb000c45..9d8454cf 100644 --- a/manifests/map.pp +++ b/manifests/map.pp @@ -28,12 +28,12 @@ # } # define postfix::map ( - Enum['present', 'absent'] $ensure = 'present', - Variant[Array[String], String, Undef] $source = undef, - Optional[Variant[Sensitive[String],String]] $content = undef, - String $type = 'hash', - Optional[Stdlib::Absolutepath] $path = undef, - String[4,4] $mode = '0640' + Enum['present', 'absent'] $ensure = 'present', + Optional[Variant[Array[String], String]] $source = undef, + Optional[Variant[Sensitive[String], String]] $content = undef, + String[1] $type = 'hash', + Optional[Stdlib::Absolutepath] $path = undef, + String[4,4] $mode = '0640', ) { include postfix include postfix::params @@ -49,7 +49,7 @@ } # CIDR and PCRE maps need a postfix reload, but not a postmap - if $type =~ /^(cidr|pcre)$/ { + if $type =~ /^(cidr|pcre|regexp)$/ { $manage_notify = Service['postfix'] } else { if $ensure == 'present' { @@ -71,7 +71,7 @@ notify => $manage_notify, } - if $type !~ /^(cidr|pcre)$/ { + if $type !~ /^(cidr|pcre|regexp)$/ { file { "postfix map ${name}.db": ensure => $ensure, path => "${_path}.db", diff --git a/manifests/mta.pp b/manifests/mta.pp index 29b69610..122d40fa 100644 --- a/manifests/mta.pp +++ b/manifests/mta.pp @@ -15,6 +15,9 @@ # directly without a relay. # [*mydestination*] - (string) # [*mynetworks*] - (string) +# [*masquerade_classes*] - (array) +# [*masquerade_domains*] - (array) +# [*masquerade_exceptions*] - (array) # # === Examples # @@ -29,12 +32,18 @@ Optional[Pattern[/^\S+(?:,\s*\S+)*$/]] $mydestination = undef, Optional[Pattern[/^(?:\S+?(?:(?:,\s+)|(?:\s+))?)*$/]] $mynetworks = undef, Optional[Pattern[/^\S+$/]] $relayhost = undef, + Optional[Array[String[1]]] $masquerade_classes = undef, + Optional[Array[String[1]]] $masquerade_domains = undef, + Optional[Array[String[1]]] $masquerade_exceptions = undef, ) { include postfix $_mydestination = pick($mydestination, $postfix::mydestination) $_mynetworks = pick($mynetworks, $postfix::mynetworks) - $_relayhost = pick($relayhost, $postfix::relayhost) + $_relayhost = pick($relayhost, $postfix::relayhost, 'direct') + $_masquerade_classes = $masquerade_classes.lest || { $postfix::masquerade_classes } + $_masquerade_domains = $masquerade_domains.lest || { $postfix::masquerade_domains } + $_masquerade_exceptions = $masquerade_exceptions.lest || { $postfix::masquerade_exceptions } # If direct is specified then relayhost should be blank if ($_relayhost == 'direct') { @@ -56,6 +65,16 @@ 'transport_maps': value => "hash:${postfix::confdir}/transport"; } + if ! $_masquerade_classes.empty() { + postfix::config { 'masquerade_classes': value => join($_masquerade_classes, ' ') } + } + if ! $_masquerade_domains.empty() { + postfix::config { 'masquerade_domains': value => join($_masquerade_domains, ' ') } + } + if ! $_masquerade_exceptions.empty() { + postfix::config { 'masquerade_exceptions': value => join($_masquerade_exceptions, ' ') } + } + postfix::hash { "${postfix::confdir}/virtual": ensure => 'present', } diff --git a/manifests/satellite.pp b/manifests/satellite.pp index 51202277..51de4d77 100644 --- a/manifests/satellite.pp +++ b/manifests/satellite.pp @@ -12,6 +12,9 @@ # [*mydestination*] - (string) # [*mynetworks*] - (string) # [*relayhost*] - (string) +# [*masquerade_classes*] - (array) +# [*masquerade_domains*] - (array) +# [*masquerade_exceptions*] - (array) # # === Examples # @@ -26,6 +29,9 @@ $mydestination = undef, $mynetworks = undef, $relayhost = undef, + $masquerade_classes = undef, + $masquerade_domains = undef, + $masquerade_exceptions = undef, ) { include postfix @@ -34,11 +40,17 @@ $_mydestination = pick($mydestination, $postfix::mydestination) $_mynetworks = pick($mynetworks, $postfix::mynetworks) $_relayhost = pick($relayhost, $postfix::relayhost) + $_masquerade_classes = $masquerade_classes.lest || { $postfix::masquerade_classes } + $_masquerade_domains = $masquerade_domains.lest || { $postfix::masquerade_domains } + $_masquerade_exceptions = $masquerade_exceptions.lest || { $postfix::masquerade_exceptions } class { 'postfix::mta': - mydestination => $_mydestination, - mynetworks => $_mynetworks, - relayhost => $_relayhost, + mydestination => $_mydestination, + mynetworks => $_mynetworks, + relayhost => $_relayhost, + masquerade_classes => $_masquerade_classes, + masquerade_domains => $_masquerade_domains, + masquerade_exceptions => $_masquerade_exceptions, } postfix::virtual { "@${postfix::myorigin}": diff --git a/metadata.json b/metadata.json index 080b213f..4108c9e6 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppet-postfix", - "version": "2.0.1-rc0", + "version": "3.0.1-rc0", "author": "Vox Pupuli", "summary": "Postfix Module", "license": "Apache-2.0", @@ -18,7 +18,7 @@ }, { "name": "puppet/alternatives", - "version_requirement": ">=2.0.0 < 4.0.0" + "version_requirement": ">=2.0.0 < 5.0.0" }, { "name": "puppetlabs/mailalias_core", @@ -51,7 +51,8 @@ "operatingsystem": "CentOS", "operatingsystemrelease": [ "7", - "8" + "8", + "9" ] }, { diff --git a/spec/acceptance/postfix_spec.rb b/spec/acceptance/postfix_spec.rb index 6212ac77..c40d19d8 100644 --- a/spec/acceptance/postfix_spec.rb +++ b/spec/acceptance/postfix_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper_acceptance' describe 'postfix class' do @@ -39,7 +41,7 @@ class { 'postfix': it { is_expected.to be_running } end - describe file('/etc/aliases') do + describe file('/etc/aliases', '/usr/bin/mailx') do it { is_expected.to exist } end end diff --git a/spec/classes/postfix_augeas_spec.rb b/spec/classes/postfix_augeas_spec.rb index 3a86c4b7..1839328b 100644 --- a/spec/classes/postfix_augeas_spec.rb +++ b/spec/classes/postfix_augeas_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'postfix::augeas' do @@ -20,6 +22,7 @@ test_content: %r{Provides unit tests and examples for the lens.}, stock_since: '1.0.0') } + it { is_expected.to contain_augeas__lens('postfix_virtual').with(ensure: 'present', lens_content: %r{Parses /etc/postfix/virtual}, diff --git a/spec/classes/postfix_mailman_spec.rb b/spec/classes/postfix_mailman_spec.rb index 075d336a..d11f9b46 100644 --- a/spec/classes/postfix_mailman_spec.rb +++ b/spec/classes/postfix_mailman_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'postfix::mailman' do diff --git a/spec/classes/postfix_mta_spec.rb b/spec/classes/postfix_mta_spec.rb index 981e4df4..0479419d 100644 --- a/spec/classes/postfix_mta_spec.rb +++ b/spec/classes/postfix_mta_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'postfix::mta' do @@ -6,19 +8,26 @@ mydestination => 'bar', mynetworks => '127.0.0.1/8, [::1]/128 ![::2]/128', relayhost => 'foo', + masquerade_classes => ['envelope_sender'], + masquerade_domains => ['host.example.com', 'example.com'], + masquerade_exceptions => ['root'], }" end on_supported_os.each do |os, facts| context "on #{os}" do let(:facts) do - facts + facts.merge(augeasversion: '1.2.0', + puppetversion: Puppet.version) 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') } + it { is_expected.to contain_postfix__config('masquerade_classes').with_value('envelope_sender') } + it { is_expected.to contain_postfix__config('masquerade_domains').with_value('host.example.com example.com') } + it { is_expected.to contain_postfix__config('masquerade_exceptions').with_value('root') } context "when mydestination => 'blank'" do let :pre_condition do diff --git a/spec/classes/postfix_satellite_spec.rb b/spec/classes/postfix_satellite_spec.rb index 96ef35f8..0b8a075a 100644 --- a/spec/classes/postfix_satellite_spec.rb +++ b/spec/classes/postfix_satellite_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'postfix::satellite' do @@ -19,6 +21,7 @@ class { 'postfix': 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', diff --git a/spec/classes/postfix_spec.rb b/spec/classes/postfix_spec.rb index c5c57d8d..843f5dc3 100644 --- a/spec/classes/postfix_spec.rb +++ b/spec/classes/postfix_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'postfix' do @@ -71,6 +73,7 @@ context 'when on release 8', if: (facts[:osfamily] == 'RedHat' && facts[:operatingsystemmajrelease] == '8') do it { is_expected.to contain_file('/etc/aliases').with_seltype('etc_aliases_t').with_content("# file managed by puppet\n") } + it { is_expected.to contain_service('postfix').with( ensure: 'running', @@ -83,6 +86,7 @@ context 'when on release 7', if: (facts[:osfamily] == 'RedHat' && facts[:operatingsystemmajrelease] == '7') do it { is_expected.to contain_file('/etc/aliases').with_seltype('etc_aliases_t').with_content("# file managed by puppet\n") } + it { is_expected.to contain_service('postfix').with( ensure: 'running', @@ -95,6 +99,7 @@ context 'when on release 6', if: (facts[:osfamily] == 'RedHat' && facts[:operatingsystemmajrelease] == '6') do it { is_expected.to contain_file('/etc/aliases').with_seltype('etc_aliases_t').with_content("# file managed by puppet\n") } + it { is_expected.to contain_service('postfix').with( ensure: 'running', @@ -108,6 +113,7 @@ context 'when on Fedora', if: facts[:operatingsystem] == 'Fedora' do it { is_expected.to contain_file('/etc/aliases').with_seltype('etc_aliases_t').with_content("# file managed by puppet\n") } + it { is_expected.to contain_service('postfix').with( ensure: 'running', @@ -119,433 +125,517 @@ end end - context 'when setting parameters' do - case facts[:osfamily] - when 'Debian' - context "when setting smtp_listen to 'all'" do - let(:params) do - { - 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 smtp_listen to 'all'" do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) do + { + 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', - } - end + master_smtps: 'smtps inet n - - - - smtpd', + master_submission: 'submission inet n - - - - smtpd', + } + end - 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_exec('newaliases').with_refreshonly('true') } + 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_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(postfix_master_cf_path).without('seltype').with_content( - %r{smtp inet n - - - - smtpd} - ).with_content( - %r{amavis unix} - ).with_content( - %r{dovecot.*\n.* user=bar:bar } - ).with_content( - %r{schleuder} - ).with_content( - %r{sympa} - ).with_content( - %r{user=bar} - ).with_content( - %r{^smtp.*\n.*smtpd_client_restrictions=check_client_access,hash:} - ).with_content( - %r{^smtps inet n} - ).with_content( - %r{^submission inet n} - ) - } - it { is_expected.to contain_file(postfix_main_cf_path).without('seltype') } + case facts[:os]['family'] + when 'FreeBSD' + it { is_expected.not_to contain_package('mailx') } + else + it { is_expected.to contain_package('mailx') } + end + case facts[:os]['family'] + 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_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_file(postfix_master_cf_path).without('seltype').with_content( + %r{smtp inet n - - - - smtpd} + ).with_content( + %r{amavis unix} + ).with_content( + %r{dovecot.*\n.* user=bar:bar } + ).with_content( + %r{schleuder} + ).with_content( + %r{sympa} + ).with_content( + %r{user=bar} + ).with_content( + %r{^smtp.*\n.*smtpd_client_restrictions=check_client_access,hash:} + ).with_content( + %r{^smtps inet n} + ).with_content( + %r{^submission inet n} + ) + } - it { is_expected.to contain_mailalias('root').with_recipient('foo') } + it { is_expected.to contain_file(postfix_main_cf_path).without('seltype') } - 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) do - { - inet_interfaces: 'localhost2', - } - end - - it 'creates 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 'does stuff' do - skip 'need to write this still' - end - end - context 'when a custom mail_user is specified' do - let(:params) do - { - mail_user: 'bar', - } - end - - it 'adjusts the content of /etc/postfix/master.cf specifying the user' do - is_expected.to contain_file(postfix_master_cf_path).with_content(%r{user=bar}) - end - end - context 'when mailman is true' do - let(:params) do - { - mailman: true, - } - end - - it 'does stuff' do - skip 'need to write this still' - end - end - context 'when specifying a custom mastercf_source' do - let(:params) do - { - mastercf_source: 'testy', - } - end - - it 'does stuff' do - skip 'need to write this still' - end - end - context 'when specifying a custom mastercf_content' do - let(:params) do - { - mastercf_content: 'testy', - } - end - - it 'does stuff' do - skip 'need to write this still' - end - end - context 'when specifying a custom mastercf_template' do - let(:params) do - { - mastercf_template: 'testy', - } - end - - it 'does stuff' do - skip 'need to write this still' - end - end - context 'when specifying a custom mastercf_source and mastercf_content' do - let(:params) do - { - mastercf_source: 'testy_1', - mastercf_content: 'testy_2', - } - end - - it 'fails' do - expect { is_expected.to compile }.to raise_error(%r{mutually exclusive}) - end - end - context 'when specifying a custom mastercf_source and mastercf_template' do - let(:params) do - { - mastercf_source: 'testy_1', - mastercf_template: 'testy_2', - } - end - - it 'fails' do - expect { is_expected.to compile }.to raise_error(%r{mutually exclusive}) - end - end - context 'when specifying a custom mastercf_content and mastercf_template' do - let(:params) do - { - mastercf_content: 'testy_1', - mastercf_template: 'testy_2', - } - end - - it 'fails' do - expect { is_expected.to compile }.to raise_error(%r{mutually exclusive}) - end - end - context 'when specifying a mastercf_source and custom mastercf_content and mastercf_template' do - let(:params) do - { - mastercf_source: 'testy_1', - mastercf_content: 'testy_2', - mastercf_template: 'testy_3', - } - end - - it 'fails' do - expect { is_expected.to compile }.to raise_error(%r{mutually exclusive}) - end - end - context 'when specifying a custom master_smtp' do - let(:params) do - { - master_smtp: "smtp inet n - - - - smtpd - -o smtpd_client_restrictions=check_client_access,hash:/etc/postfix/access,reject", - } - end - - it 'updates master.cf with the specified flags to smtp' do - is_expected.to contain_file(postfix_master_cf_path).with_content( - %r{smtp inet n - - - - smtpd} - ).with_content( - %r{^smtp.*\n.*smtpd_client_restrictions=check_client_access,hash:} - ) - end - end - context 'when specifying a custom master_smtps' do - let(:params) do - { - master_smtps: 'smtps inet n - - - - smtpd', - } - end - - it 'updates master.cf with the specified flags to smtps' do - is_expected.to contain_file(postfix_master_cf_path).with_content(%r{^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 'configures 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:#{postfix_virtual_path}") - is_expected.to contain_postfix__config('transport_maps').with_value("hash:#{postfix_transport_path}") - 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 'fails' do - expect { is_expected.to compile }.to raise_error(%r{Please disable one}) - end - end - end - context 'when specifying mydestination' do - it 'does stuff' do - skip 'need to write this still' - end - end - context 'when specifying mynetworks' do - it 'does stuff' do - skip 'need to write this still' - end - end - context 'when specifying myorigin' do - let(:params) { { myorigin: 'localhost' } } + it { + is_expected.to contain_service('postfix').with( + ensure: 'running', + enable: 'true', + hasstatus: 'true', + restart: '/etc/init.d/postfix reload' + ) + } - it 'creates 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 'does stuff' do - skip 'need to write this still' - end - end - context 'when specifying a root_mail_recipient' do - let(:params) { { root_mail_recipient: 'foo' } } + end - it 'contains 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 'configures 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:#{postfix_virtual_path}") - is_expected.to contain_postfix__config('transport_maps').with_value("hash:#{postfix_transport_path}") - 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 'fails' do - expect { is_expected.to compile }.to raise_error(%r{Please disable one}) - end - end - end - context 'when specifying smtp_listen' do - let(:params) { { smtp_listen: 'all' } } + it { is_expected.to contain_mailalias('root').with_recipient('foo') } + end - it 'does stuff' do - skip 'need to write this still' - end - end - context 'when use_amavisd is true' do - let(:params) { { use_amavisd: true } } + context 'when specifying inet_interfaces' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) do + { + inet_interfaces: 'localhost2', + } + end - it 'updates master.cf with the specified flags to amavis' do - is_expected.to contain_file(postfix_master_cf_path).with_content(%r{amavis unix}) - end - end - context 'when use_dovecot_lda is true' do - let(:params) { { use_dovecot_lda: true } } + it 'creates a postfix::config defined type with inet_interfaces specified properly' do + is_expected.to contain_postfix__config('inet_interfaces').with_value('localhost2') + end + end - it 'updates master.cf with the specified flags to dovecot' do - is_expected.to contain_file(postfix_master_cf_path).with_content(%r{dovecot.*\n.* user=vmail:vmail }) - end - end - context 'when use_schleuder is true' do - let(:params) { { use_schleuder: true } } + context 'when enabling ldap' do + it 'ldap is configured' do + skip 'need to write this still' + end + end - it 'updates master.cf with the specified flags to schleuder' do - is_expected.to contain_file(postfix_master_cf_path).with_content(%r{schleuder}) - end - end - context 'when use_sympa is true' do - let(:params) { { use_sympa: true } } + context 'when a custom mail_user is specified' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) do + { + mail_user: 'bar', + } + end - it 'updates master.cf to include sympa' do - is_expected.to contain_file(postfix_master_cf_path).with_content(%r{sympa}) - end - end - context 'when manage_root_alias is false' do - let(:params) { { manage_root_alias: false } } + it 'adjusts the content of /etc/postfix/master.cf specifying the user' do + is_expected.to contain_file(postfix_master_cf_path).with_content(%r{user=bar}) + end + end - it 'does not manage root mailalias' do - is_expected.not_to contain_mailalias('root') - end - end - context 'when manage_mailx is false' do - let(:params) { { manage_mailx: false } } + context 'when mailman is true' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) do + { + mailman: true, + } + end - it 'does not have mailx package' do - is_expected.not_to contain_package('mailx') - end - end - context 'when config hash is used' do - let(:params) do - { - configs: { - 'message_size_limit' => { - 'value' => '51200000', - }, - }, - } - end + it 'does stuff' do + skip 'need to write this still' + end + end - it 'updates master.cf with the specified contents' do - is_expected.to contain_postfix__config('message_size_limit').with_value('51200000') - end - end - context 'when hash hash is used' do - let(:params) do - { - hash: { - '/etc/postfix/transport' => { - 'ensure' => 'present', - }, - }, - } - end + context 'when specifying a custom mastercf_source' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) do + { + mastercf_source: 'testy', + } + end - it 'updates master.cf with the specified contents' do - is_expected.to contain_postfix__hash('/etc/postfix/transport').with_ensure('present') - end - end - context 'when transport hash is used' do - let(:params) do - { - transport: { - 'local_relay' => { - 'nexthop' => '[10.12.0.2]:9925', - }, - }, - } - end + it 'does stuff' do + skip 'need to write this still' + end + end + + context 'when specifying a custom mastercf_content' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) do + { + mastercf_content: 'testy', + } + end + + it 'does stuff' do + skip 'need to write this still' + end + end + + context 'when specifying a custom mastercf_template' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) do + { + mastercf_template: 'testy', + } + end + + it 'does stuff' do + skip 'need to write this still' + end + end + + context 'when specifying a custom mastercf_source and mastercf_content' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) do + { + mastercf_source: 'testy_1', + mastercf_content: 'testy_2', + } + end + + it 'fails' do + expect { is_expected.to compile }.to raise_error(%r{mutually exclusive}) + end + end + + context 'when specifying a custom mastercf_source and mastercf_template' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) do + { + mastercf_source: 'testy_1', + mastercf_template: 'testy_2', + } + end + + it 'fails' do + expect { is_expected.to compile }.to raise_error(%r{mutually exclusive}) + end + end + + context 'when specifying a custom mastercf_content and mastercf_template' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) do + { + mastercf_content: 'testy_1', + mastercf_template: 'testy_2', + } + end + + it 'fails' do + expect { is_expected.to compile }.to raise_error(%r{mutually exclusive}) + end + end + + context 'when specifying a mastercf_source and custom mastercf_content and mastercf_template' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) do + { + mastercf_source: 'testy_1', + mastercf_content: 'testy_2', + mastercf_template: 'testy_3', + } + end + + it 'fails' do + expect { is_expected.to compile }.to raise_error(%r{mutually exclusive}) + end + end + + context 'when specifying a custom master_smtp' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) do + { + master_smtp: "smtp inet n - - - - smtpd + -o smtpd_client_restrictions=check_client_access,hash:/etc/postfix/access,reject", + } + end + + it 'updates master.cf with the specified flags to smtp' do + is_expected.to contain_file(postfix_master_cf_path).with_content( + %r{smtp inet n - - - - smtpd} + ).with_content( + %r{^smtp.*\n.*smtpd_client_restrictions=check_client_access,hash:} + ) + end + end + + context 'when specifying a custom master_smtps' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) do + { + master_smtps: 'smtps inet n - - - - smtpd', + } + end - it 'updates master.cf with the specified contents' do - is_expected.to contain_postfix__transport('local_relay').with_nexthop('[10.12.0.2]:9925') - end + it 'updates master.cf with the specified flags to smtps' do + is_expected.to contain_file(postfix_master_cf_path).with_content(%r{^smtps inet n}) + end + end + + context 'when mta is enabled' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) { { mta: true, mydestination: '1.2.3.4' } } + + it 'configures 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('virtual_alias_maps').with_value("hash:#{postfix_virtual_path}") + is_expected.to contain_postfix__config('transport_maps').with_value("hash:#{postfix_transport_path}") + end + + it { is_expected.to contain_class('postfix::mta') } + + context 'and satellite is also enabled' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) { { mta: true, satellite: true, mydestination: '1.2.3.4', relayhost: '2.3.4.5' } } + + it 'fails' do + expect { is_expected.to compile }.to raise_error(%r{Please disable one}) end - context 'when virtual hash is used' do - let(:params) do - { - virtual: { - 'someone@somedomain.tld' => { - 'destination' => 'internal@ourdomain.tld', - }, - }, - } - end + end + end + + context 'when specifying mydestination' do + it 'sets mydestination' do + skip 'need to write this still' + end + end - it 'updates master.cf with the specified contents' do - is_expected.to contain_postfix__virtual('someone@somedomain.tld').with_destination('internal@ourdomain.tld') - end + context 'when specifying mynetworks' do + it 'mynetworks is configured' do + skip 'need to write this still' + end + end + + context 'when specifying myorigin' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) { { myorigin: 'localhost' } } + + it 'creates 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 'a relayhost is configured' do + skip 'need to write this still' + end + end + + context 'when specifying a root_mail_recipient' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) { { root_mail_recipient: 'foo' } } + + it 'contains 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 # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) { { satellite: true, mydestination: '1.2.3.4', relayhost: '2.3.4.5' } } + let :pre_condition do + "class { 'augeas': }" + end + + it 'configures 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:#{postfix_virtual_path}") + is_expected.to contain_postfix__config('transport_maps').with_value("hash:#{postfix_transport_path}") + end + + context 'and mta is also enabled' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) { { mta: true, satellite: true, mydestination: '1.2.3.4', relayhost: '2.3.4.5' } } + + it 'fails' do + expect { is_expected.to compile }.to raise_error(%r{Please disable one}) end - context 'when conffile hash is used' do - let(:params) do - { - conffile: { - 'ldapoptions.cf' => { - 'mode' => '0640', - 'options' => { - 'server_host' => 'ldap.mydomain.com', - 'bind' => 'yes', - 'bind_dn' => 'cn=admin,dc=mydomain,dc=com', - 'bind_pw' => 'password', - 'search_base' => 'dc=example, dc=com', - 'query_filter' => 'mail=%s', - 'result_attribute' => 'uid', - }, - }, - }, - } - end + end + end + + context 'when specifying smtp_listen' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) { { smtp_listen: 'all' } } + + it 'updates master.cf to listen to all addresses' do + is_expected.to contain_file(postfix_master_cf_path).with_content( + %r{smtp inet n - n - - smtpd} + ) + end + end - it 'creates ldapoptions.cf with the specified contents' do - is_expected.to contain_postfix__conffile('ldapoptions.cf').with( - 'mode' => '0640', + context 'when specifying multiple smtp_listen addresses as string' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) { { smtp_listen: '192.168.0.123 10.0.0.123' } } + + it 'updates master.cf with multiple smtp listeners' do + is_expected.to contain_file(postfix_master_cf_path).with_content( + %r{192.168.0.123:smtp inet n - n - - smtpd} + ).with_content( + %r{10.0.0.123:smtp inet n - n - - smtpd} + ) + end + end + + context 'when specifying multiple smtp_listen addresses as array' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) { { smtp_listen: ['192.168.0.123', '10.0.0.123'] } } + + it 'updates master.cf with multiple smtp listeners' do + is_expected.to contain_file(postfix_master_cf_path).with_content( + %r{192.168.0.123:smtp inet n - n - - smtpd} + ).with_content( + %r{10.0.0.123:smtp inet n - n - - smtpd} + ) + end + end + + context 'when use_amavisd is true' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) { { use_amavisd: true } } + + it 'updates master.cf with the specified flags to amavis' do + is_expected.to contain_file(postfix_master_cf_path).with_content(%r{amavis unix}) + end + end + + context 'when use_dovecot_lda is true' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) { { use_dovecot_lda: true } } + + it 'updates master.cf with the specified flags to dovecot' do + is_expected.to contain_file(postfix_master_cf_path).with_content(%r{dovecot.*\n.* user=vmail:vmail }) + end + end + + context 'when use_schleuder is true' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) { { use_schleuder: true } } + + it 'updates master.cf with the specified flags to schleuder' do + is_expected.to contain_file(postfix_master_cf_path).with_content(%r{schleuder}) + end + end + + context 'when use_sympa is true' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) { { use_sympa: true } } + + it 'updates master.cf to include sympa' do + is_expected.to contain_file(postfix_master_cf_path).with_content(%r{sympa}) + end + end + + context 'when manage_root_alias is false' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) { { manage_root_alias: false } } + + it 'does not manage root mailalias' do + is_expected.not_to contain_mailalias('root') + end + end + + context 'when manage_mailx is false' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) { { manage_mailx: false } } + + it 'does not have mailx package' do + is_expected.not_to contain_package('mailx') + end + end + + context 'when config hash is used' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) do + { + configs: { + 'message_size_limit' => { + 'value' => '51200000', + }, + }, + } + end + + it 'updates main.cf with the specified contents' do + is_expected.to contain_postfix__config('message_size_limit').with_value('51200000') + end + end + + context 'when hashes hash is used' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) do + { + hashes: { + '/etc/postfix/transport' => { + 'ensure' => 'present', + }, + }, + } + end + + it 'creates the hash' do + is_expected.to contain_postfix__hash('/etc/postfix/transport').with_ensure('present') + end + end + + context 'when transports hash is used' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) do + { + transports: { + 'local_relay' => { + 'nexthop' => '[10.12.0.2]:9925', + }, + }, + } + end + + it 'updates the transport map' do + is_expected.to contain_postfix__transport('local_relay').with_nexthop('[10.12.0.2]:9925') + end + end + + context 'when virtuals hash is used' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) do + { + virtuals: { + 'someone@somedomain.tld' => { + 'destination' => 'internal@ourdomain.tld', + }, + }, + } + end + + it 'updates the virtual map' do + is_expected.to contain_postfix__virtual('someone@somedomain.tld').with_destination('internal@ourdomain.tld') + end + end + + context 'when conffiles hash is used' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) do + { + conffiles: { + 'ldapoptions.cf' => { + 'mode' => '0640', 'options' => { - 'server_host' => 'ldap.mydomain.com', - 'bind' => 'yes', - 'bind_dn' => 'cn=admin,dc=mydomain,dc=com', - 'bind_pw' => 'password', - 'search_base' => 'dc=example, dc=com', - 'query_filter' => 'mail=%s', + 'server_host' => 'ldap.mydomain.com', + 'bind' => 'yes', + 'bind_dn' => 'cn=admin,dc=mydomain,dc=com', + 'bind_pw' => 'password', + 'search_base' => 'dc=example, dc=com', + 'query_filter' => 'mail=%s', 'result_attribute' => 'uid', - } - ) - end - end + }, + }, + }, + } + end + + it 'creates ldapoptions.cf with the specified contents' do + is_expected.to contain_postfix__conffile('ldapoptions.cf').with( + 'mode' => '0640', + 'options' => { + 'server_host' => 'ldap.mydomain.com', + 'bind' => 'yes', + 'bind_dn' => 'cn=admin,dc=mydomain,dc=com', + 'bind_pw' => 'password', + 'search_base' => 'dc=example, dc=com', + 'query_filter' => 'mail=%s', + 'result_attribute' => 'uid', + } + ) + end + end + + context 'when maps hash is used' do # rubocop:disable RSpec/MultipleMemoizedHelpers + let(:params) do + { + maps: { + 'a_map' => { + 'type' => 'regexp', + 'content' => 'abc xyz', + }, + }, + } + end + + it 'creates the map resource' do + is_expected.to contain_postfix__map('a_map').with( + 'type' => 'regexp', + 'content' => 'abc xyz' + ) end end end diff --git a/spec/defines/postfix_conffile_spec.rb b/spec/defines/postfix_conffile_spec.rb index 5e5db2f2..ef7d533d 100644 --- a/spec/defines/postfix_conffile_spec.rb +++ b/spec/defines/postfix_conffile_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'postfix::conffile' do @@ -13,20 +15,6 @@ facts end - context 'when passing wrong type for ensure' do - let(:params) do - { - ensure: ['present'], - } - end - - it 'fails' do - expect do - is_expected.to contain_file('postfix conffile foo') - end.to raise_error - end - end - context 'when passing wrong value for ensure' do let(:params) do { @@ -96,15 +84,15 @@ # context 'when passing options parameter' do # let(:params) { { - #:options => { - #:server_host => 'ldap.mydomain.com', - #:bind => 'no', + # :options => { + # :server_host => 'ldap.mydomain.com', + # :bind => 'no', # }, # } } # it { is_expected.to contain_file('postfix conffile foo').with( - #:ensure => 'present', - #:content => '# + # :ensure => 'present', + # :content => '# ###################################################### ## File managed by puppet ## DO NOT EDITY!!! diff --git a/spec/defines/postfix_config_spec.rb b/spec/defines/postfix_config_spec.rb index 630d6603..3038b582 100644 --- a/spec/defines/postfix_config_spec.rb +++ b/spec/defines/postfix_config_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'postfix::config' do @@ -23,36 +25,7 @@ it 'fails' do expect do is_expected.to contain_augeas("set postfix 'foo'") - end.to raise_error - end - end - - context 'when passing wrong type for value' do - let(:params) do - { - value: ['bar'], - } - end - - it 'fails' do - expect do - is_expected.to contain_augeas("set postfix 'foo'") - end.to raise_error - end - end - - context 'when passing wrong type for ensure' do - let(:params) do - { - value: 'bar', - ensure: ['present'], - } - end - - it 'fails' do - expect do - is_expected.to contain_augeas("set postfix 'foo'") - end.to raise_error + end.to raise_error(Puppet::Error, %r{can not be empty if ensure = present}) end end diff --git a/spec/defines/postfix_hash_spec.rb b/spec/defines/postfix_hash_spec.rb index bf03bb66..1ca7576a 100644 --- a/spec/defines/postfix_hash_spec.rb +++ b/spec/defines/postfix_hash_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'postfix::hash' do @@ -13,20 +15,6 @@ facts end - context 'when passing wrong type for ensure' do - let(:params) do - { - ensure: ['present'], - } - end - - it 'fails' do - expect do - is_expected.to contain_file('/tmp/foo') - end.to raise_error - end - end - context 'when passing wrong value for ensure' do let(:params) do { @@ -79,6 +67,7 @@ source: '/tmp/bar' ).without(:content) } + it { is_expected.to contain_file('postfix map /tmp/foo.db').with_ensure('present') } it { is_expected.to contain_exec('generate /tmp/foo.db') } end @@ -96,6 +85,7 @@ content: 'bar' ).without(:source) } + it { is_expected.to contain_file('postfix map /tmp/foo.db').with_ensure('present') } it { is_expected.to contain_exec('generate /tmp/foo.db') } end @@ -106,6 +96,7 @@ ensure: 'present' ).without(:source).without(:content) } + it { is_expected.to contain_file('postfix map /tmp/foo.db').with_ensure('present') } it { is_expected.to contain_exec('generate /tmp/foo.db') } end diff --git a/spec/defines/postfix_map_spec.rb b/spec/defines/postfix_map_spec.rb index d346e47c..a52d89b9 100644 --- a/spec/defines/postfix_map_spec.rb +++ b/spec/defines/postfix_map_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'postfix::map' do @@ -20,20 +22,6 @@ facts end - context 'when passing wrong type for ensure' do - let(:params) do - { - ensure: ['present'], - } - end - - it 'fails' do - expect do - is_expected.to contain_file('postfix map foo') - end.to raise_error - end - end - context 'when passing wrong value for ensure' do let(:params) do { @@ -76,6 +64,7 @@ source: '/tmp/bar' ).without(:content) } + it { is_expected.to contain_file('postfix map foo.db').with_ensure('present') } it { is_expected.to contain_exec('generate foo.db') } end @@ -93,6 +82,7 @@ content: 'bar' ).without(:source) } + it { is_expected.to contain_file('postfix map foo.db').with_ensure('present') } it { is_expected.to contain_exec('generate foo.db') } end @@ -103,6 +93,7 @@ ensure: 'present' ).without(:source).without(:content) } + it { is_expected.to contain_file('postfix map foo.db').with_ensure('present') } it { is_expected.to contain_exec('generate foo.db') } end @@ -141,6 +132,17 @@ it { is_expected.to contain_file('postfix map foo').with_ensure('present') } it { is_expected.not_to contain_file('postfix map foo.db') } end + + context 'when using regexp type' do + let(:params) do + { + type: 'regexp', + } + end + + it { is_expected.to contain_file('postfix map foo').with_ensure('present') } + it { is_expected.not_to contain_file('postfix map foo.db') } + end end end end diff --git a/spec/defines/postfix_transport_spec.rb b/spec/defines/postfix_transport_spec.rb index 1a9cfdbd..30a1d8f6 100644 --- a/spec/defines/postfix_transport_spec.rb +++ b/spec/defines/postfix_transport_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'postfix::transport' do @@ -24,50 +26,6 @@ class { '::postfix': } puppetversion: Puppet.version) end - context 'when sending wrong type for destination' do - let(:params) do - { - destination: ['bar'], - } - end - - it 'fails' do - expect do - is_expected.to contain_augeas('Postfix transport - foo') - end.to raise_error - end - end - - context 'when sending wrong type for nexthop' do - let(:params) do - { - destination: 'bar', - nexthop: ['baz'], - } - end - - it 'fails' do - expect do - is_expected.to contain_augeas('Postfix transport - foo') - end.to raise_error - end - end - - context 'when sending wrong type for file' do - let(:params) do - { - destination: 'bar', - file: ['baz'], - } - end - - it 'fails' do - expect do - is_expected.to contain_augeas('Postfix transport - foo') - end.to raise_error - end - end - context 'when sending wrong value for file' do let(:params) do { @@ -83,21 +41,6 @@ class { '::postfix': } end end - context 'when sending wrong type for ensure' do - let(:params) do - { - destination: 'bar', - ensure: ['baz'], - } - end - - it 'fails' do - expect do - is_expected.to contain_augeas('Postfix transport - foo') - end.to raise_error - end - end - context 'when sending wrong value for ensure' do let(:params) do { @@ -115,6 +58,7 @@ class { '::postfix': } 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: postfix_transport_path, @@ -141,6 +85,7 @@ class { '::postfix': } end it { is_expected.to contain_class('postfix::augeas') } + it { is_expected.to contain_augeas('Postfix transport - foo').with( incl: '/tmp/transport', @@ -167,6 +112,7 @@ class { '::postfix': } end it { is_expected.to contain_class('postfix::augeas') } + it { is_expected.to contain_augeas('Postfix transport - foo').with( incl: '/tmp/transport', @@ -191,6 +137,7 @@ class { '::postfix': } end it { is_expected.to contain_class('postfix::augeas') } + it { is_expected.to contain_augeas('Postfix transport - foo').with( incl: postfix_transport_path, diff --git a/spec/defines/postfix_virtual_spec.rb b/spec/defines/postfix_virtual_spec.rb index 9b2e8b2f..5a75fe96 100644 --- a/spec/defines/postfix_virtual_spec.rb +++ b/spec/defines/postfix_virtual_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'postfix::virtual' do @@ -32,35 +34,6 @@ class { '::postfix': } end end - context 'when sending wrong type for destination' do - let(:params) do - { - destination: true, - } - end - - it 'fails' do - expect do - is_expected.to contain_augeas('Postfix virtual - foo') - end.to raise_error - end - end - - context 'when sending wrong type for file' do - let(:params) do - { - destination: 'bar', - file: ['baz'], - } - end - - it 'fails' do - expect do - is_expected.to contain_augeas('Postfix virtual - foo') - end.to raise_error - end - end - context 'when sending wrong value for file' do let(:params) do { @@ -76,21 +49,6 @@ class { '::postfix': } end end - context 'when sending wrong type for ensure' do - let(:params) do - { - destination: 'bar', - ensure: ['baz'], - } - end - - it 'fails' do - expect do - is_expected.to contain_augeas('Postfix virtual - foo') - end.to raise_error - end - end - context 'when sending wrong value for ensure' do let(:params) do { @@ -114,6 +72,7 @@ class { '::postfix': } end it { is_expected.to contain_class('postfix::augeas') } + it { is_expected.to contain_augeas('Postfix virtual - foo').with( incl: postfix_virutal_path, @@ -137,6 +96,7 @@ class { '::postfix': } end it { is_expected.to contain_class('postfix::augeas') } + it { is_expected.to contain_augeas('Postfix virtual - foo').with( incl: '/tmp/virtual', @@ -160,6 +120,7 @@ class { '::postfix': } end it { is_expected.to contain_class('postfix::augeas') } + it { is_expected.to contain_augeas('Postfix virtual - foo').with( incl: '/tmp/virtual', @@ -183,6 +144,7 @@ class { '::postfix': } end it { is_expected.to contain_class('postfix::augeas') } + it { is_expected.to contain_augeas('Postfix virtual - foo').with( incl: postfix_virutal_path, diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fb5f0cbe..4d617f39 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,17 +1,17 @@ +# frozen_string_literal: true + # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ # puppetlabs_spec_helper will set up coverage if the env variable is set. # We want to do this if lib exists and it hasn't been explicitly set. -ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../../lib', __FILE__)) +ENV['COVERAGE'] ||= 'yes' if Dir.exist?(File.expand_path('../lib', __dir__)) require 'voxpupuli/test/spec_helper' if File.exist?(File.join(__dir__, 'default_module_facts.yml')) facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml'))) - if facts - facts.each do |name, value| - add_custom_fact name.to_sym, value - end + facts&.each do |name, value| + add_custom_fact name.to_sym, value end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index d3b906bf..d3a6e23c 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ diff --git a/spec/spec_helper_local.rb b/spec/spec_helper_local.rb index f7d3642a..6062c395 100644 --- a/spec/spec_helper_local.rb +++ b/spec/spec_helper_local.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.configure do |c| c.filter_run_excluding(excl: true) end diff --git a/templates/master.cf.FreeBSD.erb b/templates/master.cf.FreeBSD.erb index 7f2899fa..f48593dd 100644 --- a/templates/master.cf.FreeBSD.erb +++ b/templates/master.cf.FreeBSD.erb @@ -15,7 +15,9 @@ <% elsif @smtp_listen == 'all' -%> smtp inet n - <%= @jail %> - - smtpd <% else -%> -<%= @smtp_listen %>:smtp inet n - <%= @jail %> - - smtpd + <%- (@smtp_listen.is_a?(Array) ? @smtp_listen : @smtp_listen.split(' ')).each do |listen_address| -%> +<%= listen_address %>:smtp inet n - <%= @jail %> - - smtpd + <%- end -%> <% end -%> <% if @master_submission -%> <%= @master_submission %> diff --git a/templates/master.cf.SLES11.2.erb b/templates/master.cf.SLES11.2.erb index 2467261c..30f8262f 100644 --- a/templates/master.cf.SLES11.2.erb +++ b/templates/master.cf.SLES11.2.erb @@ -12,7 +12,9 @@ <% if @smtp_listen == 'all' -%> smtp inet n - <%= @jail %> - - smtpd <% else -%> -<%= @smtp_listen %>:smtp inet n - <%= @jail %> - - smtpd + <%- (@smtp_listen.is_a?(Array) ? @smtp_listen : @smtp_listen.split(' ')).each do |listen_address| -%> +<%= listen_address %>:smtp inet n - <%= @jail %> - - smtpd + <%- end -%> <% end -%> #smtp inet n - n - - smtpd #submission inet n - n - - smtpd diff --git a/templates/master.cf.SLES11.3.erb b/templates/master.cf.SLES11.3.erb index 93f44184..e000c2fb 100644 --- a/templates/master.cf.SLES11.3.erb +++ b/templates/master.cf.SLES11.3.erb @@ -12,7 +12,9 @@ <% if @smtp_listen == 'all' -%> smtp inet n - <%= @jail %> - - smtpd <% else -%> -<%= @smtp_listen %>:smtp inet n - <%= @jail %> - - smtpd + <%- (@smtp_listen.is_a?(Array) ? @smtp_listen : @smtp_listen.split(' ')).each do |listen_address| -%> +<%= listen_address %>:smtp inet n - <%= @jail %> - - smtpd + <%- end -%> <% end -%> #smtp inet n - n - - smtpd #submission inet n - n - - smtpd diff --git a/templates/master.cf.SLES11.4.erb b/templates/master.cf.SLES11.4.erb index 88058fb0..8a5f5270 100644 --- a/templates/master.cf.SLES11.4.erb +++ b/templates/master.cf.SLES11.4.erb @@ -12,7 +12,9 @@ <% if @smtp_listen == 'all' -%> smtp inet n - <%= @jail %> - - smtpd <% else -%> -<%= @smtp_listen %>:smtp inet n - <%= @jail %> - - smtpd + <%- (@smtp_listen.is_a?(Array) ? @smtp_listen : @smtp_listen.split(' ')).each do |listen_address| -%> +<%= listen_address %>:smtp inet n - <%= @jail %> - - smtpd + <%- end -%> <% end -%> #submission inet n - n - - smtpd # -o smtpd_etrn_restrictions=reject diff --git a/templates/master.cf.SLES12.2.erb b/templates/master.cf.SLES12.2.erb index 1cdb7229..0d1a23e4 100644 --- a/templates/master.cf.SLES12.2.erb +++ b/templates/master.cf.SLES12.2.erb @@ -14,7 +14,9 @@ <% elsif @smtp_listen == 'all' -%> smtp inet n - n - - smtpd <% else -%> -<%= @smtp_listen %>:smtp inet n - n - - smtpd + <%- (@smtp_listen.is_a?(Array) ? @smtp_listen : @smtp_listen.split(' ')).each do |listen_address| -%> +<%= listen_address %>:smtp inet n - <%= @jail %> - - smtpd + <%- end -%> <% end -%> <% if @master_submission -%> <%= @master_submission %> diff --git a/templates/master.cf.SLES12.3.erb b/templates/master.cf.SLES12.3.erb index 1cdb7229..0d1a23e4 100644 --- a/templates/master.cf.SLES12.3.erb +++ b/templates/master.cf.SLES12.3.erb @@ -14,7 +14,9 @@ <% elsif @smtp_listen == 'all' -%> smtp inet n - n - - smtpd <% else -%> -<%= @smtp_listen %>:smtp inet n - n - - smtpd + <%- (@smtp_listen.is_a?(Array) ? @smtp_listen : @smtp_listen.split(' ')).each do |listen_address| -%> +<%= listen_address %>:smtp inet n - <%= @jail %> - - smtpd + <%- end -%> <% end -%> <% if @master_submission -%> <%= @master_submission %> diff --git a/templates/master.cf.Solaris.erb b/templates/master.cf.Solaris.erb index 91a2aee3..3cba35f7 100644 --- a/templates/master.cf.Solaris.erb +++ b/templates/master.cf.Solaris.erb @@ -12,7 +12,9 @@ <% elsif @smtp_listen == 'all' -%> smtp inet n - <%= @jail %> - - smtpd <% else -%> -<%= @smtp_listen %>:smtp inet n - <%= @jail %> - - smtpd + <%- (@smtp_listen.is_a?(Array) ? @smtp_listen : @smtp_listen.split(' ')).each do |listen_address| -%> +<%= listen_address %>:smtp inet n - <%= @jail %> - - smtpd + <%- end -%> <% end -%> <% if @master_submission -%> <%= @master_submission %> diff --git a/templates/master.cf.common.erb b/templates/master.cf.common.erb index ef275d24..77ca445b 100644 --- a/templates/master.cf.common.erb +++ b/templates/master.cf.common.erb @@ -36,6 +36,4 @@ sympa unix - n n - - pipe sympabounce unix - n n - - pipe flags=R user=sympa argv=/usr/lib/sympa/bin/bouncequeue ${user} <% end -%> -<% if @master_entries %> <%= @master_entries.join("\n") %> -<% end -%> diff --git a/templates/master.cf.debian.erb b/templates/master.cf.debian.erb index afa9174a..086c5cc0 100644 --- a/templates/master.cf.debian.erb +++ b/templates/master.cf.debian.erb @@ -12,7 +12,9 @@ <% elsif @smtp_listen == 'all' -%> smtp inet n - <%= @jail %> - - smtpd <% else -%> -<%= @smtp_listen %>:smtp inet n - <%= @jail %> - - smtpd + <%- (@smtp_listen.is_a?(Array) ? @smtp_listen : @smtp_listen.split(' ')).each do |listen_address| -%> +<%= listen_address %>:smtp inet n - <%= @jail %> - - smtpd + <%- end -%> <% end -%> <% if @master_submission -%> <%= @master_submission %> diff --git a/templates/master.cf.redhat.erb b/templates/master.cf.redhat.erb index ec907ea2..3d0f4bde 100644 --- a/templates/master.cf.redhat.erb +++ b/templates/master.cf.redhat.erb @@ -12,7 +12,9 @@ <% elsif @smtp_listen == 'all' -%> smtp inet n - <%= @jail %> - - smtpd <% else -%> -<%= @smtp_listen %>:smtp inet n - <%= @jail %> - - smtpd + <%- (@smtp_listen.is_a?(Array) ? @smtp_listen : @smtp_listen.split(' ')).each do |listen_address| -%> +<%= listen_address %>:smtp inet n - <%= @jail %> - - smtpd + <%- end -%> <% end -%> <% if @master_submission -%> <%= @master_submission %> diff --git a/templates/master.cf.sles.erb b/templates/master.cf.sles.erb index ad3cd137..11e43cb8 100644 --- a/templates/master.cf.sles.erb +++ b/templates/master.cf.sles.erb @@ -15,7 +15,9 @@ <% elsif @smtp_listen == 'all' -%> smtp inet n - <%= @jail %> - - smtpd <% else -%> -<%= @smtp_listen %>:smtp inet n - <%= @jail %> - - smtpd + <%- (@smtp_listen.is_a?(Array) ? @smtp_listen : @smtp_listen.split(' ')).each do |listen_address| -%> +<%= listen_address %>:smtp inet n - <%= @jail %> - - smtpd + <%- end -%> <% end -%> <% if @master_submission -%> <%= @master_submission %>