[chef] Re: coding style, abstracting "cron" vs "crond"


Chronological Thread 
  • From: Joshua Buysse < >
  • To:
  • Subject: [chef] Re: coding style, abstracting "cron" vs "crond"
  • Date: Tue, 18 Sep 2012 14:25:25 -0500

My shorter version follows, which could be optimized further using platform_family instead of platform (at least on recent versions).

On Tue, Sep 18, 2012 at 2:15 PM, < " target="_blank"> > wrote:

hiya. i have a lot of WET code when it comes to controlling cron on CentOS vs
Ubuntu. anyone have suggestions on abstracting this, making it DRY?

on CentOS, the service is known as "crond", Ubuntu, "cron". bummer.

thots? thanks!
kallen

# default to cron
cron_service_name = "cron"
if platform?("redhat", "centos")
  cron_service_name = "crond"
elsif platform?("debian", "ubuntu")
  cron_service_name = "cron"
end

template "/etc/cron.d/blah-maint" do
  source "blah-maint-cron.erb"
  mode 0644
  notifies :reload, "service[cron]", :delayed
end

service "cron" do
  service_name cron_service_name
  supports [ :reload, :status ]
  action [ :reload ]
end


--
Joshua Buysse, System Engineer
College of Liberal Arts, Office of Information Technology
University of Minnesota

"On two occasions I have been asked, 'Pray, Mr. Babbage, if you 
put into the machine wrong figures, will the right answers come 
out?' I am not able rightly to apprehend the kind of confusion of 
ideas that could provoke such a question."

  - Charles Babbage





Archive powered by MHonArc 2.6.16.

§