Merge pull request #143 from chef-cookbooks/freebsd-support

Properly support FreeBSD
This commit is contained in:
Tim Smith 2017-11-22 10:58:24 -08:00 committed by GitHub
commit 71bf059e4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 3 deletions

View File

@ -67,7 +67,48 @@ when 'omnios'
execute 'load postfix manifest' do
action :nothing
command "svccfg import #{manifest_path}"
notifies :restart, 'service[postfix]'
notifies :restart, 'service[postfix]' unless platform_family?('solaris2')
end
when 'freebsd'
# Actions are based on docs provided by FreeBSD:
# https://www.freebsd.org/doc/handbook/mail-changingmta.html
service 'sendmail' do
action :nothing
end
template '/etc/mail/mailer.conf' do
source 'mailer.erb'
owner 'root'
group 0
notifies :restart, 'service[postfix]' unless platform_family?('solaris2')
end
execute 'switch_mailer_to_postfix' do
command [
'sysrc',
'sendmail_enable=NO',
'sendmail_submit_enable=NO',
'sendmail_outbound_enable=NO',
'sendmail_msp_queue_enable=NO',
'postfix_enable=YES',
]
notifies :stop, 'service[sendmail]', :immediately
notifies :disable, 'service[sendmail]', :immediately
notifies :start, 'service[postfix]', :delayed
only_if "sysrc sendmail_enable sendmail_submit_enable sendmail_outbound_enable sendmail_msp_queue_enable | egrep -q '(YES|unknown variable)' || sysrc postfix_enable | egrep -q '(NO|unknown variable)'"
end
execute 'disable_periodic' do
# rubocop:disable Lint/ParenthesesAsGroupedExpression
environment ({ 'RC_CONFS' => '/etc/periodic.conf' })
command [
'sysrc',
'daily_clean_hoststat_enable=NO',
'daily_status_mail_rejects_enable=NO',
'daily_status_include_submit_mailq=NO',
'daily_submit_queuerun=NO',
]
only_if "RC_CONFS=/etc/periodic.conf sysrc daily_clean_hoststat_enable daily_status_mail_rejects_enable daily_status_include_submit_mailq daily_submit_queuerun | egrep -q '(YES|unknown variable)'"
end
end
@ -134,7 +175,10 @@ end
owner 'root'
group node['root_group']
mode '0644'
notifies :restart, 'service[postfix]'
# restart service for solaris on chef-client has a bug
# unless condition can be removed after
# https://github.com/chef/chef/pull/6596 merge/release
notifies :restart, 'service[postfix]' unless platform_family?('solaris2')
variables(
lazy { { settings: node['postfix'][cfg] } }
)
@ -144,5 +188,5 @@ end
service 'postfix' do
supports status: true, restart: true, reload: true
action :enable
action [:enable, :start]
end

10
templates/mailer.erb Normal file
View File

@ -0,0 +1,10 @@
#
# Auto-generated by Chef.
# Local modifications will be overwritten.
#
# Execute the Postfix sendmail program, named /usr/local/sbin/sendmail
#
sendmail /usr/local/sbin/sendmail
send-mail /usr/local/sbin/sendmail
mailq /usr/local/sbin/sendmail
newaliases /usr/local/sbin/sendmail