- From: KC Braunschweig <
>
- To:
- Subject: [chef] Re: coding style, abstracting "cron" vs "crond"
- Date: Tue, 18 Sep 2012 12:25:44 -0700
On Tue, Sep 18, 2012 at 12:15 PM,
<
>
wrote:
>
template "/etc/cron.d/blah-maint" do
>
source "blah-maint-cron.erb"
>
mode 0644
>
if platform?("redhat", "centos")
>
notifies :reload, "service[crond]", :delayed
>
elsif platform?("debian", "ubuntu")
>
notifies :reload, "service[cron]", :delayed
>
end
>
end
>
>
if platform?("redhat", "centos")
>
service "crond" do
>
supports [ :reload, :status ]
>
action [ :reload ]
>
end
>
end
>
if platform?("debian", "ubuntu")
>
service "cron" do
>
supports [ :reload, :status ]
>
action [ :reload ]
>
end
>
end
>
Paraphrasing from the cron cookbook and extrapolating a bit:
case node['platform']
when "redhat", "centos", "scientific", "fedora", "amazon"
svc = "crond"
when "debian", "ubuntu", "suse"
svc = "cron"
end
service 'cron' do
service_name svc
supports [ :reload, :status ]
action :reload
end
template "/etc/cron.d/blah-maint" do
source "blah-maint-cron.erb"
mode 0644
notifies :reload, "service[cron]"
end
If you can just agree to call the cron service cron, you can set the
actual service_name that chef will use based on the platform driven
variable and no one else has to care.
KC
Archive powered by MHonArc 2.6.16.