summaryrefslogtreecommitdiff
path: root/puppet/modules/postfix/manifests/virtual.pp
blob: 06df32addde355a6c2f66fbd65728b7934f0b357 (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
/*
== Definition: postfix::virtual

Manages content of the /etc/postfix/virtual map.

Parameters:
- *name*: name of address postfix will lookup. See virtual(8).
- *destination*: where the emails will be delivered to. See virtual(8).
- *ensure*: present/absent, defaults to present.

Requires:
- Class["postfix"]
- Postfix::Hash["/etc/postfix/virtual"]
- Postfix::Config["virtual_alias_maps"]
- file_line (from module stdlib)

Example usage:

  node "toto.example.com" {

    class { 'postfix': }

    postfix::hash { "/etc/postfix/virtual":
      ensure => present,
    }
    postfix::config { "virtual_alias_maps":
      value => "hash:/etc/postfix/virtual"
    }
    postfix::virtual { "user@example.com":
      ensure      => present,
      destination => "root",
    }
  }

*/
define postfix::virtual ($ensure="present", $destination) {
  file_line {"${name} ${destination}":
    ensure => $ensure,
    path   => "/etc/postfix/virtual",
    line   => "${name} ${destination}",
    notify => Exec["generate /etc/postfix/virtual.db"],
    require => Package["postfix"],
  }
}