aboutsummaryrefslogtreecommitdiff
path: root/manifests/classes/postfix-header_checks.pp
blob: 071f6b0a93e61fd63be7f381bd0324127e63fd1d (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
56
57
#
# == Class: postfix::header_checks
#
# Manages Postfix header_checks by merging snippets shipped:
# - in the module's files/header_checks.d/ or puppet:///files/etc/postfix/header_checks.d
#   (the latter takes precedence if present); site-postfix module is supported
#   as well, see the source argument of file {"$postfix_header_checks_snippets_dir"
#   bellow for details.
# - via postfix::header_checks_snippet defines
#
# Example usage:
# 
#   node "toto.example.com" {
#     $postfix_manage_header_checks = yes
#     include postfix
#   }
#
class postfix::header_checks {

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

  $postfix_header_checks_dir          = "${common::moduledir::module_dir_path}/postfix/header_checks"
  $postfix_header_checks_snippets_dir = "${postfix_header_checks_dir}/header_checks.d"
  $postfix_merged_header_checks       = "${postfix_header_checks_dir}/merged_header_checks"

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

  concatenated_file { "$postfix_merged_header_checks":
    dir     => "${postfix_header_checks_snippets_dir}",
    require => File["$postfix_header_checks_snippets_dir"],
  }
  
  config_file { '/etc/postfix/header_checks':
    source    => "$postfix_merged_header_checks",
    subscribe => File["$postfix_merged_header_checks"],
  }

  postfix::config { "header_checks":
    value   => 'regexp:/etc/postfix/header_checks',
    require => File['/etc/postfix/header_checks'],
  }

}