summaryrefslogtreecommitdiff
path: root/manifests/sieve.pp
blob: f05202030e86d9b2e1de2239fcf15dc7e537eaad (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
68
69
70
71
72
73
74
75
76
77
class dovecot::sieve {

  include ::dovecot

  package { 'dovecot-sieve':
    ensure => installed,
    before => Service['dovecot'],
  }

  $sieve_location = $operatingsystem ? {
    debian => '/var/lib/dovecot/sieve',
    default => '/var/lib/dovecot-sieve'
  }

  file {
    $sieve_location:
      ensure => directory,
      owner => root, group => 0, mode => 0644;
 
    "${sieve_location}/global":
      ensure => directory,
      recurse => true,
      purge => true,
      force => true,
      notify => Exec['compile_global_sieve'],
      owner => root, group => root, mode => 0644;

    "${sieve_location}/default.sieve":
      source => [ "puppet:///modules/site-dovecot/sieve/${fqdn}/default.sieve",
                  "puppet:///modules/site-dovecot/sieve/default.sieve",
                  "puppet:///modules/dovecot/sieve/${operatingsystem}/default.sieve",
                  "puppet:///modules/dovecot/sieve/default.sieve" ],
      notify => Exec['compile_default_sieve'],
      owner => root, group => root, mode => 0644;

    # this is for sequential sieve scripts, configured in 90-sieve.conf as:
    #  sieve_before = /var/lib/dovecot/sieve/default.sieve
    "${sieve_location}/before.sieve":
      source => [ "puppet:///modules/site-dovecot/sieve/${fqdn}/before.sieve",
                  "puppet:///modules/site-dovecot/sieve/before.sieve",
                  "puppet:///modules/dovecot/sieve/${operatingsystem}/before.sieve",
                  "puppet:///modules/dovecot/sieve/before.sieve" ],
      notify => Exec['compile_before_sieve'],
      owner => root, group => root, mode => 0644;

    # this is for sequential sieve scripts, configured in 90-sieve.conf as:
    #  sieve_after = /var/lib/dovecot/sieve/after.sieve
    "${sieve_location}/after.sieve":
      source => [ "puppet:///modules/site-dovecot/sieve/${fqdn}/after.sieve",
                  "puppet:///modules/site-dovecot/sieve/after.sieve",
                  "puppet:///modules/dovecot/sieve/${operatingsystem}/after.sieve",
                  "puppet:///modules/dovecot/sieve/after.sieve" ],
      notify => Exec['compile_after_sieve'],
      owner => root, group => root, mode => 0644;
  }

  exec {
    'compile_default_sieve':
      command => "sievec ${sieve_location}/default.sieve",
      creates => "${sieve_location}/default.svbin",
      require => File["${sieve_location}/default.sieve"];

    'compile_before_sieve':
      command => "sievec ${sieve_location}/before.sieve",
      creates => "${sieve_location}/before.svbin",
      require => File["${sieve_location}/before.sieve"];
    
    'compile_after_sieve':
      command => "sievec ${sieve_location}/after.sieve",
      creates => "${sieve_location}/after.svbin",
      require => File["${sieve_location}/after.sieve"];

    'compile_global_sieve':
      command => "sievec ${sieve_location}/global/",
      refreshonly => true;
  }
}