Knife bootstrap & client service registration: how?

Hello,

I am using “knife bootstrap” to initialize Chef client on my VMs. My
initial role created some users just to make sure the bootstrap
procedure was working. My latest changeset is to make sure that after
"knife bootstrap", the Chef client is also registered as a system
service (runit style). I added “chef::bootstrap_client” as a recipe in
the initial bootstrap role.

The bootstrap_client recipe barfs at “start runsvdir”. Stacktrace below:

[Fri, 13 Aug 2010 15:39:32 +0200] INFO: Creating
directory[/var/log/chef] at /var/log/chef
[Fri, 13 Aug 2010 15:39:32 +0200] INFO: Setting owner to 0 for
directory[/var/log/chef]
[Fri, 13 Aug 2010 15:39:32 +0200] INFO: Setting group to 0 for
directory[/var/log/chef]
[Fri, 13 Aug 2010 15:39:32 +0200] INFO: Setting mode to 755 for
directory[/var/log/chef]
[Fri, 13 Aug 2010 15:39:32 +0200] WARN: remote_file is deprecated for
fetching files from cookbooks. Use cookbook_file instead
[Fri, 13 Aug 2010 15:39:32 +0200] WARN: From
remote_file[/etc/event.d/runsvdir] on
/srv/chef/cache/cookbooks/runit/recipes/default.rb:52:in from_file' [Fri, 13 Aug 2010 15:39:32 +0200] INFO: Storing updated cookbooks/runit/files/default/runsvdir in the cache. [Fri, 13 Aug 2010 15:39:32 +0200] INFO: Backing up current file at /etc/event.d/runsvdir [Fri, 13 Aug 2010 15:39:32 +0200] INFO: Backing up remote_file[/etc/event.d/runsvdir] to /srv/chef/backup/etc/event.d/runsvdir.chef-20100813153932 [Fri, 13 Aug 2010 15:39:32 +0200] INFO: remote_file[/etc/event.d/runsvdir] sending run action to execute[start-runsvdir] (immediate) [Fri, 13 Aug 2010 15:39:32 +0200] ERROR: remote_file[/etc/event.d/runsvdir] (/srv/chef/cache/cookbooks/runit/recipes/default.rb:52:infrom_file’)
had an error:
start runsvdir returned 1, expected 0
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/…/lib/chef/mixin/command.rb:184:in
handle_command_failures' /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/mixin/command.rb:131:inrun_command’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/…/lib/chef/provider/execute.rb:49:in
action_run' /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:51:insend’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/…/lib/chef/runner.rb:51:in
run_action' /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:58:inrun_action’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/…/lib/chef/runner.rb:56:in each' /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:56:inrun_action’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/…/lib/chef/runner.rb:109:in
converge' /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:108:ineach’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/…/lib/chef/runner.rb:108:in
converge' /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/resource_collection.rb:94 /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/resource_collection/stepable_iterator.rb:116:incall’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/…/lib/chef/resource_collection/stepable_iterator.rb:116:in
call_iterator_block' /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/resource_collection/stepable_iterator.rb:85:instep’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/…/lib/chef/resource_collection/stepable_iterator.rb:104:in
iterate' /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/resource_collection/stepable_iterator.rb:55:ineach_with_index’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/…/lib/chef/resource_collection.rb:92:in
execute_each_resource' /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:82:inconverge’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/…/lib/chef/client.rb:304:in
converge' /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/client.rb:106:inrun’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/…/lib/chef/application/client.rb:212:in
run_application' /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application/client.rb:202:inloop’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/…/lib/chef/application/client.rb:202:in
run_application' /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application.rb:62:inrun’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/chef-client:26
/usr/bin/chef-client:19:in `load’
/usr/bin/chef-client:19

If I first manually stop runsvdir and retry, the recipe goes a bit
farther before it barfs again, now on restarting the chef-client
service:

sudo stop runsvdir runsvdir stop/waiting sudo /usr/bin/chef-client
[Fri, 13 Aug 2010 15:52:19 +0200] INFO: Starting Chef Run (Version 0.9.8)
[Fri, 13 Aug 2010 15:52:19 +0200] INFO: Ran execute[apt-get update] successfully
[Fri, 13 Aug 2010 15:52:19 +0200] WARN: remote_file is deprecated for
fetching files from cookbooks. Use cookbook_file instead
[Fri, 13 Aug 2010 15:52:19 +0200] WARN: From
remote_file[/etc/event.d/runsvdir] on
/srv/chef/cache/cookbooks/runit/recipes/default.rb:52:in from_file' [Fri, 13 Aug 2010 15:52:19 +0200] INFO: Creating directory[/etc/sv/chef-client] at /etc/sv/chef-client [Fri, 13 Aug 2010 15:52:19 +0200] INFO: Setting mode to 755 for directory[/etc/sv/chef-client] [Fri, 13 Aug 2010 15:52:19 +0200] INFO: Creating directory[/etc/sv/chef-client/log] at /etc/sv/chef-client/log [Fri, 13 Aug 2010 15:52:19 +0200] INFO: Setting mode to 755 for directory[/etc/sv/chef-client/log] [Fri, 13 Aug 2010 15:52:19 +0200] INFO: Creating directory[/etc/sv/chef-client/log/main] at /etc/sv/chef-client/log/main [Fri, 13 Aug 2010 15:52:19 +0200] INFO: Setting mode to 755 for directory[/etc/sv/chef-client/log/main] [Fri, 13 Aug 2010 15:52:19 +0200] INFO: Storing updated cookbooks/chef/templates/default/sv-chef-client-run.erb in the cache. [Fri, 13 Aug 2010 15:52:19 +0200] INFO: Writing updated content for template[/etc/sv/chef-client/run] to /etc/sv/chef-client/run [Fri, 13 Aug 2010 15:52:19 +0200] INFO: Storing updated cookbooks/chef/templates/default/sv-chef-client-log-run.erb in the cache. [Fri, 13 Aug 2010 15:52:19 +0200] INFO: Writing updated content for template[/etc/sv/chef-client/log/run] to /etc/sv/chef-client/log/run [Fri, 13 Aug 2010 15:52:19 +0200] INFO: Creating a symbolic link from /usr/bin/sv -> /etc/init.d/chef-client for link[/etc/init.d/chef-client] [Fri, 13 Aug 2010 15:52:19 +0200] INFO: Creating a symbolic link from /etc/sv/chef-client -> /etc/service/chef-client for link[/etc/service/chef-client] [Fri, 13 Aug 2010 15:52:26 +0200] ERROR: Running exception handlers [Fri, 13 Aug 2010 15:52:26 +0200] ERROR: Exception handlers complete [Fri, 13 Aug 2010 15:52:26 +0200] ERROR: Re-raising exception: Chef::Exceptions::Exec - /etc/init.d/chef-client restart returned 1, expected 0 /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/mixin/command.rb:184:inhandle_command_failures’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/…/lib/chef/mixin/command.rb:131:in
run_command' /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/provider/service/init.rb:53:inrestart_service’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/…/lib/chef/provider/service.rb:83:in
action_restart' /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:51:insend’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/…/lib/chef/runner.rb:51:in
run_action' /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:124:inconverge’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/…/lib/chef/runner.rb:118:in each' /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/runner.rb:118:inconverge’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/…/lib/chef/client.rb:304:in
converge' /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/client.rb:106:inrun’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/…/lib/chef/application/client.rb:212:in
run_application' /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application/client.rb:202:inloop’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/…/lib/chef/application/client.rb:202:in
run_application' /usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/../lib/chef/application.rb:62:inrun’
/usr/lib/ruby/gems/1.8/gems/chef-0.9.8/bin/chef-client:26
/usr/bin/chef-client:19:in `load’
/usr/bin/chef-client:19

Running the command manually returns this:

$ sudo /etc/init.d/chef-client restart
warning: chef-client: unable to open supervise/ok: file does not exist

The chef cookbook and it’s dependencies are the latest you can
download from cookbooks.opscode.com. Is the cookbook not creating the
required files for the startup to succeed, or am I trying to get the
chef-client installed as a service in a completely wrong way?

Any help appreciated.

Ringo

I worked around it by upgrading to 0.9.8 and using the
ubuntu-10.04-apt template. I did have to modify it a bit to support
running it from a sudo-capable user though.

Ringo

On 13 August 2010 16:08, Ringo De Smet ringo.desmet@gmail.com wrote:

Hello,

I am using "knife bootstrap" to initialize Chef client on my VMs. My
initial role created some users just to make sure the bootstrap
procedure was working. My latest changeset is to make sure that after
"knife bootstrap", the Chef client is also registered as a system
service (runit style). I added "chef::bootstrap_client" as a recipe in
the initial bootstrap role.