# Install Sendmail packages. # class sendmail::common { if !$mail_domain and $domain { $mail_domain = $domain } if $operatingsystem != "OpenBSD" { package { "sendmail": ensure => installed, name => [ "sendmail", "sendmail-cf", ], } service { "sendmail": ensure => running, enable => true, require => Package["sendmail"], } } case $operatingsystem { "centos","fedora": { file { "/etc/sysconfig/sendmail": ensure => present, content => "DAEMON=no\nQUEUE=1h\n", owner => "root", group => "root", mode => 0644, notify => Service["sendmail"], } } } } # Configure Sendmail submission. # # === Global variables # # $mail_server: # Hostname of mail server. # class sendmail::client inherits sendmail::common { if !$mail_server { $mail_server = "127.0.0.1" } file { "/etc/mail/submit.mc": path => $operatingsystem ? { "openbsd" => "/usr/share/sendmail/cf/submit.mc", default => "/etc/mail/submit.mc", }, ensure => present, content => template("sendmail/submit.mc.erb", "sendmail/submit.mc.msp.erb"), owner => "root", group => $operatingsystem ? { "openbsd" => "bin", default => "root", }, mode => 0644, notify => Exec["make submit.cf"], require => $operatingsystem ? { "openbsd" => undef, default => Package["sendmail"], }, } exec { "make submit.cf": path => "/bin:/usr/bin:/sbin:/usr/sbin:/etc/mail", cwd => $operatingsystem ? { "openbsd" => "/usr/share/sendmail/cf", default => "/etc/mail", }, refreshonly => true, notify => $operatingsystem ? { "openbsd" => undef, default => Service["sendmail"], }, } file { "/etc/mail/submit.cf": ensure => present, owner => "root", group => $operatingsystem ? { "openbsd" => "wheel", "ubuntu" => "smmsp", default => "root", }, mode => 0644, source => $operatingsystem ? { "openbsd" => "/usr/share/sendmail/cf/submit.cf", default => undef, }, require => Exec["make submit.cf"], } } # Configure Sendmail submission using port 587. # class sendmail::client::msa inherits sendmail::client { File["/etc/mail/submit.mc"] { content => template("sendmail/submit.mc.erb", "sendmail/submit.mc.msa.erb"), } } # Configure Sendmail server. # # $sendmail_domain: # SMTP domain name. class sendmail::server inherits sendmail::common { include procmail case $operatingsystem { centos,redhat: { $sendmail_ostype = "linux" $group = "root" File["/etc/sysconfig/sendmail"] { content => "DAEMON=yes\nQUEUE=1h\n", } } ubuntu: { fail("Operating system not supported.") } openbsd: { $sendmail_ostype = "openbsd" $group = "wheel" } } file { "sendmail.mc": name => $operatingsystem ? { "openbsd" => "/usr/share/sendmail/cf/sendmail.mc", default => "/etc/mail/sendmail.mc", }, content => template("sendmail/sendmail.mc.erb"), owner => "root", group => $group, mode => 0644, notify => Exec["make sendmail.cf"], } file { "/etc/aliases": ensure => present, notify => Exec["newaliases"], owner => "root", group => $group, mode => 0644, } exec { "make sendmail.cf": path => "/bin:/usr/bin:/sbin:/usr/sbin", cwd => $operatingsystem ? { openbsd => "/usr/share/sendmail/cf", default => "/etc/mail", }, require => $operatingsystem ? { openbsd => undef, default => Package["sendmail"], }, refreshonly => true, } file { "/etc/mail/sendmail.cf": ensure => present, owner => "root", group => $group, mode => 0644, source => $operatingsystem ? { openbsd => "/usr/share/sendmail/cf/sendmail.cf", default => undef, }, require => Exec["make sendmail.cf"], notify => Service["sendmail"], } exec { "newaliases": path => "/bin:/usr/bin:/sbin:/usr/sbin", refreshonly => true, } }