Unverified Commit 12937edf authored by Romain Tartière's avatar Romain Tartière Committed by GitHub
Browse files

Merge pull request #336 from dodevops/feature/replace-hash-with-cdb

parents f51bf0ef a46ff7c8
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -31,12 +31,17 @@
#   Where to create the file. If not defined "${postfix::confdir}/canonical"
#   will be used as path.
#
# @param lookup_table_suffix
#   Depends on the lookup table type, which is used on the postfix::hash and postfix::config resources.
#   Defaults to 'db', the suffix of the "hash" type.
#
# @see https://www.postfix.org/canonical.5.html
#
define postfix::canonical (
  String                   $destination,
  Enum['present','absent'] $ensure              = 'present',
  Stdlib::Absolutepath     $file        = undef
  Stdlib::Absolutepath     $file                = undef,
  String[1]                $lookup_table_suffix = 'db',
) {
  include postfix
  include postfix::augeas
@@ -65,6 +70,6 @@ define postfix::canonical (
    lens    => 'Postfix_Canonical.lns',
    changes => $changes,
    require => [Package['postfix'], Augeas::Lens['postfix_canonical']],
    notify  => Exec["generate ${_file}.db"],
    notify  => Exec["generate ${_file}.${lookup_table_suffix}"],
  }
}
+2 −2
Original line number Diff line number Diff line
# @summary Creates Postfix hashed "map" files, and builds the corresponding db file
#
# Creates Postfix hashed "map" files. It will create "${name}", and then build
# "${name}.db" using the "postmap" command. The map file can then be referred to
# "${name}.<table type suffix>" using the "postmap" command. The map file can then be referred to
# using postfix::config.
#
# @example Creates a virtual hashmap
@@ -62,7 +62,7 @@ define postfix::hash (
    ensure  => $ensure,
    source  => $source,
    content => $content,
    type    => 'hash',
    type    => $postfix::lookup_table_type,
    path    => $name,
    mode    => $mode,
  }
+5 −0
Original line number Diff line number Diff line
@@ -86,6 +86,10 @@
#   A free form string that can define any LDAP options to be passed through (ldap_table(5)).
#   Example: `start_tls = yes`.
#
# @param lookup_table_type
#   Table format type as described in http://www.postfix.org/DATABASE_README.html#types.
#   Type has to be supported by system, see "postconf -m" for supported types.
#
# @param mail_user
#   A string defining the mail user, and optionally group, to execute external commands as.
#   This parameter maps to the user parameter (pipe(8)).
@@ -258,6 +262,7 @@ class postfix (
  Optional[String]                     $ldap_base             = undef,
  Optional[String]                     $ldap_host             = undef,
  Optional[String]                     $ldap_options          = undef,
  String                               $lookup_table_type     = 'hash',
  String                               $mail_user             = 'vmail',       # postfix_mail_user
  Boolean                              $mailman               = false,
  String                               $mailx_ensure          = 'present',
+2 −2
Original line number Diff line number Diff line
@@ -12,9 +12,9 @@ class postfix::mailman {

  postfix::config {
    'virtual_alias_maps':
      value => "hash:${postfix::confdir}/virtual";
      value => "${postfix::lookup_table_type}:${postfix::confdir}/virtual";
    'transport_maps':
      value => "hash:${postfix::confdir}/transport";
      value => "${postfix::lookup_table_type}:${postfix::confdir}/transport";
    'mailman_destination_recipient_limit':
      value => '1';
  }
+14 −6
Original line number Diff line number Diff line
@@ -55,12 +55,20 @@ define postfix::map (
    fail 'You must provide either \'source\' or \'content\', not both'
  }

  $_generated_suffix = $type ? {
    'cdb'   => 'cdb',
    'dbm'   => 'dir',
    'lmdb'  => 'lmdb',
    'sdbm'  => 'dir',
    default => 'db',
  }

  # CIDR and PCRE maps need a postfix reload, but not a postmap
  if $type =~ /^(cidr|pcre|regexp)$/ {
    $manage_notify = Service['postfix']
  } else {
    if $ensure == 'present' {
      $manage_notify = Exec["generate ${name}.db"]
      $manage_notify = Exec["generate ${name}.${_generated_suffix}"]
    } else {
      $manage_notify = undef
    }
@@ -79,9 +87,9 @@ define postfix::map (
  }

  if $type !~ /^(cidr|pcre|regexp)$/ {
    file { "postfix map ${name}.db":
    file { "postfix map ${name}.${_generated_suffix}":
      ensure  => $ensure,
      path    => "${_path}.db",
      path    => "${_path}.${_generated_suffix}",
      owner   => 'root',
      group   => 'postfix',
      mode    => $mode,
@@ -91,11 +99,11 @@ define postfix::map (
  }

  $generate_cmd = $ensure ? {
    'absent'  => "rm ${_path}.db",
    'present' => "postmap ${_path}",
    'absent'  => "rm ${_path}.${_generated_suffix}",
    'present' => "postmap ${type}:${_path}",
  }

  exec { "generate ${name}.db":
  exec { "generate ${name}.${_generated_suffix}":
    command     => $generate_cmd,
    path        => $facts['path'],
    #creates    => "${name}.db", # this prevents postmap from being run !
Loading