Hi,
Besides a few outstanding issues (ruby 1.8.7 doesn’t seem to work and
this http://tickets.opscode.com/browse/CHEF-269), I’ve got my EC2
setup going, mostly thanks to the excellent documentation and examples.
So, next step is to try to speed up my recipes and I’m running into a
few areas where I don’t think I fully understand how things are
supposed to work:
- Given this recipe
remote_file “war” do
path "/usr/share/jetty6/webapps/ROOT.war"
owner "jetty"
mode 0640
source node[:war]
notifies :restart, resources(:service => “jetty6”)
end
I would assume Chef would either a) Start the jetty6 service if it was
not running or b) restart the jetty6 service if it was running already
And only do this if the remote file has changed.
First it seems that, if the service is not running already, it is not
started??
[Thu, 11 Jun 2009 20:43:37 +0200] DEBUG: remote_file[fz_war] changed
from f18463d301b65a6c161669d0de190293f78480b3ed88590215ea30947cf8dfbf
to 1792af24a3aa7829dbf15340ad54d7a7af9db272fa769e4572f03e783c4c3da5
[Thu, 11 Jun 2009 20:43:37 +0200] INFO: Updating remote_file[fz_war]
at /usr/share/jetty6/webapps/ROOT.war
[Thu, 11 Jun 2009 20:43:37 +0200] INFO: Backing up remote_file[fz_war]
to /usr/share/jetty6/webapps/ROOT.war.chef-20090611204337
[Thu, 11 Jun 2009 20:43:38 +0200] INFO: Removing backup of
remote_file[fz_war] at /usr/share/jetty6/webapps/
ROOT.war.chef-20090611181740
[Thu, 11 Jun 2009 20:43:38 +0200] INFO: remote_file[fz_war] sending
restart action to service[jetty6] (delayed)
[Thu, 11 Jun 2009 20:43:38 +0200] DEBUG: service[jetty6] using
Chef::Provider::Service::Debian
[Thu, 11 Jun 2009 20:43:38 +0200] DEBUG: service[jetty6] does not
support status and you have not specified a status command, falling
back to process table inspection
[Thu, 11 Jun 2009 20:43:38 +0200] DEBUG: service[jetty6]: attempting
to match jetty6 ((?-mix:jetty6)) against process table
[Thu, 11 Jun 2009 20:43:38 +0200] DEBUG: service[jetty6]: ps -ef
exited and parsed successfully, process running: false
[Thu, 11 Jun 2009 20:43:38 +0200] INFO: Chef Run complete in 24.356492
seconds
If the service is already running it is restarted ok:
[Thu, 11 Jun 2009 20:53:46 +0200] INFO: remote_file[fz_war] sending
restart action to service[jetty6] (delayed)
[Thu, 11 Jun 2009 20:53:46 +0200] DEBUG: service[jetty6] using
Chef::Provider::Service::Debian
[Thu, 11 Jun 2009 20:53:46 +0200] DEBUG: service[jetty6] does not
support status and you have not specified a status command, falling
back to process table inspection
[Thu, 11 Jun 2009 20:53:46 +0200] DEBUG: service[jetty6]: attempting
to match jetty6 ((?-mix:jetty6)) against process table
[Thu, 11 Jun 2009 20:53:46 +0200] DEBUG: service[jetty6]: ps -ef
exited and parsed successfully, process running: true
[Thu, 11 Jun 2009 20:53:46 +0200] DEBUG: service[jetty6]: attempting
to restart
[Thu, 11 Jun 2009 20:53:46 +0200] DEBUG: Executing /etc/init.d/jetty6
restart
[Thu, 11 Jun 2009 20:54:28 +0200] DEBUG: ---- Begin output of /etc/
init.d/jetty6 restart ----
Second, it seems that the notification always takes place, even if the
remote file didn’t change:
Thu, 11 Jun 2009 20:44:35 +0200] DEBUG: /fz-1.war 100% done (9736249
of 9736249)
[Thu, 11 Jun 2009 20:44:36 +0200] INFO: remote_file[fz_war] sending
restart action to service[jetty6] (delayed)
[Thu, 11 Jun 2009 20:44:36 +0200] DEBUG: service[jetty6] using
Chef::Provider::Service::Debian
[Thu, 11 Jun 2009 20:44:36 +0200] DEBUG: service[jetty6] does not
support status and you have not specified a status command, falling
back to process table inspection
[Thu, 11 Jun 2009 20:44:36 +0200] DEBUG: service[jetty6]: attempting
to match jetty6 ((?-mix:jetty6)) against process table
[Thu, 11 Jun 2009 20:44:36 +0200] DEBUG: service[jetty6]: ps -ef
exited and parsed successfully, process running: false
[Thu, 11 Jun 2009 20:44:36 +0200] INFO: Chef Run complete in 23.318144
seconds
Did I misunderstand something about how notification & services are
supposed to work??
- Given this recipe:
service “mountec2vol” do
supports :status => true, :restart => true
action [ :enable, :start ]
end
It seems Chef is running the “status” command twice. Is this necessary?
[Thu, 11 Jun 2009 16:41:52 +0200] DEBUG: Processing service[mountec2vol]
[Thu, 11 Jun 2009 16:41:52 +0200] DEBUG: service[mountec2vol] using
Chef::Provider::Service::Debian
[Thu, 11 Jun 2009 16:41:52 +0200] DEBUG: service[mountec2vol] supports
status, running
[Thu, 11 Jun 2009 16:41:52 +0200] DEBUG: Executing /etc/init.d/
mountec2vol status
[Thu, 11 Jun 2009 16:42:00 +0200] DEBUG: ---- Begin output of /etc/
init.d/mountec2vol status ----
[Thu, 11 Jun 2009 16:42:00 +0200] DEBUG: STDOUT: ATTACHMENT
vol-98f316f1 i-8b4f4cff /dev/sdh attache2009-06-11T13:33:56+0000
[Thu, 11 Jun 2009 16:42:00 +0200] DEBUG: STDERR:
[Thu, 11 Jun 2009 16:42:00 +0200] DEBUG: ---- End output of /etc/
init.d/mountec2vol status ----
[Thu, 11 Jun 2009 16:42:00 +0200] DEBUG: Ran /etc/init.d/mountec2vol
status returned 0
[Thu, 11 Jun 2009 16:42:00 +0200] DEBUG: service[mountec2vol]: not
enabling, already enabled
[Thu, 11 Jun 2009 16:42:00 +0200] DEBUG: service[mountec2vol] using
Chef::Provider::Service::Debian
[Thu, 11 Jun 2009 16:42:00 +0200] DEBUG: service[mountec2vol] supports
status, running
[Thu, 11 Jun 2009 16:42:00 +0200] DEBUG: Executing /etc/init.d/
mountec2vol status
[Thu, 11 Jun 2009 16:42:08 +0200] DEBUG: ---- Begin output of /etc/
init.d/mountec2vol status ----
[Thu, 11 Jun 2009 16:42:08 +0200] DEBUG: STDOUT: ATTACHMENT
vol-98f316f1 i-8b4f4cff /dev/sdh attache2009-06-11T13:33:56+0000
[Thu, 11 Jun 2009 16:42:08 +0200] DEBUG: STDERR:
[Thu, 11 Jun 2009 16:42:08 +0200] DEBUG: ---- End output of /etc/
init.d/mountec2vol status ----
[Thu, 11 Jun 2009 16:42:08 +0200] DEBUG: Ran /etc/init.d/mountec2vol
status returned 0
[Thu, 11 Jun 2009 16:42:08 +0200] DEBUG: service[mountec2vol]: not
starting, already running
/Jeppe