[chef] Re: Re: Re: Running chef-client as a service


Chronological Thread 
  • From: Dmitry V'yal < >
  • To:
  • Subject: [chef] Re: Re: Re: Running chef-client as a service
  • Date: Tue, 01 Jun 2010 14:43:12 +0400
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=xKkQGyFy6CEEokMWa6iCD5Sexfm7BI2tmQLNKo8wRSuM94F6PPzqTkv+JzxBNQd37T Jl7VvIqen3hWdO6NUm8Irs6BC1vUjwT3hmDk3Sc2wVgYMYk/4VlUABIldxzdC1Cyw3DX 0D/rvmEnY+vAIXILdDebeC6UZBiFP/prCqvHI=

On 05/31/2010 08:57 PM, Joshua Miller wrote:
Here is what I do for my debian package installs, one problem I have not 
fixed is it does not reload chef upstart when the values change ... new to 
upstart and  a restart does not pickup the new vars so I have to figure it 
out later.  Since I dont change it much I have not really cared.


thanks for sharing. I adopted your recipe, but turned the service into the task run by cron. RAM is precious resource on VPS.
I couldn't find a proper way to calculate times for cron, though. Also I think /etc/init.d/chef-client is not really necessary.

This what is have for now:

$ cat chef/recipes/client-deb.rb
case node[:platform]
when "ubuntu"
  if node[:platform_version].to_f >= 9.10
    service "chef-client" do
       provider Chef::Provider::Service::Upstart
       supports :restart => true, :reload => true
    end

    template "/etc/init/chef-client.conf" do
      source "upstart-chef-client.conf.erb"
      owner "root"
      group "root"
      mode 0644
      backup 0
      notifies :start, resources(:service => "chef-client")
      not_if do File.symlink?("/etc/init.d/chef-server") end
    end

    cron "chef-client" do
minute ((0..59).to_a.delete_if {|x| x % (@node[:chef][:client_interval].to_i / 60) != 0 }.join ",")
      command "service chef-client start"
    end
  end
end

% cat chef/templates/default/upstart-chef-client.conf.erb
start on runlevel [2345]

task

script
exec /usr/bin/env chef-client -c /etc/chef/client.rb -s <%= @node[:chef][:client_splay] %>
end script



Archive powered by MHonArc 2.6.16.

§