aboutsummaryrefslogtreecommitdiff
path: root/manifests/classes
diff options
context:
space:
mode:
authorMarc Fournier <marc.fournier@camptocamp.com>2008-12-03 17:53:28 +0100
committerMarc Fournier <marc.fournier@camptocamp.com>2008-12-03 17:53:28 +0100
commit28df18c79fb71407af663ee9b3c214094e1551f1 (patch)
treeca379d7992fe56a3ca79f116c05c0558f858217b /manifests/classes
downloadpuppet-postfix-28df18c79fb71407af663ee9b3c214094e1551f1.tar.gz
puppet-postfix-28df18c79fb71407af663ee9b3c214094e1551f1.tar.bz2
Initial import from bzr into github.
Diffstat (limited to 'manifests/classes')
-rw-r--r--manifests/classes/postfix-mailman.pp20
-rw-r--r--manifests/classes/postfix-mta.pp56
-rw-r--r--manifests/classes/postfix-satellite.pp35
-rw-r--r--manifests/classes/postfix.pp91
4 files changed, 202 insertions, 0 deletions
diff --git a/manifests/classes/postfix-mailman.pp b/manifests/classes/postfix-mailman.pp
new file mode 100644
index 0000000..6a34f45
--- /dev/null
+++ b/manifests/classes/postfix-mailman.pp
@@ -0,0 +1,20 @@
+class postfix-ng::mailman {
+ $postfix_ng_smtp_listen = "0.0.0.0"
+ include postfix-ng
+
+ postfix-ng::config {
+ "mydestination": value => "";
+ "virtual_alias_maps": value => "hash:/etc/postfix/virtual";
+ "transport_maps": value => "hash:/etc/postfix/transport";
+ "mailman_destination_recipient_limit": value => "1", nonstandard => true;
+ }
+
+ postfix-ng::hash { "/etc/postfix/virtual":
+ ensure => present,
+ }
+
+ postfix-ng::hash { "/etc/postfix/transport":
+ ensure => present,
+ }
+
+}
diff --git a/manifests/classes/postfix-mta.pp b/manifests/classes/postfix-mta.pp
new file mode 100644
index 0000000..94f9f78
--- /dev/null
+++ b/manifests/classes/postfix-mta.pp
@@ -0,0 +1,56 @@
+#########################################################################
+#
+# This class configures a minimal MTA, listening on
+# $postfix_ng_smtp_listen (default to localhost) and delivering mail to
+# $postfix_mydestination (default to $fqdn).
+#
+# A valid relay host is required ($postfix_relayhost) for outbound email.
+#
+# transport & virtual maps get configured and can be populated with
+# postfix-ng::transport and postfix-ng::virtual
+#
+# Example:
+#
+# node "toto.example.com" {
+# $postfix_relayhost = "mail.example.com"
+# $postfix_ng_smtp_listen = "0.0.0.0"
+# $postfix_mydestination = "\$myorigin, myapp.example.com"
+#
+# include postfix-ng::mta
+#
+# postfix-ng::transport { "myapp.example.com":
+# ensure => present,
+# destination => "local:",
+# }
+# }
+#
+
+class postfix-ng::mta {
+
+ case $postfix_relayhost {
+ "": { fail("Required \$postfix_relayhost variable is not defined.") }
+ }
+
+ case $postfix_mydestination {
+ "": { $postfix_mydestination = "\$myorigin" }
+ }
+
+ include postfix-ng
+
+ postfix-ng::config {
+ "mydestination": value => $postfix_mydestination;
+ "mynetworks": value => "127.0.0.0/8";
+ "relayhost": value => $postfix_relayhost;
+ "virtual_alias_maps": value => "hash:/etc/postfix/virtual";
+ "transport_maps": value => "hash:/etc/postfix/transport";
+ }
+
+ postfix-ng::hash { "/etc/postfix/virtual":
+ ensure => present,
+ }
+
+ postfix-ng::hash { "/etc/postfix/transport":
+ ensure => present,
+ }
+
+}
diff --git a/manifests/classes/postfix-satellite.pp b/manifests/classes/postfix-satellite.pp
new file mode 100644
index 0000000..0f8cd5f
--- /dev/null
+++ b/manifests/classes/postfix-satellite.pp
@@ -0,0 +1,35 @@
+#########################################################################
+#
+# This class configures all local email (cron, mdadm, etc) to be forwarded
+# to $root_mail_recipient, using $postfix_relayhost as a relay.
+#
+# $valid_fqdn can be set to override $fqdn in the case where the FQDN is
+# not recognized as valid by the destination server.
+#
+# All other parameters for postfix-ng::mta are valid.
+#
+# Example:
+#
+# node "toto.local.lan" {
+# $postfix_relayhost = "mail.example.com"
+# $valid_fqdn = "toto.example.com"
+# $root_mail_recipient = "the.sysadmin@example.com"
+#
+# include postfix-ng::satellite
+# }
+
+class postfix-ng::satellite {
+
+ # If $fake_fqdn exists, use it to override $fqdn
+ case $valid_fqdn {
+ "": { $valid_fqdn = $fqdn }
+ default: { $fqdn = "${valid_fqdn}" }
+ }
+
+ include postfix-ng::mta
+
+ postfix-ng::virtual {"@${valid_fqdn}":
+ ensure => present,
+ destination => "root",
+ }
+}
diff --git a/manifests/classes/postfix.pp b/manifests/classes/postfix.pp
new file mode 100644
index 0000000..f943a4e
--- /dev/null
+++ b/manifests/classes/postfix.pp
@@ -0,0 +1,91 @@
+#########################################################################
+#
+# This class provides a basic setup of postfix with local and remote
+# delivery and an SMTP server listening on the loopback interface.
+#
+
+class postfix-ng {
+
+ # Default value for various options
+ case $postfix_ng_smtp_listen {
+ "": { $postfix_ng_smtp_listen = "127.0.0.1" }
+ }
+ case $root_mail_recipient {
+ "": { $root_mail_recipient = "nobody" }
+ }
+
+
+ package { ["postfix", "mailx"]:
+ ensure => installed
+ }
+
+ service { "postfix":
+ ensure => running,
+ require => Package["postfix"],
+ }
+
+ file { "/etc/mailname":
+ ensure => present,
+ content => "${fqdn}\n",
+ }
+
+ # Aliases
+
+ file { "/etc/aliases":
+ ensure => present,
+ content => "# file managed by puppet\n",
+ replace => false,
+ notify => Exec["newaliases"],
+ }
+
+ exec { "newaliases":
+ command => "/usr/bin/newaliases",
+ refreshonly => true,
+ require => Package["postfix"],
+ subscribe => File["/etc/aliases"],
+ }
+
+ # Config files
+
+ file { "/etc/postfix/master.cf":
+ ensure => present,
+ content => $lsbdistcodename ? {
+ Tikanga => template("postfix-ng/master.cf.redhat5.erb"),
+ etch => template("postfix-ng/master.cf.debian-etch.erb"),
+ default => "No puppet template defined for $lsbdistcodename\n",
+ },
+ notify => Service["postfix"],
+ require => Package["postfix"],
+ }
+
+ file { "/etc/postfix/main.cf":
+ ensure => present,
+ source => "puppet:///postfix-ng/main.cf",
+ replace => false,
+ notify => Service["postfix"],
+ require => Package["postfix"],
+ }
+
+ # Default configuration parameters
+
+ postfix-ng::config {
+ "myorigin": value => "${fqdn}";
+ "alias_maps": value => "hash:/etc/aliases";
+ "inet_interfaces": value => "all";
+ }
+
+ case $operatingsystem {
+ RedHat: {
+ postfix-ng::config {
+ "sendmail_path": value => "/usr/sbin/sendmail.postfix";
+ "newaliases_path": value => "/usr/bin/newaliases.postfix";
+ "mailq_path": value => "/usr/bin/mailq.postfix";
+ }
+ }
+ }
+
+ mailalias {"root":
+ recipient => $root_mail_recipient,
+ notify => Exec["newaliases"],
+ }
+}