Defined Type: postfix::hash

Defined in:
manifests/hash.pp

Summary

Creates Postfix hashed "map" files, and builds the corresponding db file

Overview

Creates Postfix hashed “map” files. It will create “$name”, and then build “$name.<table type suffix>” using the “postmap” command. The map file can then be referred to using postfix::config.

Examples:

Creates a virtual hashmap

# This example creates a virtual hashmap in the Postfix config dir
# and adds a value into it with the postfix::config type.
postfix::hash { 'virtual':
  ensure => present,
}
postfix::config { 'virtual_alias_maps':
  value => 'hash:/etc/postfix/virtual',
}

Create a sasl_passwd hash from a source file

postfix::hash { '/etc/postfix/sasl_passwd':
  ensure  => 'present',
  source  => 'puppet:///modules/profile/postfix/client/sasl_passwd',
}

Create a sasl_passwd hash with contents defined in the manifest

postfix::hash { '/etc/postfix/sasl_passwd':
  ensure  => 'present',
  content => '#Destination                Credentials\nsmtp.example.com            gssapi:nopassword',
}

Parameters:

  • ensure (Enum['present', 'absent']) (defaults to: 'present')

    Defines whether the hash map file is present or not. Value can either be present or absent. Example: ‘absent`.

  • source (Variant[Array[String], String, Undef]) (defaults to: undef)

    A string whose value is a location for the source file to be used. This parameter is mutually exclusive with the content parameter, one or the other must be present, but both cannot be present. Example: ‘puppet:///modules/some/location/sasl_passwd`.

  • content (Optional[Variant[Sensitive[String],String]]) (defaults to: undef)

    A free form string that defines the contents of the file. This parameter is mutually exclusive with the source parameter. Example: ‘#Destination Credentialsnsmtp.example.com gssapi:nopassword`.

  • mode (Stdlib::Filemode) (defaults to: '0640')

    the desired file mode



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'manifests/hash.pp', line 45

define postfix::hash (
  Enum['present', 'absent']                   $ensure  = 'present',
  Variant[Array[String], String, Undef]       $source  = undef,
  Optional[Variant[Sensitive[String],String]] $content = undef,
  Stdlib::Filemode                            $mode    = '0640',
) {
  include postfix::params

  assert_type(Stdlib::Absolutepath, $name)

  if (!defined(Class['postfix'])) {
    fail 'You must define class postfix before using postfix::config!'
  }

  if $source and $content {
    fail 'You must provide either \'source\' or \'content\', not both'
  }

  postfix::map { $name:
    ensure  => $ensure,
    source  => $source,
    content => $content,
    type    => $postfix::lookup_table_type,
    path    => $name,
    mode    => $mode,
  }
}