How to start a interactive Chef client just like start a rails by “rails console”?
-
23-03-2021 - |
Question
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?
Solution
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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow