diff --git a/metadata.rb b/metadata.rb index a9eb751..2b449c4 100644 --- a/metadata.rb +++ b/metadata.rb @@ -6,7 +6,7 @@ version "0.8.4" recipe "postfix", "Installs and configures postfix" recipe "postfix::sasl_auth", "Set up postfix to auth to a server with sasl" -%w{ubuntu debian}.each do |os| +%w{ubuntu debian redhat centos}.each do |os| supports os end diff --git a/recipes/default.rb b/recipes/default.rb index 5c97fe5..6d88b45 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -22,8 +22,24 @@ package "postfix" do action :install end -service "postfix" do - action :enable +case node[:platform] +when "ubuntu", "debian" + service "postfix" do + action :enable + end +when "redhat", "centos" + service "postfix" do + action :nothing + end + service "sendmail" do + action :nothing + end + execute "switch_mailer_to_postfix" do + command "/usr/sbin/alternatives --set mta /usr/sbin/sendmail.postfix" + notifies :stop, resources(:service => "sendmail") + notifies :start, resources(:service => "postfix") + not_if "/usr/bin/test /etc/alternatives/mta -ef /usr/sbin/sendmail.postfix" + end end %w{main master}.each do |cfg|