summaryrefslogtreecommitdiff
path: root/puppet/modules/opendkim/manifests/init.pp
blob: 4d4c5312efd4fffd9dd9b8de132aa381f06e0905 (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
58
59
60
61
62
63
64
65
66
67
#
# I am not sure about what issues might arise with DKIM key sizes
# larger than 2048. It might or might not be supported. See:
# http://dkim.org/specs/rfc4871-dkimbase.html#rfc.section.3.3.3
#
class opendkim {

  $domain_hash = hiera('domain')
  $domain      = $domain_hash['full_suffix']
  $mx          = hiera('mx')
  $dkim        = $mx['dkim']
  $selector    = $dkim['selector']
  $dkim_cert   = $dkim['public_key']
  $dkim_key    = $dkim['private_key']

  ensure_packages(['opendkim', 'libvbr2'])

  # postfix user needs to be in the opendkim group
  # in order to access the opendkim socket located at:
  # local:/var/run/opendkim/opendkim.sock
  user { 'postfix':
    groups  => 'opendkim',
    require => Package['opendkim'];
  }

  service { 'opendkim':
    ensure     => running,
    enable     => true,
    hasstatus  => true,
    hasrestart => true,
    subscribe  => File[$dkim_key];
  }

  file {
    '/etc/opendkim.conf':
      ensure  => file,
      content => template('opendkim/opendkim.conf'),
      mode    => '0644',
      owner   => root,
      group   => root,
      notify  => Service['opendkim'],
      require => Package['opendkim'];

    '/etc/default/opendkim.conf':
      ensure  => file,
      content => 'SOCKET="inet:8891@localhost" # listen on loopback on port 8891',
      mode    => '0644',
      owner   => root,
      group   => root,
      notify  => Service['opendkim'],
      require => Package['opendkim'];

    $dkim_key:
      ensure  => file,
      mode    => '0600',
      owner   => 'opendkim',
      group   => 'opendkim',
      require => Package['opendkim'];

    $dkim_cert:
      ensure  => file,
      mode    => '0600',
      owner   => 'opendkim',
      group   => 'opendkim',
      require => Package['opendkim'];
  }
}