- From: Joshua Miller <
>
- To:
- Subject: [chef] Re: Re: Running chef-client as a service
- Date: Mon, 31 May 2010 09:57:40 -0700
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; b=wTpd+5AzD3PnHyD0xOXShxlmvG77rv1++c2/cY0QDKWVaPnvC0/vG8DSRLoMhSc9yV vhRfeNJDVqszd3duY9rZ6q4lPBQwKbbUifwRI20jlUrhdRIUyNEQ1AMWLGeKDBObr/JH mHgvdZ9ns5YRx9+iOUO6dJnX1DraRJNHZQPD0=
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.
Joshua
joshua-millers-macbook-pro:~ jmiller$ cat
site-cookbooks/chef/recipes/client-deb.rb
case node[:platform]
when "ubuntu"
if node[:platform_version].to_f >= 9.10
template "/etc/init.d/chef-client" do
source "chef-client-upstartjob.erb"
owner "root"
group "root"
mode 0774
backup 0
not_if do File.symlink?("/etc/init.d/chef-server") end
end
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
end
end
joshua-millers-macbook-pro:~ jmiller$ cat
site-cookbooks/chef/templates/default/upstart-chef-client.conf.erb
start on runlevel [2345]
script
exec /usr/bin/env chef-client -c /etc/chef/client.rb -i <%=
@node[:chef][:client_interval] %> -s <%= @node[:chef][:client_splay] %>
end script
# Restart the process if it dies with a signal
# or exit code not given by the 'normal exit' stanza.
respawn
# Give up if restart occurs 10 times in 90 seconds.
respawn limit 10 90
joshua-millers-macbook-pro:~ jmiller$
Then I just jacked the upstart stuff init script:
joshua-millers-macbook-pro:~ jmiller$ cat
site-cookbooks/chef/templates/default/chef-client-upstartjob.erb
#!/bin/sh -e
# upstart-job
#
# Symlink target for initscripts that have been converted to Upstart.
set -e
INITSCRIPT="$(basename "$0")"
JOB="${INITSCRIPT%.sh}"
if [ "$JOB" = "upstart-job" ]; then
if [ -z "$1" ]; then
echo "Usage: upstart-job JOB COMMAND" 1>&2
exit 1
fi
JOB="$1"
INITSCRIPT="$1"
shift
else
if [ -z "$1" ]; then
echo "Usage: $0 COMMAND" 1>&2
exit 1
fi
fi
COMMAND="$1"
shift
if [ -z "$DPKG_MAINTSCRIPT_PACKAGE" ]; then
ECHO=echo
else
ECHO=:
fi
$ECHO "Rather than invoking init scripts through /etc/init.d, use the
service(8)"
$ECHO "utility, e.g. service $INITSCRIPT $COMMAND"
case $COMMAND in
status)
$ECHO
$ECHO "Since the script you are attempting to invoke has been converted
to an"
$ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g.
$COMMAND $JOB"
$COMMAND "$JOB"
;;
start|stop|restart)
$ECHO
$ECHO "Since the script you are attempting to invoke has been converted
to an"
$ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g.
$COMMAND $JOB"
PID=$(status "$JOB" 2>/dev/null | awk '/[0-9]$/ { print $NF }')
if [ -z "$PID" ] && [ "$COMMAND" = "stop" ]; then
exit 0
elif [ -n "$PID" ] && [ "$COMMAND" = "start" ]; then
exit 0
elif [ -z "$PID" ] && [ "$COMMAND" = "restart" ]; then
start "$JOB"
exit 0
fi
$COMMAND "$JOB"
;;
reload|force-reload)
$ECHO
$ECHO "Since the script you are attempting to invoke has been converted
to an"
$ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g.
$COMMAND $JOB"
reload "$JOB"
;;
*)
$ECHO
$ECHO "The script you are attempting to invoke has been converted to an
Upstart" 1>&2
$ECHO "job, but $COMMAND is not supported for Upstart jobs." 1>&2
exit 1
esac
joshua-millers-macbook-pro:~ jmiller
On May 31, 2010, at 9:04 AM, Daniel DeLeo wrote:
>
Ohai!
>
The bootstrap recipe uses the node[:chef][:init_style] attribute to
>
determine which init system to use:
>
>
http://github.com/opscode/cookbooks/blob/master/chef/recipes/bootstrap_client.rb#L31-63
>
>
It looks like upstart isn't supported yet, so I'd recommend creating
>
your own post-bootstrap recipe to configure chef to run via upstart.
>
>
HTH,
>
Dan DeLeo
>
>
On Mon, May 31, 2010 at 4:31 AM, Dmitry V'yal
>
<
>
>
wrote:
>
> Greetings,
>
>
>
> I've bootstrapped chef clients through vpn as I planned earlier. Now what
>
> is
>
> the best way to run chef-client automatically? I've read, chef uses runit
>
> for managing services, but ubuntu-9.10 I'm testing on is based on Upstart.
>
> Is there really a point in replacing upstart in favor of runit?
>
>
>
> What can be advised in my situation?
>
>
>
> Best wishes,
>
> Dmitry
>
>
Archive powered by MHonArc 2.6.16.