Skip to content
Snippets Groups Projects
Select Git revision
  • 8bc885887aaa6a4ae7ebcb4daaa2206636e972f0
  • master default protected
  • update-min-openvox-version-07f8cb2
  • cleanup_fixtures
  • add-openvox
  • freebsd-14
  • remove-legacy-top-scope-syntax
  • rel430
  • tests
  • revert-363-augeas-module-cleanup
  • release-4.1.0
  • puppet8
  • relax-dependencies
  • rel400
  • mode
  • puppet7
  • release-3.1.0
  • freebsd13
  • freebsd11
  • stdlib
  • centos
  • v6.0.0
  • v5.1.0
  • v5.0.0
  • v4.5.0
  • v4.4.0
  • v4.3.0
  • v4.2.1
  • v4.2.0
  • v4.1.0
  • v4.0.0
  • v3.1.0
  • v3.0.0
  • v2.0.0
  • 1.12.0
  • 1.11.0
  • 1.10.0
  • 1.9.0
  • 1.8.0
  • 1.7.0
  • 1.6.0
41 results

map.pp

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    map.pp 2.25 KiB
    # == Definition: postfix::map
    #
    # Creates postfix "map" files. It will create "${name}", and then build
    # "${name}.db" using the "postmap" command. The map file can then be referred to
    # using postfix::config.
    #
    # === Parameters
    #
    # [*name*]   - the name of the map file.
    # [*ensure*] - present/absent, defaults to present.
    # [*source*] - file source.
    # [*type*]   - type of the postfix map (valid values are cidr, pcre, hash...)
    # [*path*]   - path of the created file. By default it is placed in the
    #              postfix directory
    #
    # === Requires
    #
    # - Class["postfix"]
    #
    # === Examples
    #
    #   postfix::map { '/etc/postfix/virtual':
    #     ensure => present,
    #   }
    #   postfix::config { 'virtual_alias_maps':
    #     value => 'hash:/etc/postfix/virtual',
    #   }
    #
    define postfix::map (
      Enum['present', 'absent']             $ensure = 'present',
      Variant[Array[String], String, Undef] $source = undef,
      Variant[Array[String], String, Undef] $content = undef,
      String                                $type = 'hash',
      Stdlib::Absolutepath                  $path = "/etc/postfix/${name}",
    ) {
      include ::postfix::params
    
      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'
      }
    
      # CIDR and PCRE maps need a postfix reload, but not a postmap
      if $type =~ /^(cidr|pcre)$/ {
        $manage_notify = Service['postfix']
      } else {
        $manage_notify = Exec["generate ${name}.db"]
      }
    
      file { "postfix map ${name}":
        ensure  => $ensure,
        path    => $path,
        source  => $source,
        content => $content,
        owner   => 'root',
        group   => 'postfix',
        mode    => '0644',
        require => Package['postfix'],
        notify  => $manage_notify,
      }
    
      if $type !~ /^(cidr|pcre)$/ {
        file {"postfix map ${name}.db":
          ensure  => $ensure,
          path    => "${path}.db",
          owner   => 'root',
          group   => 'postfix',
          mode    => '0644',
          require => [File["postfix map ${name}"], Exec["generate ${name}.db"]],
        }
      }
    
      exec {"generate ${name}.db":
        command     => "postmap ${path}",
        path        => $::path,
        #creates    => "${name}.db", # this prevents postmap from being run !
        refreshonly => true,
      }
    }