aboutsummaryrefslogtreecommitdiff
path: root/manifests/transport_regexp.pp
blob: 924ae8a77919bc53df4538305d2b268ea5f15e3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#
# == Class: postfix::transport_regexp
#
# Manages Postfix transport_regexp by merging snippets shipped:
# - in the module's files/transport_regexp.d/ or puppet:///files/etc/postfix/transport_regexp.d
#   (the latter takes precedence if present); site-postfix module is supported
#   as well, see the source argument of file {"$postfix_transport_regexp_snippets_dir"
#   bellow for details.
# - via postfix::transport_regexp_snippet defines
#
# Example usage:
# 
#   node "toto.example.com" {
#     $postfix_manage_transport_regexp = yes
#     include postfix
#     postfix::config { "transport_maps":
#       value => "hash:/etc/postfix/transport, regexp:/etc/postfix/transport_regexp",
#     }
#   }
#
class postfix::transport_regexp {

  include common::moduledir
  module_dir{'postfix/transport_regexp': }

  $postfix_transport_regexp_dir          = "${common::moduledir::module_dir_path}/postfix/transport_regexp"
  $postfix_transport_regexp_snippets_dir = "${postfix_transport_regexp_dir}/transport_regexp.d"
  $postfix_merged_transport_regexp       = "${postfix_transport_regexp_dir}/merged_transport_regexp"

  file {"$postfix_transport_regexp_snippets_dir":
    ensure  => 'directory',
    owner   => 'root',
    group   => '0',
    mode    => '700',
    source  => [
                "puppet:///modules/site-postfix/${fqdn}/transport_regexp.d",
                "puppet:///modules/site-postfix/transport_regexp.d",
                "puppet:///files/etc/postfix/transport_regexp.d",
                "puppet:///modules/postfix/transport_regexp.d",
               ],
    recurse => true,
    purge   => false,
  }

  concatenated_file { "$postfix_merged_transport_regexp":
    dir     => "${postfix_transport_regexp_snippets_dir}",
    require => File["$postfix_transport_regexp_snippets_dir"],
  }
  
  config_file { '/etc/postfix/transport_regexp':
    source    => "$postfix_merged_transport_regexp",
    subscribe => File["$postfix_merged_transport_regexp"],
  }

}