Rerunnable and idempotent?

Re-running bootstrap::server fails if rabbitmq-server was already started by
previous installation.

Should we expect chef recipes to be re-runnable and idempotent? I would
suggest a call to start a service should not error out if the service is
already running.

thanks,

Mike

root@ip-10-160-81-191:~# cat solo.rb
file_cache_path "/tmp/chef-solo"
cookbook_path "/tmp/chef-solo/cookbooks"
recipe_url "http://s3.amazonaws.com/chef-solo/bootstrap-latest.tar.gz"
root@ip-10-160-81-191:~# cat chef.json
{
“bootstrap”: {
“chef”: {
“url_type”: “http”,
“init_style”: “runit”,
“path”: “/srv/chef”,
“serve_path”: “/srv/chef”,
“server_fqdn”: “chef.failmode.com”,
“webui_enabled”: true
}
},
“run_list”: [ “recipe[bootstrap::server]” ]

root@ip-10-160-81-191:~# chef-solo -c ~/solo.rb -j ~/chef.json
[Sat, 03 Apr 2010 14:30:50 +0000] INFO: Starting Chef Solo Run
[Sat, 03 Apr 2010 14:31:12 +0000] ERROR: service[rabbitmq-server]
(/tmp/chef-solo/cookbooks/rabbitmq_chef/recipes/default.rb line 45) had an
error:
/etc/init.d/rabbitmq-server start returned 1, expected 0
/usr/lib/ruby/gems/1.8/gems/chef-0.8.10/bin/…/lib/chef/mixin/command.rb:179:in
handle_command_failures' /usr/lib/ruby/gems/1.8/gems/chef-0.8.10/bin/../lib/chef/mixin/command.rb:122:inrun_command’
/usr/lib/ruby/gems/1.8/gems/chef-0.8.10/bin/…/lib/chef/provider/service/init.rb:37:in
start_service' /usr/lib/ruby/gems/1.8/gems/chef-0.8.10/bin/../lib/chef/provider/service.rb:62:inaction_start’

This is a question of what the return code from rabbitmq-server is -
in this case, the rabbitmq-server start command returns a non-zero
status code, which we (by neccesity) treat as an error.

We can (and will) change the resource so that this is worked around,
but the real bug is in the rabbitmq-server init script.

Adam

Sent from my iPhone

On Apr 3, 2010, at 7:38 AM, Mike Bailey mike@bailey.net.au wrote:

Re-running bootstrap::server fails if rabbitmq-server was already
started by previous installation.

Should we expect chef recipes to be re-runnable and idempotent? I
would suggest a call to start a service should not error out if the
service is already running.

thanks,

Mike

root@ip-10-160-81-191:~# cat solo.rb
file_cache_path "/tmp/chef-solo"
cookbook_path "/tmp/chef-solo/cookbooks"
recipe_url "http://s3.amazonaws.com/chef-solo/bootstrap-latest.tar.gz"
root@ip-10-160-81-191:~# cat chef.json
{
"bootstrap": {
"chef": {
"url_type": "http",
"init_style": "runit",
"path": "/srv/chef",
"serve_path": "/srv/chef",
"server_fqdn": "chef.failmode.com",
"webui_enabled": true
}
},
"run_list": [ "recipe[bootstrap::server]" ]

root@ip-10-160-81-191:~# chef-solo -c ~/solo.rb -j ~/chef.json
[Sat, 03 Apr 2010 14:30:50 +0000] INFO: Starting Chef Solo Run
[Sat, 03 Apr 2010 14:31:12 +0000] ERROR: service[rabbitmq-server] (/
tmp/chef-solo/cookbooks/rabbitmq_chef/recipes/default.rb line 45)
had an error:
/etc/init.d/rabbitmq-server start returned 1, expected 0
/usr/lib/ruby/gems/1.8/gems/chef-0.8.10/bin/../lib/chef/mixin/
command.rb:179:in handle_command_failures' /usr/lib/ruby/gems/1.8/gems/chef-0.8.10/bin/../lib/chef/mixin/ command.rb:122:in run_command'
/usr/lib/ruby/gems/1.8/gems/chef-0.8.10/bin/../lib/chef/provider/
service/init.rb:37:in start_service' /usr/lib/ruby/gems/1.8/gems/chef-0.8.10/bin/../lib/chef/provider/ service.rb:62:in action_start'

I'm glad to hear that the intention is for recipes to be idempotent and
re-runnable.

Deprec had a similar issue with nginx's start script. For that case I chose
to ignore the return code although a better solution might be to check the
service status.

  • Mike

On Sun, Apr 4, 2010 at 2:49 AM, Adam Jacob adam@opscode.com wrote:

This is a question of what the return code from rabbitmq-server is - in
this case, the rabbitmq-server start command returns a non-zero status code,
which we (by neccesity) treat as an error.

We can (and will) change the resource so that this is worked around, but
the real bug is in the rabbitmq-server init script.

Adam

Sent from my iPhone

On Apr 3, 2010, at 7:38 AM, Mike Bailey mike@bailey.net.au wrote:

Re-running bootstrap::server fails if rabbitmq-server was already started
by previous installation.

Should we expect chef recipes to be re-runnable and idempotent? I would
suggest a call to start a service should not error out if the service is
already running.

thanks,

Mike

root@ip-10-160-81-191:~# cat solo.rb
file_cache_path "/tmp/chef-solo"
cookbook_path "/tmp/chef-solo/cookbooks"
recipe_url " http://s3.amazonaws.com/chef-solo/bootstrap-latest.tar.gz
http://s3.amazonaws.com/chef-solo/bootstrap-latest.tar.gz"
root@ip-10-160-81-191:~# cat chef.json
{
"bootstrap": {
"chef": {
"url_type": "http",
"init_style": "runit",
"path": "/srv/chef",
"serve_path": "/srv/chef",
"server_fqdn": " http://chef.failmode.comchef.failmode.com",
"webui_enabled": true
}
},
"run_list": [ "recipe[bootstrap::server]" ]

root@ip-10-160-81-191:~# chef-solo -c ~/solo.rb -j ~/chef.json
[Sat, 03 Apr 2010 14:30:50 +0000] INFO: Starting Chef Solo Run
[Sat, 03 Apr 2010 14:31:12 +0000] ERROR: service[rabbitmq-server]
(/tmp/chef-solo/cookbooks/rabbitmq_chef/recipes/default.rb line 45) had an
error:
/etc/init.d/rabbitmq-server start returned 1, expected 0
/usr/lib/ruby/gems/1.8/gems/chef-0.8.10/bin/../lib/chef/mixin/command.rb:179:in
handle_command_failures' /usr/lib/ruby/gems/1.8/gems/chef-0.8.10/bin/../lib/chef/mixin/command.rb:122:in run_command'
/usr/lib/ruby/gems/1.8/gems/chef-0.8.10/bin/../lib/chef/provider/service/init.rb:37:in
start_service' /usr/lib/ruby/gems/1.8/gems/chef-0.8.10/bin/../lib/chef/provider/service.rb:62:in action_start'