]> gitweb.fluxo.info Git - puppet-mail.git/commitdiff
Major refactor to enhance per-subsystem config isolation
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 26 Aug 2010 14:31:22 +0000 (11:31 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 26 Aug 2010 14:31:22 +0000 (11:31 -0300)
12 files changed:
manifests/base.pp
manifests/packages.pp
manifests/postfixadmin.pp
manifests/regexps.pp [new file with mode: 0644]
manifests/regular.pp [new file with mode: 0644]
manifests/schleuder.pp
manifests/sympa.pp
manifests/system.pp
manifests/virtual.pp [new file with mode: 0644]
manifests/web.pp
templates/postfix/sympa/transport_regexp.erb [moved from templates/postfix/transport_regexp.erb with 100% similarity]
templates/postfix/sympa/virtual_regexp.erb [moved from templates/postfix/virtual_regexp.erb with 100% similarity]

index f3b68e4ccca3ef1418cc091773ca0a31da1efd68..a8bd59a9d7c0e620e3e1659a5961120f817ddb8b 100644 (file)
@@ -11,65 +11,18 @@ class mail::base {
     "virtual_mailbox_base":                value => '/var/mail/virtual';
     "virtual_uid_maps":                    value => 'static:5000';
     "virtual_gid_maps":                    value => 'static:5000';
-    "virtual_transport":                   value => 'dovecot';
-    "dovecot_destination_recipient_limit": value => '1';
     "recipient_delimiter":                 value => '+';
   }
 
-  postfix::hash { "/etc/postfix/virtual":
-    ensure => present,
-  }
-
-  postfix::hash { "/etc/postfix/transport":
-    ensure => present,
-  }
-
   # Recipient restrictions
   postfix::config { "smtpd_recipient_restrictions":
     value => 'permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_rbl_client psbl.surriel.com, check_policy_service inet:127.0.0.1:60000' }
 
-  # Virtual mailboxes
-  file { '/var/mail/virtual':
-    ensure  => directory,
-    owner   => vmail,
-    group   => vmail,
-    mode    => 0750,
-    require => User['vmail'],
-  }
-
-  group { "vmail":
+  postfix::hash { "/etc/postfix/virtual":
     ensure => present,
-    gid    => 5000,
   }
 
-  user { "vmail":
-    ensure   => present,
-    uid      => 5000,
-    gid      => "vmail",
-    password => "*",
-    home     => '/var/mail/virtual',
-    require  => Group['vmail'],
-  }
-
-  # Sympa mailing list manager
-  case $mail_sympa {
-    true: { }
-    default: {
-      file { "/etc/postfix/transport_regexp":
-        ensure  => present,
-        owner   => root,
-        group   => root,
-        mode    => 0644,
-        notify  => Service['postfix'],
-      }
-    
-      file { "/etc/postfix/virtual_regexp":
-        ensure  => present,
-        owner   => root,
-        group   => root,
-        mode    => 0644,
-        notify  => Service['postfix'],
-      }
-    }
+  postfix::hash { "/etc/postfix/transport":
+    ensure => present,
   }
 }
index ec520092156c33bbccef3cfe396c3ca9796d6c37..0cc4a71ff3170bbd3b3a9dad086565beee9dfe27 100644 (file)
@@ -1,14 +1,20 @@
 class mail::packages {
   # The needed packages
-  package { [ 'postfix-mysql', 'dovecot-imapd', 'maildrop' ]:
+  package { [ 'postgrey', 'amavisd-new', 'spamassassin', 'spamc' ]:
     ensure => installed,
   }
 
-  package { [ 'postgrey', 'amavisd-new', 'spamassassin', 'spamc', 'libpam-mysql', 'libgsasl7' ]:
+  package { [ 'clamav-base', 'clamav-daemon', 'clamav-freshclam' ]:
     ensure => installed,
   }
+}
 
-  package { [ 'clamav-base', 'clamav-daemon', 'clamav-freshclam' ]:
+class mail::packages::virtual {
+  package { [ 'libpam-mysql', 'libgsasl7' ]:
+    ensure => installed,
+  }
+
+  package { [ 'postfix-mysql', 'dovecot-imapd', 'maildrop' ]:
     ensure => installed,
   }
 
index be3e312d9c0039b3f3e31eb94171e9ed50832589..e00d8ce33b3980ad9a427f58c5dcb25fcc0de3cc 100644 (file)
@@ -1,4 +1,28 @@
 class mail::postfixadmin {
+  # Class configuration
+  case $postfixadmin_database_password {
+    '': { fail("You need to define \$postfixadmin_database_password host config") }
+  }
+
+  case $postfixadmin_setup_hash {
+    '': {
+      warning("You need to define \$postfixadmin_setup_hash host config")
+      $postfixadmin_setup_hash = 'changeme'
+    }
+  }
+
+  case $postfixadmin_database_user {
+    '': { $postfixadmin_database_user = "postfix" }
+  }
+
+  case $postfixadmin_database_host {
+    '': { $postfixadmin_database_host = "localhost" }
+  }
+
+  case $postfixadmin_database_name {
+    '': { $postfixadmin_database_name= "postfix" }
+  }
+
   #
   # Database configuration
   #
@@ -9,6 +33,11 @@ class mail::postfixadmin {
   #
   # Postfix configuration
   #
+  postfix::config {
+    "virtual_transport": value => 'dovecot';
+    "dovecot_destination_recipient_limit": value => '1';
+  }
+
   postfix::config { "virtual_mailbox_domains":
     value   => 'proxy:mysql:/etc/postfix/sql/mysql_virtual_domains_maps.cf',
     require => File['/etc/postfix/sql/mysql_virtual_domains_maps.cf'],
diff --git a/manifests/regexps.pp b/manifests/regexps.pp
new file mode 100644 (file)
index 0000000..d05ad68
--- /dev/null
@@ -0,0 +1,17 @@
+class mail::regexps {
+  file { "/etc/postfix/transport_regexp":
+    ensure  => present,
+    owner   => root,
+    group   => root,
+    mode    => 0644,
+    notify  => Service['postfix'],
+  }
+
+  file { "/etc/postfix/virtual_regexp":
+    ensure  => present,
+    owner   => root,
+    group   => root,
+    mode    => 0644,
+    notify  => Service['postfix'],
+  }
+}
diff --git a/manifests/regular.pp b/manifests/regular.pp
new file mode 100644 (file)
index 0000000..da35e33
--- /dev/null
@@ -0,0 +1,5 @@
+class mail::regular {
+  postfix::config { "virtual_alias_maps":
+    value => 'hash://postfix/virtual, regexp:/etc/postfix/virtual_regexp',
+  }
+}
index ec31e116644122e6036cfb181d3a45dac466a5e0..ae51c9cddd6186c40a0543498d4b47296cd52d72 100644 (file)
@@ -1,4 +1,7 @@
 class mail::schleuder {
+  # Schleuder subsystems
+  include mail::packages::schleuder
+
   postfix::config { "schleuder_destination_recipient_limit": value => '1' }
 
   postfix::transport { "encrypted.$domain":
index 78ec9e4f49113902ffb7ced036f3b9fc451e3267..18e8c9ae83e0137bf39ed6d7f9de2fa2346881c4 100644 (file)
@@ -1,4 +1,33 @@
-class mail::sympa {
+class mail::sympa inherits mail::regexps {
+  # Sympa subsystems
+  include mail::web::sympa
+  include mail::packages::sympa
+
+  # Class configuration
+  case $sympa_database_password {
+    '': { fail("You need to define \$sympa_database_password host config") }
+  }
+
+  case $sympa_database_name {
+    '': { $sympa_database_name= "sympa" }
+  }
+
+  case $sympa_database_host {
+    '': { $sympa_database_host = "localhost" }
+  }
+
+  case $sympa_subdomain {
+    '': { $sympa_subdomain = "lists" }
+  }
+
+  case $sympa_listmasters {
+    '': { $sympa_listmasters = "listmaster@${fqdn}" }
+  }
+
+  case $sympa_lang {
+    '': { $sympa_lang = "en_US" }
+  }
+
   #
   # Database configuration
   #
@@ -30,24 +59,15 @@ class mail::sympa {
     mode    => 0640,
     content => template('mail/sympa/sympa.conf.erb'),
     require => [ File['/etc/sympa'], User['sympa'] ],
+    notify  => Service['apache'],
   }
 
-  file { "/etc/postfix/transport_regexp":
-    ensure  => present,
-    owner   => root,
-    group   => root,
-    mode    => 0644,
-    content => template('mail/postfix/transport_regexp.erb'),
-    notify  => Service['postfix'],
+  File["/etc/postfix/transport_regexp"] {
+    content => template('mail/postfix/sympa/transport_regexp.erb'),
   }
 
-  file { "/etc/postfix/virtual_regexp":
-    ensure  => present,
-    owner   => root,
-    group   => root,
-    mode    => 0644,
-    content => template('mail/postfix/virtual_regexp.erb'),
-    notify  => Service['postfix'],
+  File["/etc/postfix/virtual_regexp"] {
+    content => template('mail/postfix/sympa/virtual_regexp.erb'),
   }
 
   postfix::config {
index 53ec12ff6fb540697aa6b9128892efd3d80e1239..e48f52e12bc014a70b586639e2ff7d347b129a84 100644 (file)
@@ -10,84 +10,41 @@ class mail::system {
     '': { $postfix_mynetworks = "127.0.0.0/8" }
   }
 
-  case $postfixadmin_database_password {
-    '': { fail("You need to define \$postfixadmin_database_password host config") }
-  }
-
-  case $postfixadmin_setup_hash {
-    '': {
-      warning("You need to define \$postfixadmin_setup_hash host config")
-      $postfixadmin_setup_hash = 'changeme'
-    }
-  }
-
-  case $postfixadmin_database_user {
-    '': { $postfixadmin_database_user = "postfix" }
-  }
-
-  case $postfixadmin_database_host {
-    '': { $postfixadmin_database_host = "localhost" }
-  }
-
-  case $postfixadmin_database_name {
-    '': { $postfixadmin_database_name= "postfix" }
-  }
-
   # Module requirements
   include postfix
-  include database
   include ssl::mail
 
-  # Subsystems
+  # Common subsystems
   include mail::packages
   include mail::base
-  include mail::sasl
   include mail::tls
-  include mail::dovecot
   include mail::amavisd
   include mail::header_checks
-  include mail::postfixadmin
-  include mail::web
   include mail::clamav
 
+  # Virtual mail system
+  case $mail_virtual {
+    true: {
+      include mail::virtual
+    }
+    default: {
+      include mail::regular
+    }
+  }
+
   # Sympa mailing list manager
   case $mail_sympa {
     true: {
-
-      case $sympa_database_password {
-        '': { fail("You need to define \$sympa_database_password host config") }
-      }
-
-      case $sympa_database_name {
-        '': { $sympa_database_name= "sympa" }
-      }
-
-      case $sympa_database_host {
-        '': { $sympa_database_host = "localhost" }
-      }
-
-      case $sympa_subdomain {
-        '': { $sympa_subdomain = "lists" }
-      }
-
-      case $sympa_listmasters {
-        '': { $sympa_listmasters = "listmaster@${fqdn}" }
-      }
-
-      case $sympa_lang {
-        '': { $sympa_lang = "en_US" }
-      }
-
       include mail::sympa
-      include mail::web::sympa
-      include mail::packages::sympa
+    }
+    default: {
+      include mail::regexps
     }
   }
 
   # Schleuder mailing list manager
   case $mail_schleuder {
     true: {
-      include mail::packages::schleuder
       include mail::schleuder
     }
   }
diff --git a/manifests/virtual.pp b/manifests/virtual.pp
new file mode 100644 (file)
index 0000000..5035c77
--- /dev/null
@@ -0,0 +1,32 @@
+class mail::virtual {
+  # Virtual subsystems
+  include database
+  include mail::packages::virtual
+  include mail::sasl
+  include mail::dovecot
+  include mail::postfixadmin
+  include mail::web::virtual
+
+  # Virtual mailboxes
+  file { '/var/mail/virtual':
+    ensure  => directory,
+    owner   => vmail,
+    group   => vmail,
+    mode    => 0750,
+    require => User['vmail'],
+  }
+
+  group { "vmail":
+    ensure => present,
+    gid    => 5000,
+  }
+
+  user { "vmail":
+    ensure   => present,
+    uid      => 5000,
+    gid      => "vmail",
+    password => "*",
+    home     => '/var/mail/virtual',
+    require  => Group['vmail'],
+  }
+}
index 2bfd5c4dfb276cdc5374f7c1073eeac2b5e4d779..73db06c00a697937a5dca9b13a8599ea5cac6db0 100644 (file)
@@ -1,4 +1,4 @@
-class mail::web inherits websites::setup {
+class mail::web::virtual inherits websites::setup {
   include php::imap
 
   apache::site { "postfixadmin":