|
| 1 | +# Copyright 2019 dhtech |
| 2 | +# |
| 3 | +# Use of this source code is governed by a BSD-style |
| 4 | +# license that can be found in the LICENSE file |
| 5 | +# |
| 6 | +# == Class: mailmx |
| 7 | +# |
| 8 | +# This module manages the rancid server which fetches and saves configuration |
| 9 | +# in the core and dist service. |
| 10 | +# |
| 11 | +# === Parameters |
| 12 | +# |
| 13 | +# [*postfix_networks*] |
| 14 | +# Decides how postfix will be used. |
| 15 | +# [*postfix_destinations*] |
| 16 | +# Decides how postfix will be used. |
| 17 | +# |
| 18 | + |
| 19 | +class mailmx($ldap_uri, $postfix_networks, $postfix_destinations) { |
| 20 | + |
| 21 | + # |
| 22 | + # Postfix |
| 23 | + # |
| 24 | + package { ['postfix', 'postfix-ldap', 'postfix-sqlite']: |
| 25 | + ensure => installed, |
| 26 | + } |
| 27 | + |
| 28 | + file { '/etc/postfix/main.cf': |
| 29 | + ensure => file, |
| 30 | + content => template('mailmx/postfix/main.cf.erb'), |
| 31 | + notify => Service['postfix'], |
| 32 | + require => Package['postfix'], |
| 33 | + } |
| 34 | + |
| 35 | + file { '/etc/postfix/dynamicmaps.cf': |
| 36 | + ensure => file, |
| 37 | + content => template('mailmx/postfix/dynamicmaps.cf.erb'), |
| 38 | + } |
| 39 | + |
| 40 | + file { '/etc/postfix/ldap-lists-stage1.cf': |
| 41 | + ensure => file, |
| 42 | + content => template('mailmx/postfix/ldap-lists-stage1.cf.erb'), |
| 43 | + } |
| 44 | + |
| 45 | + file { '/etc/postfix/ldap-lists-stage2.cf': |
| 46 | + ensure => file, |
| 47 | + content => template('mailmx/postfix/ldap-lists-stage2.cf.erb'), |
| 48 | + } |
| 49 | + |
| 50 | + file { '/etc/postfix/ldap-people.cf': |
| 51 | + ensure => file, |
| 52 | + content => template('mailmx/postfix/ldap-people.cf.erb'), |
| 53 | + } |
| 54 | + |
| 55 | + file { '/etc/postfix/pfix-no-srs.cf': |
| 56 | + ensure => file, |
| 57 | + content => template('mailmx/postfix/pfix-no-srs.cf.erb'), |
| 58 | + notify => Exec['postmap-pfix-no-srs'], |
| 59 | + } |
| 60 | + |
| 61 | + exec { 'postmap-pfix-no-srs': |
| 62 | + refreshonly => true, |
| 63 | + command => '/usr/sbin/postmap /etc/postfix/pfix-no-srs.cf', |
| 64 | + } |
| 65 | + |
| 66 | + file { '/etc/postfix/transport': |
| 67 | + ensure => file, |
| 68 | + content => template('mailmx/postfix/transport.erb'), |
| 69 | + notify => Exec['postmap-transport'], |
| 70 | + } |
| 71 | + |
| 72 | + exec { 'postmap-transport': |
| 73 | + refreshonly => true, |
| 74 | + command => '/usr/sbin/postmap /etc/postfix/transport', |
| 75 | + } |
| 76 | + |
| 77 | + service { 'postfix': |
| 78 | + ensure => 'running', |
| 79 | + name => 'postfix', |
| 80 | + enable => true, |
| 81 | + require => Package['postfix'], |
| 82 | + } |
| 83 | + |
| 84 | + # |
| 85 | + # Dovecot |
| 86 | + # |
| 87 | + package { ['dovecot-core', 'dovecot-imapd']: |
| 88 | + ensure => installed, |
| 89 | + } |
| 90 | + |
| 91 | + file { '/etc/dovecot/dovecot.conf': |
| 92 | + ensure => file, |
| 93 | + content => template('mailmx/dovecot/dovecot.conf.erb'), |
| 94 | + notify => Service['dovecot'], |
| 95 | + } |
| 96 | + |
| 97 | + file { '/etc/pam.d/dovecot': |
| 98 | + ensure => file, |
| 99 | + content => template('mailmx/dovecot/dovecot.pam.erb'), |
| 100 | + } |
| 101 | + |
| 102 | + service { 'dovecot': |
| 103 | + ensure => 'running', |
| 104 | + name => 'dovecot', |
| 105 | + enable => true, |
| 106 | + require => Package['dovecot-core'], |
| 107 | + } |
| 108 | + |
| 109 | +} |
0 commit comments