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

Split init.pp into packages/files/service and add parameters

parent 364c2bff
class postfix::files {
include postfix::params
file { '/etc/mailname':
ensure => present,
content => "${::fqdn}\n",
seltype => $postfix::params::seltype,
}
# Aliases
file { '/etc/aliases':
ensure => present,
content => '# file managed by puppet\n',
replace => false,
seltype => $postfix::params::seltype,
notify => Exec['newaliases'],
}
# Aliases
exec { 'newaliases':
command => '/usr/bin/newaliases',
refreshonly => true,
subscribe => File['/etc/aliases'],
}
# Config files
file { '/etc/postfix/master.cf':
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
content => template(
$postfix::params::master_os_template,
"${module_name}/master.cf.common.erb"
),
seltype => $postfix::params::seltype,
}
# Config files
file { '/etc/postfix/main.cf':
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
source => "puppet:///modules/${module_name}/main.cf",
replace => false,
seltype => $postfix::params::seltype,
}
::postfix::config {
'myorigin': value => $postfix::myorigin;
'alias_maps': value => 'hash:/etc/aliases';
'inet_interfaces': value => $postfix::inet_interfaces;
}
case $::osfamily {
'RedHat': {
::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 => $postfix::root_mail_recipient,
notify => Exec['newaliases'],
}
}
class postfix::packages {
include postfix::params
package { 'postfix':
ensure => installed,
}
package { 'mailx':
ensure => installed,
name => $postfix::params::mailx_package,
}
}
class postfix::params {
case $::osfamily {
'RedHat': {
$seltype = $::lsbmajdistrelease {
'4' => 'etc_t',
'5','6' => 'postfix_etc_t',
default => undef,
}
$mailx_package = 'mailx'
$master_os_template = "${module_name}/master.cf.redhat.erb"
}
'Debian': {
$seltype = undef,
$mailx_package = $::lsbdistcodename ? {
/sarge|etch|lenny|lucid/ => 'mailx',
default => 'bsd-mailx',
}
$master_os_template = "${module_name}/master.cf.debian.erb"
}
default: {
fail "Unsupported OS family '${::osfamily}'"
}
}
}
class postfix::service {
service { 'postfix':
ensure => running,
enable => true,
hasstatus => true,
restart => '/etc/init.d/postfix reload',
}
}
Markdown is supported
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