summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
Diffstat (limited to 'manifests')
-rw-r--r--manifests/config.pp1
-rw-r--r--manifests/header_checks_snippet.pp21
-rw-r--r--manifests/init.pp6
-rw-r--r--manifests/transport_regexp.pp55
-rw-r--r--manifests/transport_regexp_snippet.pp67
-rw-r--r--manifests/virtual_regexp.pp55
-rw-r--r--manifests/virtual_regexp_snippet.pp67
7 files changed, 265 insertions, 7 deletions
diff --git a/manifests/config.pp b/manifests/config.pp
index 8e203a6..7b27053 100644
--- a/manifests/config.pp
+++ b/manifests/config.pp
@@ -37,6 +37,7 @@ define postfix::config ($ensure = present, $value, $nonstandard = false) {
false => "test \"x$(postconf -h ${name})\" = 'x${value}'",
true => "test \"x$(egrep '^${name} ' /etc/postfix/main.cf | cut -d= -f2 | cut -d' ' -f2)\" = 'x${value}'",
},
+ path => "/usr/bin:/usr/sbin/:/bin:/sbin",
notify => Service["postfix"],
require => File["/etc/postfix/main.cf"],
}
diff --git a/manifests/header_checks_snippet.pp b/manifests/header_checks_snippet.pp
index 91d7501..454d219 100644
--- a/manifests/header_checks_snippet.pp
+++ b/manifests/header_checks_snippet.pp
@@ -15,7 +15,7 @@ Example usage:
node "toto.example.com" {
include postfix
- postfix::header_checks_snippet {
+ postfix::header_checks {
'wrong_date': content => 'FIXME';
'bla': source => 'puppet:///files/etc/postfix/header_checks.d/bla';
}
@@ -37,22 +37,29 @@ define postfix::header_checks_snippet (
fail("Only one of \$source or \$content must specified for postfix::header_checks_snippet ${name}")
}
- include postfix::header_checks
+ if ($value == false) and ($ensure == "present") {
+ fail("The value parameter must be set when using the postfix::header_checks_snippet define with ensure=present.")
+ }
- $fragment = "postfix_header_checks_${name}"
+ include postfix::header_checks
- concat::fragment { "$fragment":
+ $snippetfile = "${postfix::header_checks::postfix_header_checks_snippets_dir}/${name}"
+
+ file { "$snippetfile":
ensure => "$ensure",
- target => '/etc/postfix/header_checks',
+ mode => 600,
+ owner => root,
+ group => 0,
+ notify => Exec["concat_${postfix::header_checks::postfix_merged_header_checks}"],
}
if $source {
- Concat::Fragment["$fragment"] {
+ File["$snippetfile"] {
source => $source,
}
}
else {
- Concat::Fragment["$fragment"] {
+ File["$snippetfile"] {
content => $content,
}
}
diff --git a/manifests/init.pp b/manifests/init.pp
index 6d16efc..5b04a0f 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -88,6 +88,12 @@ class postfix {
if $postfix_use_amavisd == 'yes' {
include postfix::amavis
}
+ if $postfix_manage_transport_regexp == 'yes' {
+ include postfix::transport_regexp
+ }
+ if $postfix_manage_virtual_regexp == 'yes' {
+ include postfix::virtual_regexp
+ }
package { ["postfix", "mailx"]:
ensure => installed
diff --git a/manifests/transport_regexp.pp b/manifests/transport_regexp.pp
new file mode 100644
index 0000000..924ae8a
--- /dev/null
+++ b/manifests/transport_regexp.pp
@@ -0,0 +1,55 @@
+#
+# == Class: postfix::transport_regexp
+#
+# Manages Postfix transport_regexp by merging snippets shipped:
+# - in the module's files/transport_regexp.d/ or puppet:///files/etc/postfix/transport_regexp.d
+# (the latter takes precedence if present); site-postfix module is supported
+# as well, see the source argument of file {"$postfix_transport_regexp_snippets_dir"
+# bellow for details.
+# - via postfix::transport_regexp_snippet defines
+#
+# Example usage:
+#
+# node "toto.example.com" {
+# $postfix_manage_transport_regexp = yes
+# include postfix
+# postfix::config { "transport_maps":
+# value => "hash:/etc/postfix/transport, regexp:/etc/postfix/transport_regexp",
+# }
+# }
+#
+class postfix::transport_regexp {
+
+ include common::moduledir
+ module_dir{'postfix/transport_regexp': }
+
+ $postfix_transport_regexp_dir = "${common::moduledir::module_dir_path}/postfix/transport_regexp"
+ $postfix_transport_regexp_snippets_dir = "${postfix_transport_regexp_dir}/transport_regexp.d"
+ $postfix_merged_transport_regexp = "${postfix_transport_regexp_dir}/merged_transport_regexp"
+
+ file {"$postfix_transport_regexp_snippets_dir":
+ ensure => 'directory',
+ owner => 'root',
+ group => '0',
+ mode => '700',
+ source => [
+ "puppet:///modules/site-postfix/${fqdn}/transport_regexp.d",
+ "puppet:///modules/site-postfix/transport_regexp.d",
+ "puppet:///files/etc/postfix/transport_regexp.d",
+ "puppet:///modules/postfix/transport_regexp.d",
+ ],
+ recurse => true,
+ purge => false,
+ }
+
+ concatenated_file { "$postfix_merged_transport_regexp":
+ dir => "${postfix_transport_regexp_snippets_dir}",
+ require => File["$postfix_transport_regexp_snippets_dir"],
+ }
+
+ config_file { '/etc/postfix/transport_regexp':
+ source => "$postfix_merged_transport_regexp",
+ subscribe => File["$postfix_merged_transport_regexp"],
+ }
+
+}
diff --git a/manifests/transport_regexp_snippet.pp b/manifests/transport_regexp_snippet.pp
new file mode 100644
index 0000000..eb43c37
--- /dev/null
+++ b/manifests/transport_regexp_snippet.pp
@@ -0,0 +1,67 @@
+/*
+== Definition: postfix::transport_regexp_snippet
+
+Adds a transport_regexp snippets to /etc/postfix/transport_regexp.
+See the postfix::transport_regexp class for details.
+
+Parameters:
+- *source* or *content*: source or content of the transport_regexp snippet
+- *ensure*: present (default) or absent
+
+Requires:
+- Class["postfix"]
+
+Example usage:
+
+ node "toto.example.com" {
+ include postfix
+ postfix::transport_regexp {
+ 'wrong_date': content => 'FIXME';
+ 'bla': source => 'puppet:///files/etc/postfix/transport_regexp.d/bla';
+ }
+ }
+
+*/
+
+define postfix::transport_regexp_snippet (
+ $ensure = "present",
+ $source = '',
+ $content = undef
+) {
+
+ if $source == '' and $content == undef {
+ fail("One of \$source or \$content must be specified for postfix::transport_regexp_snippet ${name}")
+ }
+
+ if $source != '' and $content != undef {
+ fail("Only one of \$source or \$content must specified for postfix::transport_regexp_snippet ${name}")
+ }
+
+ if ($value == false) and ($ensure == "present") {
+ fail("The value parameter must be set when using the postfix::transport_regexp_snippet define with ensure=present.")
+ }
+
+ include postfix::transport_regexp
+
+ $snippetfile = "${postfix::transport_regexp::postfix_transport_regexp_snippets_dir}/${name}"
+
+ file { "$snippetfile":
+ ensure => "$ensure",
+ mode => 600,
+ owner => root,
+ group => 0,
+ notify => Exec["concat_${postfix::transport_regexp::postfix_merged_transport_regexp}"],
+ }
+
+ if $source {
+ File["$snippetfile"] {
+ source => $source,
+ }
+ }
+ else {
+ File["$snippetfile"] {
+ content => $content,
+ }
+ }
+
+}
diff --git a/manifests/virtual_regexp.pp b/manifests/virtual_regexp.pp
new file mode 100644
index 0000000..db41354
--- /dev/null
+++ b/manifests/virtual_regexp.pp
@@ -0,0 +1,55 @@
+#
+# == Class: postfix::virtual_regexp
+#
+# Manages Postfix virtual_regexp by merging snippets shipped:
+# - in the module's files/virtual_regexp.d/ or puppet:///files/etc/postfix/virtual_regexp.d
+# (the latter takes precedence if present); site-postfix module is supported
+# as well, see the source argument of file {"$postfix_virtual_regexp_snippets_dir"
+# bellow for details.
+# - via postfix::virtual_regexp_snippet defines
+#
+# Example usage:
+#
+# node "toto.example.com" {
+# $postfix_manage_virtual_regexp = yes
+# include postfix
+# postfix::config { "virtual_alias_maps":
+# value => 'hash://postfix/virtual, regexp:/etc/postfix/virtual_regexp',
+# }
+# }
+#
+class postfix::virtual_regexp {
+
+ include common::moduledir
+ module_dir{'postfix/virtual_regexp': }
+
+ $postfix_virtual_regexp_dir = "${common::moduledir::module_dir_path}/postfix/virtual_regexp"
+ $postfix_virtual_regexp_snippets_dir = "${postfix_virtual_regexp_dir}/virtual_regexp.d"
+ $postfix_merged_virtual_regexp = "${postfix_virtual_regexp_dir}/merged_virtual_regexp"
+
+ file {"$postfix_virtual_regexp_snippets_dir":
+ ensure => 'directory',
+ owner => 'root',
+ group => '0',
+ mode => '700',
+ source => [
+ "puppet:///modules/site-postfix/${fqdn}/virtual_regexp.d",
+ "puppet:///modules/site-postfix/virtual_regexp.d",
+ "puppet:///files/etc/postfix/virtual_regexp.d",
+ "puppet:///modules/postfix/virtual_regexp.d",
+ ],
+ recurse => true,
+ purge => false,
+ }
+
+ concatenated_file { "$postfix_merged_virtual_regexp":
+ dir => "${postfix_virtual_regexp_snippets_dir}",
+ require => File["$postfix_virtual_regexp_snippets_dir"],
+ }
+
+ config_file { '/etc/postfix/virtual_regexp':
+ source => "$postfix_merged_virtual_regexp",
+ subscribe => File["$postfix_merged_virtual_regexp"],
+ }
+
+}
diff --git a/manifests/virtual_regexp_snippet.pp b/manifests/virtual_regexp_snippet.pp
new file mode 100644
index 0000000..b4515b4
--- /dev/null
+++ b/manifests/virtual_regexp_snippet.pp
@@ -0,0 +1,67 @@
+/*
+== Definition: postfix::virtual_regexp_snippet
+
+Adds a virtual_regexp snippets to /etc/postfix/virtual_regexp.
+See the postfix::virtual_regexp class for details.
+
+Parameters:
+- *source* or *content*: source or content of the virtual_regexp snippet
+- *ensure*: present (default) or absent
+
+Requires:
+- Class["postfix"]
+
+Example usage:
+
+ node "toto.example.com" {
+ include postfix
+ postfix::virtual_regexp {
+ 'wrong_date': content => 'FIXME';
+ 'bla': source => 'puppet:///files/etc/postfix/virtual_regexp.d/bla';
+ }
+ }
+
+*/
+
+define postfix::virtual_regexp_snippet (
+ $ensure = "present",
+ $source = '',
+ $content = undef
+) {
+
+ if $source == '' and $content == undef {
+ fail("One of \$source or \$content must be specified for postfix::virtual_regexp_snippet ${name}")
+ }
+
+ if $source != '' and $content != undef {
+ fail("Only one of \$source or \$content must specified for postfix::virtual_regexp_snippet ${name}")
+ }
+
+ if ($value == false) and ($ensure == "present") {
+ fail("The value parameter must be set when using the postfix::virtual_regexp_snippet define with ensure=present.")
+ }
+
+ include postfix::virtual_regexp
+
+ $snippetfile = "${postfix::virtual_regexp::postfix_virtual_regexp_snippets_dir}/${name}"
+
+ file { "$snippetfile":
+ ensure => "$ensure",
+ mode => 600,
+ owner => root,
+ group => 0,
+ notify => Exec["concat_${postfix::virtual_regexp::postfix_merged_virtual_regexp}"],
+ }
+
+ if $source {
+ File["$snippetfile"] {
+ source => $source,
+ }
+ }
+ else {
+ File["$snippetfile"] {
+ content => $content,
+ }
+ }
+
+}