Puppet Class: directadmin::mail

Defined in:
manifests/mail.pp

Overview

directadmin::mail



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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'manifests/mail.pp', line 2

class directadmin::mail {

  # File change: set up our e-mail limit
  file { '/etc/virtual/limit':
    ensure  => present,
    owner   => mail,
    group   => mail,
    mode    => '0644',

    # maximum e-mails per day, it needs quotes to ensure it gets
    # read correctly, Hiera will set it as an integer for example
    content => sprintf('%s', $::directadmin::mail_limit),

    # restart on change
    notify  => Service['exim'],
    require => Exec['directadmin-installer'],
  }
  # File change: /etc/virtual/limit_unknown
  -> file { '/etc/virtual/limit_unknown':
    ensure  => present,
    owner   => mail,
    group   => mail,
    mode    => '0644',
    content => sprintf('%s', '0'),
    notify  => Service['exim'],
    require => Exec['directadmin-installer'],
  }
  # File change: /etc/virtual/user_limit
  -> file { '/etc/virtual/user_limit':
    ensure  => present,
    owner   => mail,
    group   => mail,

    # this file is set to 755 by directadmin by default
    mode    => '0755',

    # maximum e-mails per day, per e-mail address.
    # it needs quotes to ensure it gets read correctly, Hiera will
    # set it as an integer for example
    content => sprintf('%s', $::directadmin::mail_limit_per_address),
    notify  => Service['exim'],
    require => Exec['directadmin-installer'],
  }

  # File: set the default webmail client
  file { '/var/www/html/webmail':
    ensure  => link,
    target  => "/var/www/html/${::directadmin::default_webmail}",
    require => Exec['directadmin-installer'],
  }
  # File_line: set the default /webmail alias
  file_line { 'httpd-alias-default-webmail':
    ensure  => present,
    path    => '/etc/httpd/conf/extra/httpd-alias.conf',
    line    => "Alias /webmail /var/www/html/${::directadmin::default_webmail}",
    match   => 'Alias \/webmail',
    notify  => Service['httpd'],
    require => Exec['directadmin-installer'],
  }
  directadmin::config::set { 'webmail_link': value => $::directadmin::default_webmail, }

  # Install support for imap in php if required
  if $::directadmin::php_imap == true {
    # Make sure libc-client2007e-dev is installed on Debian and Ubuntu
    if $::operatingsystem =~ /^(Debian|Ubuntu)$/ {
      if versioncmp($::operatingsystemmajrelease, '7') >= 0 {
        if versioncmp($::puppetversion, '3.6.0') >= 0 {
            # There is a really weird bug in puppet-lint that errors out when
            # a space is added between Package and {.
            Package{
                allow_virtual => true,
            }
        }

        package { 'libc-client2007e-dev':
          ensure => installed,
          before => Exec['directadmin-download-php-imap'],
        }
      }
    }
    exec { 'directadmin-download-php-imap':
      cwd     => '/root',
      command => 'wget -O /root/imap_php.sh files.directadmin.com/services/all/imap_php.sh && chmod +x /root/imap_php.sh',
      creates => '/root/imap_php.sh',
      require => Exec['directadmin-installer'],
      path    => '/bin:/usr/bin',
    }
    exec { 'directadmin-install-php-imap':
      cwd     => '/root',
      command => '/root/imap_php.sh',
      unless  => 'php -i | grep -i c-client | wc -l | grep -c 1',
      require => [ Exec['directadmin-installer'], Exec['directadmin-download-php-imap'] ],
      timeout => 0,
      path    => '/bin:/usr/bin',
      notify  => Service['httpd'],
    }
  }

  # File_line: make sure the primary hostname is set in exim.conf
  # as we have seen some issues with CentOS 7 here.
  file_line { 'exim-set-primary-hostname':
    path    => '/etc/exim.conf',
    line    => "primary_hostname = ${::fqdn}",
    match   => '^(# )?primary_hostname =',
    notify  => Service['exim'],
    require => Exec['directadmin-installer'],
  }

  # SpamAssassin cron jobs
  if $::directadmin::sa_updates == true {
    $sa_cron = 'present'
  } else {
    $sa_cron = 'absent'
  }

  # Cron: daily update of SpamAssassin rules
  cron { 'exim-sa-update':
    ensure  => $sa_cron,
    command => '/usr/bin/sa-update && /sbin/service exim restart >/dev/null 2>&1',
    user    => root,
    hour    => 7,
    minute  => 5,
    require => Exec['directadmin-installer'],
  }

  # Set up RBL checks by default
  if $::directadmin::default_rbl == true {
    file { '/etc/virtual/use_rbl_domains':
      ensure  => 'link',
      target  => '/etc/virtual/domains',
      require => Exec['directadmin-installer'],
    }
  }
}