Commit 2b796d24 authored by Raphaël Pinson's avatar Raphaël Pinson
Browse files

Linting

parent a399f4b4
......@@ -39,12 +39,12 @@ define postfix::config ($value, $ensure = present) {
case $ensure {
present: {
augeas { "set postfix '${name}' to '${value}'":
changes => "set $name '$value'",
changes => "set ${name} '${value}'",
}
}
absent: {
augeas { "rm postfix '${name}'":
changes => "rm $name",
changes => "rm ${name}",
}
}
default: {}
......
......@@ -16,162 +16,20 @@
# include postfix
# }
#
class postfix {
# selinux labels differ from one distribution to another
case $::operatingsystem {
RedHat, CentOS: {
case $::lsbmajdistrelease {
'4': { $postfix_seltype = 'etc_t' }
'5','6': { $postfix_seltype = 'postfix_etc_t' }
default: { $postfix_seltype = undef }
}
}
default: {
$postfix_seltype = undef
}
}
# Default value for various options
if $postfix_smtp_listen == '' {
$postfix_smtp_listen = '127.0.0.1'
}
if $root_mail_recipient == '' {
$root_mail_recipient = 'nobody'
}
if $postfix_use_amavisd == '' {
$postfix_use_amavisd = 'no'
}
if $postfix_use_dovecot_lda == '' {
$postfix_use_dovecot_lda = 'no'
}
if $postfix_use_schleuder == '' {
$postfix_use_schleuder = 'no'
}
if $postfix_use_sympa == '' {
$postfix_use_sympa = 'no'
}
if $postfix_mail_user == '' {
$postfix_mail_user = 'vmail'
}
case $::operatingsystem {
/RedHat|CentOS|Fedora/: {
$mailx_package = 'mailx'
}
/Debian|kFreeBSD/: {
$mailx_package = $::lsbdistcodename ? {
/lenny|etch|sarge/ => 'mailx',
default => 'bsd-mailx',
}
}
'Ubuntu': {
if (versioncmp('10', $::lsbmajdistrelease) > 0) {
$mailx_package = 'mailx'
} else {
$mailx_package = 'bsd-mailx'
}
}
}
$master_os_template = $::operatingsystem ? {
/RedHat|CentOS/ => template('postfix/master.cf.redhat.erb', 'postfix/master.cf.common.erb'),
/Debian|Ubuntu|kFreeBSD/ => template('postfix/master.cf.debian.erb', 'postfix/master.cf.common.erb'),
}
package { 'postfix':
ensure => installed,
}
package { 'mailx':
ensure => installed,
name => $mailx_package,
}
service { 'postfix':
ensure => running,
enable => true,
hasstatus => true,
restart => '/etc/init.d/postfix reload',
require => Package['postfix'],
}
file { '/etc/mailname':
ensure => present,
content => "$::fqdn\n",
seltype => $postfix_seltype,
}
# Aliases
file { '/etc/aliases':
ensure => present,
content => '# file managed by puppet\n',
replace => false,
seltype => $postfix_seltype,
notify => Exec['newaliases'],
}
# Aliases
exec { 'newaliases':
command => '/usr/bin/newaliases',
refreshonly => true,
require => Package['postfix'],
subscribe => File['/etc/aliases'],
}
# Config files
file { '/etc/postfix/master.cf':
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
content => $master_os_template,
seltype => $postfix_seltype,
notify => Service['postfix'],
require => Package['postfix'],
}
# Config files
file { '/etc/postfix/main.cf':
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
source => 'puppet:///modules/postfix/main.cf',
replace => false,
seltype => $postfix_seltype,
notify => Service['postfix'],
require => Package['postfix'],
}
# Default configuration parameters
$myorigin = $valid_fqdn ? {
'' => $::fqdn,
default => $valid_fqdn,
}
postfix::config {
'myorigin': value => $myorigin;
'alias_maps': value => 'hash:/etc/aliases';
'inet_interfaces': value => 'all';
}
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';
}
}
default: {}
}
mailalias {'root':
recipient => $root_mail_recipient,
notify => Exec['newaliases'],
}
class postfix (
$smtp_listen = '127.0.0.1', # postfix_smtp_listen
$root_mail_recipient = 'nobody', # root_mail_recipient
$use_amavisd = 'no', # postfix_use_amavisd
$use_dovecot_lda = 'no', # postfix_use_dovecot_lda
$use_schleuder = 'no', # postfix_use_schleuder
$use_sympa = 'no', # postfix_use_sympa
$mail_user = 'vmail', # postfix_mail_user
$myorigin = $::fqdn,
$inet_interfaces = 'localhost',
) inherits postfix::params {
class { 'postfix::packages': } ->
class { 'postfix::files': } ~>
class { 'postfix::service': } ->
Class['postfix']
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment