aboutsummaryrefslogtreecommitdiff
path: root/manifests/virtual_regexp_snippet.pp
blob: 8e376b7f3aca3fae0b94ff1122f5546f76c0fdde (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
/*
== Definition: postfix::virtual_regexp_snippet

Adds a virtual_regexp snippets to /etc/postfix/virtual_regexp.
See the postfix::virtual_regexp class for details.

Parameters:
- *source* or *content*: source or content of the virtual_regexp snippet
- *ensure*: present (default) or absent

Requires:
- Class["postfix"]

Example usage:

  node "toto.example.com" {
    class { 'postfix': }
    postfix::virtual_regexp {
      'wrong_date': content => 'FIXME';
      'bla':        source => 'puppet:///files/etc/postfix/virtual_regexp.d/bla';
    }
  }

*/

define postfix::virtual_regexp_snippet (
  $ensure  = "present",
  $source  = '',
  $content = undef
) {

  if $source == '' and $content == undef {
    fail("One of \$source or \$content must be specified for postfix::virtual_regexp_snippet ${name}")
  }

  if $source != '' and $content != undef {
    fail("Only one of \$source or \$content must specified for postfix::virtual_regexp_snippet ${name}")
  }

  include postfix::virtual_regexp

  $fragment = "postfix_virtual_regexp_${name}"

  concat::fragment { "$fragment":
    ensure  => "$ensure",
    target  => '/etc/postfix/virtual_regexp',
    source  => $source ? {
      undef   => undef,
      default => $source,
    },
    content  => $content ? {
      undef   => undef,
      default => $content,
    },
  }
}