summaryrefslogtreecommitdiff
path: root/manifests/smtp_auth.pp
blob: 882b01d4025f48f9d48b2102da7b6a16c37b9df0 (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
# == Definition: postfix::smtp_auth
#
# Manages content of the /etc/postfix/smtp_auth map.
#
# Requires:
#   - Class["postfix"]
#   - Postfix::Hash["/etc/postfix/smtp_auth"]
#   - file_line (from puppetlab's stdlib module)
#
# Example usage:
#
#  node 'toto.example.com' {
#
#    include postfix
#
#    postfix::hash { '/etc/postfix/smtp_auth':
#      ensure => present,
#    }
#    postfix::config { 'smpt_auth_maps':
#      value => 'hash:/etc/postfix/smtp_auth'
#    }
#    postfix::smtp_auth { 'gmail.com':
#      ensure   => present,
#      user     => 'USER',
#      password => 'PW',
#    }
#  }

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