Commit 4fdb6536 authored by Rurik Ylä-Onnenvuori's avatar Rurik Ylä-Onnenvuori Committed by Raphaël Pinson
Browse files

Introduce new parameter 'config' for adding configuration using hiera (#240)

With configs hash user can define configuration values in hiera.
parent 1655262e
Loading
Loading
Loading
Loading
+6 −0
Changes for README.md: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -31,6 +31,12 @@ A string defining the location of the alias map file.
Default: 'hash:/etc/aliases'.  
Example: 'hash:/etc/other_aliases'.

##### `configs`

A hash containing optional configuration values for main.cf. The values are configured using postfix::config.  
Default: An empty hash.  
Example: '{message_size_limit': {'value': '51200000'}}.

##### `inet_interfaces`

A string defining the network interfaces that Postfix will listen on.  
+5 −0
Changes for manifests/init.pp: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@
#
# [*alias_maps*]          - (string)
#
# [*configs*]             - (hash)
#
# [*inet_interfaces*]     - (string)
#
# [*inet_protocols*]      - (string)
@@ -84,6 +86,7 @@
#
class postfix (
  String                          $alias_maps          = 'hash:/etc/aliases',
  Optional[Hash]                  $configs             = {},
  String                          $inet_interfaces     = 'all',
  String                          $inet_protocols      = 'all',
  Boolean                         $ldap                = false,
@@ -132,6 +135,8 @@ class postfix (
    true  => "${alias_maps}, ldap:/etc/postfix/ldap-aliases.cf",
  }

  create_resources('::postfix::config', $configs)

  anchor { 'postfix::begin': }
  -> class { '::postfix::packages': }
  -> class { '::postfix::files': }
+10 −0
Changes for spec/classes/postfix_spec.rb: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -302,6 +302,16 @@ describe 'postfix' do
              is_expected.not_to contain_package('mailx')
            end
          end
          context 'when config hash is used' do
            let (:params) { {
              :configs => {
                'message_size_limit' => {
                  'value' => '51200000'
              } } } }
            it 'should update master.cf with the specified contents' do
              is_expected.to contain_postfix__config('message_size_limit').with_value('51200000')
            end
          end
        end
      end
    end