Access to chef environment in Rakefile

Hello,

Is there any way to have an access to chef environment, run search etc. from chef-repo’s Rakefile? I’ve noticed that when I need to access search I’m creating a script which I then run via knife exec …. Can I do it somehow directly from Rakefile without shelling-out?

Thanks,
Igor Afonov (http://iafonov.github.com/)

sure... you can use the chef api with your knife config file to get
pretty much everything that you want within your rake task.

require 'chef'
Chef::Config.from_file()

Chef::Node.list
Chef::Node.load(<node_name>).attributex

On Thu, Aug 9, 2012 at 5:44 PM, Igor Afonov afonov@gmail.com wrote:

Hello,

Is there any way to have an access to chef environment, run search etc.
from chef-repo's Rakefile? I've noticed that when I need to access search
I'm creating a script which I then run via knife exec …. Can I do it
somehow directly from Rakefile without shelling-out?

Thanks,
Igor Afonov http://iafonov.github.com/

Thanks! This is exactly what I need.

--
Igor Afonov
Отправлено при помощи Sparrow (http://www.sparrowmailapp.com/?sig)

четверг, 9 августа 2012 г. в 15:39, Ranjib Dey написал:

sure... you can use the chef api with your knife config file to get pretty much everything that you want within your rake task.

require 'chef'
Chef::Config.from_file()

Chef::Node.list
Chef::Node.load(<node_name>).attributex

On Thu, Aug 9, 2012 at 5:44 PM, Igor Afonov <afonov@gmail.com (mailto:afonov@gmail.com)> wrote:

Hello,

Is there any way to have an access to chef environment, run search etc. from chef-repo's Rakefile? I've noticed that when I need to access search I'm creating a script which I then run via knife exec …. Can I do it somehow directly from Rakefile without shelling-out?

Thanks,
Igor Afonov (http://iafonov.github.com/)