Huan
Huan

Reputation: 297

How to start a interactive Chef client just like start a rails by "rails console"?

In chef workstation client, I want to start an interactive console to debug and check the role/recipe, or use search api, e.g.

 chef-client > nodes=search ("node","name:*")
 chef-client > puts "#{nodes}"

...

Just like in rails, use "rails console" to load all your rails environment into irb.

How to do it?

Upvotes: 3

Views: 1513

Answers (1)

David Faber
David Faber

Reputation: 686

The "shef" tool may be what you're looking for, it starts an IRB session in your chef environment where you can do things like search, browse and manipulate your nodes, roles, etc. There's even a debugger to step through your recipes using the "breakpoint" resource.

Here's a real basic example

chef > nodes.list
=> [node[db1-production], node[worker1-production], node[app1-production]]
chef > nodes.show('app1-production').class
 => Chef::Node 

etc.. check out the OpsCode wiki page about it: http://wiki.opscode.com/display/chef/Shef

Upvotes: 7

Related Questions