Skip to content

Instantly share code, notes, and snippets.

@Maniacal
Created June 13, 2012 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Maniacal/2925821 to your computer and use it in GitHub Desktop.
Save Maniacal/2925821 to your computer and use it in GitHub Desktop.
Problem with chef server resource
The following is for a chef-client 0.10.8 run
This is what it says in chef wiki concerning the service resource (http://wiki.opscode.com/display/chef/Resources#Resources-Service):
:status - the init script or other service provider can use a status command to determine if the service is running. If this is not specified, Chef will attempt to match the service_name against the process table as a regular expression, unless pattern is specified as a parameter attribute.
I have a service who's init script isn't proper so it doesn't support chkconfig, status, etc. It will eventually be fixed but not now. In the mean time it doesn't appear as if chef is doing what the wiki says it'll do.
Here's the resource from the recipe:
service "ejabberd" do
provider Chef::Provider::Service::Init::Redhat
action [ :start ]
end
This is what I'm seeing in the output:
[2012-06-13T18:03:09+00:00] DEBUG: Processing service[ejabberd] on i-2e187d68
[2012-06-13T18:03:09+00:00] INFO: Processing service[ejabberd] action start (ejabberd::default line 224)
[2012-06-13T18:03:09+00:00] DEBUG: service[ejabberd] supports status, running
*** Why would it say that? I didn't specify that it supports status.
[2012-06-13T18:03:09+00:00] DEBUG: Executing /sbin/service ejabberd status
[2012-06-13T18:03:09+00:00] DEBUG: ---- Begin output of /sbin/service ejabberd status ----
[2012-06-13T18:03:09+00:00] DEBUG: STDOUT: Usage: /etc/init.d/ejabberd {start|stop|restart|force-reload}
[2012-06-13T18:03:09+00:00] DEBUG: STDERR:
[2012-06-13T18:03:09+00:00] DEBUG: ---- End output of /sbin/service ejabberd status ----
[2012-06-13T18:03:09+00:00] DEBUG: Ran /sbin/service ejabberd status returned 1
[2012-06-13T18:03:09+00:00] DEBUG: sh(/sbin/chkconfig --list ejabberd)
*** Is this what is meant on the wiki when it says "match the service_name against the process table as a regular expression"? Because that's not what I would call a "process table". In fact, the service_name is ejabberd (which was running in this case), and if you look at running processes with regular expression you would find it. I could solve this with a "not_if" and my own code to check running processes but was hoping this would be handled by chef the way it's described. I could also try specifying "pattern" as it says but it looks like it's looking at the output of chkconfig, not running processes so I think it would work.
[2012-06-13T18:03:09+00:00] DEBUG: Executing /sbin/service ejabberd start
[2012-06-13T18:03:46+00:00] DEBUG: ---- Begin output of /sbin/service ejabberd start ----
[2012-06-13T18:03:46+00:00] DEBUG: STDOUT: Starting ejabberd...
done.
[2012-06-13T18:03:46+00:00] DEBUG: STDERR:
[2012-06-13T18:03:46+00:00] DEBUG: ---- End output of /sbin/service ejabberd start ----
[2012-06-13T18:03:46+00:00] DEBUG: Ran /sbin/service ejabberd start returned 0
[2012-06-13T18:03:46+00:00] INFO: service[ejabberd] started
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment