diff options
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/disable.pp | 7 | ||||
-rw-r--r-- | manifests/disable/base.pp | 12 | ||||
-rw-r--r-- | manifests/disable/debian.pp | 11 | ||||
-rw-r--r-- | manifests/init.pp | 150 | ||||
-rw-r--r-- | manifests/satellite.pp | 10 | ||||
-rw-r--r-- | manifests/smtp_auth.pp | 37 | ||||
-rw-r--r-- | manifests/tlspolicy.pp | 2 | ||||
-rw-r--r-- | manifests/transport.pp | 6 | ||||
-rw-r--r-- | manifests/transport_regexp.pp | 2 | ||||
-rw-r--r-- | manifests/virtual.pp | 6 | ||||
-rw-r--r-- | manifests/virtual_regexp.pp | 2 |
11 files changed, 159 insertions, 86 deletions
diff --git a/manifests/disable.pp b/manifests/disable.pp new file mode 100644 index 0000000..c233ec6 --- /dev/null +++ b/manifests/disable.pp @@ -0,0 +1,7 @@ +# remove postfix +class postfix::disable { + case $::operatingsystem { + debian: { include postfix::disable::debian } + default: { include postfix::disable::base } + } +} diff --git a/manifests/disable/base.pp b/manifests/disable/base.pp new file mode 100644 index 0000000..5c56c70 --- /dev/null +++ b/manifests/disable/base.pp @@ -0,0 +1,12 @@ +class postfix::disable::base { + + service{'postfix': + ensure => stopped, + enable => false, + } + package{'postfix': + ensure => absent, + require => Service['postfix'], + } + +} diff --git a/manifests/disable/debian.pp b/manifests/disable/debian.pp new file mode 100644 index 0000000..213efc5 --- /dev/null +++ b/manifests/disable/debian.pp @@ -0,0 +1,11 @@ +# debian has some issues with absent +# init scripts. +# It's a bug in debian's provider that should be fixed in puppet, but in the +# meantime we need this hack. +# +# see: https://projects.puppetlabs.com/issues/9381 +class postfix::disable::debian inherits postfix::disable::base { + Service['postfix']{ + hasstatus => false, + } +} diff --git a/manifests/init.pp b/manifests/init.pp index c388166..d298183 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -19,7 +19,6 @@ # - *$use_sympa*: whether to include sympa portion at master.cf # - *$use_firma*: whether to include firma portion at master.cf # - *$use_mlmmj*: whether to include mlmmj portion at master.cf -# - *$use_gpg_mailgate*: whether to include gpg-mailgate portion at master.cf # - *$use_submission*: set to "yes" to enable submission section at master.cf # - *$use_smtps*: set to "yes" to enable smtps section at master.cf # - *$mastercf_tail*: set this for additional content to be added at the end of master.cf @@ -35,54 +34,72 @@ # } # class postfix( - $smtp_listen = "127.0.0.1", - $root_mail_recipient = "nobody", - $anon_sasl = "no", - $manage_header_checks = "no", - $manage_tls_policy = "no", - $manage_transport_regexp = "no", - $manage_virtual_regexp = "no", + $smtp_listen = '127.0.0.1', + $root_mail_recipient = 'nobody', + $anon_sasl = 'no', + $manage_header_checks = 'no', + $manage_tls_policy = 'no', + $manage_transport_regexp = 'no', + $manage_virtual_regexp = 'no', $tls_fingerprint_digest = 'sha1', - $use_amavisd = "no", - $use_dovecot_lda = "no", - $use_schleuder = "no", - $use_sympa = "no", - $use_firma = "no", - $use_mlmmj = "no", - $use_gpg_mailgate = "no", - $use_submission = "no", - $use_smtps = "no", - $mastercf_tail = "", + $use_amavisd = 'no', + $use_dovecot_lda = 'no', + $use_schleuder = 'no', + $use_sympa = 'no', + $use_firma = 'no', + $use_mlmmj = 'no', + $use_submission = 'no', + $use_smtps = 'no', + $mastercf_tail = '', $inet_interfaces = 'all', - $myorigin = $::fqdn + $myorigin = $::fqdn, + $default_alias_maps = true ) { - # selinux labels differ from one distribution to another case $::operatingsystem { - RedHat, CentOS: { - case $::lsbmajdistrelease { - "4": { $postfix_seltype = "etc_t" } - "5": { $postfix_seltype = "postfix_etc_t" } + 'RedHat', 'CentOS': { + $master_cf_template = 'postfix/master.cf.redhat5.erb' + + # selinux labels differ from one distribution to another + case $::operatingsystemmajrelease { + '4': { $postfix_seltype = 'etc_t' } + '5': { $postfix_seltype = 'postfix_etc_t' } default: { $postfix_seltype = undef } } + + postfix::config { + 'sendmail_path': value => '/usr/sbin/sendmail.postfix'; + 'newaliases_path': value => '/usr/bin/newaliases.postfix'; + 'mailq_path': value => '/usr/bin/mailq.postfix'; + } + } + + 'Debian': { + $master_cf_template = "postfix/master.cf.debian-${::operatingsystemmajrelease}.erb" + } + + 'Ubuntu': { + $master_cf_template = 'postfix/master.cf.debian-sid.erb' } default: { - $postfix_seltype = undef + $postfix_seltype = undef + $master_cf_template = undef } } # Bootstrap moduledir include common::moduledir - module_dir{'postfix': } + common::module_dir{'postfix': } # Include optional classes if $anon_sasl == 'yes' { include postfix::anonsasl } - if $header_checks == 'yes' { + # this global variable needs to get parameterized as well + if $::header_checks == 'yes' { include postfix::header_checks } if $manage_tls_policy == 'yes' { @@ -100,7 +117,7 @@ class postfix( include postfix::virtual_regexp } - package { ["postfix", "mailx"]: + package { ['postfix', 'mailx']: ensure => installed } @@ -108,82 +125,71 @@ class postfix( Package[mailx] { name => 'bsd-mailx' } } - service { "postfix": + service { 'postfix': ensure => running, - require => Package["postfix"], + require => Package['postfix'], } - file { "/etc/mailname": + file { '/etc/mailname': ensure => present, - content => "${fqdn}\n", + content => "${::fqdn}\n", seltype => $postfix_seltype, } # Aliases - file { "/etc/aliases": - ensure => present, + file { '/etc/aliases': + ensure => present, content => "# file managed by puppet\n", replace => false, seltype => $postfix_seltype, - notify => Exec["newaliases"], + notify => Exec['newaliases'], } # Aliases - exec { "newaliases": - command => "/usr/bin/newaliases", + exec { 'newaliases': + command => '/usr/bin/newaliases', refreshonly => true, - require => Package["postfix"], - subscribe => File["/etc/aliases"], + require => Package['postfix'], + subscribe => File['/etc/aliases'], } # Config files - file { "/etc/postfix/master.cf": + file { '/etc/postfix/master.cf': ensure => present, - owner => "root", - group => "root", - mode => "0644", - content => $::operatingsystem ? { - Redhat => template("postfix/master.cf.redhat5.erb"), - CentOS => template("postfix/master.cf.redhat5.erb"), - Debian => template("postfix/master.cf.debian-${::lsbdistcodename}.erb"), - Ubuntu => template("postfix/master.cf.debian-etch.erb"), - }, + owner => 'root', + group => 'root', + mode => '0644', + content => template($master_cf_template), seltype => $postfix_seltype, - notify => Service["postfix"], - require => Package["postfix"], + notify => Service['postfix'], + require => Package['postfix'], } # Config files - file { "/etc/postfix/main.cf": + file { '/etc/postfix/main.cf': ensure => present, - owner => "root", - group => "root", - mode => "0644", - source => "puppet:///modules/postfix/main.cf", + owner => 'root', + group => 'root', + mode => '0644', + source => 'puppet:///modules/postfix/main.cf', replace => false, seltype => $postfix_seltype, - notify => Service["postfix"], - require => Package["postfix"], + notify => Service['postfix'], + require => Package['postfix'], } # Default configuration parameters - postfix::config { - "myorigin": value => "${myorigin}"; - "alias_maps": value => "hash:/etc/aliases"; - "inet_interfaces": value => "${inet_interfaces}"; - } - - case $::operatingsystem { - RedHat, CentOS: { - postfix::config { - "sendmail_path": value => "/usr/sbin/sendmail.postfix"; - "newaliases_path": value => "/usr/bin/newaliases.postfix"; - "mailq_path": value => "/usr/bin/mailq.postfix"; - } + if $default_alias_maps { + postfix::config { + 'alias_maps': value => 'hash:/etc/aliases'; } } + postfix::config { + 'myorigin': value => $myorigin; + 'inet_interfaces': value => $inet_interfaces; + } - postfix::mailalias {"root": + postfix::mailalias {'root': recipient => $root_mail_recipient, } } diff --git a/manifests/satellite.pp b/manifests/satellite.pp index 739c625..45a40ad 100644 --- a/manifests/satellite.pp +++ b/manifests/satellite.pp @@ -21,16 +21,16 @@ # } # } # + class postfix::satellite( $relayhost = '', - $valid_fqdn = '', + $valid_fqdn = $::fqdn, $root_mail_recipient = '' ) { - # If $valid_fqdn exists, use it to override $fqdn - case $valid_fqdn { - "": { $valid_fqdn = $::fqdn } - default: { $fqdn = "${valid_fqdn}" } + # If $valid_fqdn is provided, use it to override $fqdn + if $valid_fqdn != $::fdqn { + $fqdn = $valid_fqdn } class { 'postfix': diff --git a/manifests/smtp_auth.pp b/manifests/smtp_auth.pp new file mode 100644 index 0000000..b553fb5 --- /dev/null +++ b/manifests/smtp_auth.pp @@ -0,0 +1,37 @@ +# == Definition: postfix::smtp_auth +# +# Manages content of the /etc/postfix/smtp_auth map. +# +# Requires: +# - Class["postfix"] +# - Postfix::Hash["/etc/postfix/smtp_auth"] +# - file_line (from puppetlab's stdlib module) +# +# Example usage: +# +# node 'toto.example.com' { +# +# include postfix +# +# postfix::hash { '/etc/postfix/smtp_auth': +# ensure => present, +# } +# postfix::config { 'smtp_auth_maps': +# value => 'hash:/etc/postfix/smtp_auth' +# } +# postfix::smtp_auth { 'gmail.com': +# ensure => present, +# user => 'USER', +# password => 'PW', +# } +# } + +define postfix::smtp_auth ($user, $password, $ensure=present) { + file_line { $name: + ensure => $ensure, + path => '/etc/postfix/smtp_auth', + line => "${name} ${user}:${password}", + notify => Exec['generate /etc/postfix/smtp_auth.db'], + require => Package['postfix'], + } +} diff --git a/manifests/tlspolicy.pp b/manifests/tlspolicy.pp index e1272b9..d901710 100644 --- a/manifests/tlspolicy.pp +++ b/manifests/tlspolicy.pp @@ -16,7 +16,7 @@ class postfix::tlspolicy( ) { include common::moduledir - module_dir{'postfix/tls_policy': } + common::module_dir{'postfix/tls_policy': } $postfix_tlspolicy_dir = "${common::moduledir::module_dir_path}/postfix/tls_policy" $postfix_merged_tlspolicy = "${postfix_tlspolicy_dir}/merged_tls_policy" diff --git a/manifests/transport.pp b/manifests/transport.pp index 90c5468..08b93e5 100644 --- a/manifests/transport.pp +++ b/manifests/transport.pp @@ -12,7 +12,7 @@ Requires: - Class["postfix"] - Postfix::Hash["/etc/postfix/transport"] - Postfix::Config["transport_maps"] -- common::line (from module common) +- file_line (from module stdlib) Example usage: @@ -34,9 +34,9 @@ Example usage: */ define postfix::transport ($ensure="present", $destination) { - line {"${name} ${destination}": + file_line {"${name} ${destination}": ensure => $ensure, - file => "/etc/postfix/transport", + path => "/etc/postfix/transport", line => "${name} ${destination}", notify => Exec["generate /etc/postfix/transport.db"], require => Package["postfix"], diff --git a/manifests/transport_regexp.pp b/manifests/transport_regexp.pp index eaa78da..4961141 100644 --- a/manifests/transport_regexp.pp +++ b/manifests/transport_regexp.pp @@ -22,7 +22,7 @@ class postfix::transport_regexp { include common::moduledir - module_dir{'postfix/transport_regexp': } + common::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" diff --git a/manifests/virtual.pp b/manifests/virtual.pp index d6912a4..06df32a 100644 --- a/manifests/virtual.pp +++ b/manifests/virtual.pp @@ -12,7 +12,7 @@ Requires: - Class["postfix"] - Postfix::Hash["/etc/postfix/virtual"] - Postfix::Config["virtual_alias_maps"] -- common::line (from module common) +- file_line (from module stdlib) Example usage: @@ -34,9 +34,9 @@ Example usage: */ define postfix::virtual ($ensure="present", $destination) { - line {"${name} ${destination}": + file_line {"${name} ${destination}": ensure => $ensure, - file => "/etc/postfix/virtual", + path => "/etc/postfix/virtual", line => "${name} ${destination}", notify => Exec["generate /etc/postfix/virtual.db"], require => Package["postfix"], diff --git a/manifests/virtual_regexp.pp b/manifests/virtual_regexp.pp index af68ec6..18bbd8c 100644 --- a/manifests/virtual_regexp.pp +++ b/manifests/virtual_regexp.pp @@ -22,7 +22,7 @@ class postfix::virtual_regexp { include common::moduledir - module_dir{'postfix/virtual_regexp': } + common::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" |