[chef] Re: Re: how could I use knife programmatically in a ruby script?


Chronological Thread 
  • From: Bryan Berry < >
  • To:
  • Subject: [chef] Re: Re: how could I use knife programmatically in a ruby script?
  • Date: Wed, 23 Nov 2011 19:11:37 +0100

Thanks btm, I was.aware of knife exec but didn't know that it had access to all of chefs API and the node object

On Nov 23, 2011 6:24 PM, "Bryan McLellan" < "> > wrote:
On Wed, Nov 23, 2011 at 12:14 PM, Bryan Berry < "> > wrote:
> Instead of shelling out to knife each time, could I just require 'Chef',
> initialize a few values, and work from there?

You could use Chef as a library. Some people use knife as a library,
which is discouraged because it is a client that uses the chef library
itself, but I understand why.

For something simple like this, you should use 'knife exec'

http://wiki.opscode.com/display/chef/Knife+Exec
http://blog.loftninjas.org/2010/12/29/knife-one-liners/
http://blog.loftninjas.org/2011/01/12/knife-reporting-apt-updates/

Bryan



Archive powered by MHonArc 2.6.16.

§