[chef] Re: calling knife inside a chef recipe ? or a better solution


Chronological Thread 
  • From: Ranjib Dey < >
  • To:
  • Subject: [chef] Re: calling knife inside a chef recipe ? or a better solution
  • Date: Mon, 10 Feb 2014 15:11:43 -0800

you can use the search method in recipe to get the list of hosts (and save it in a file if you want), and pass it to the consumer script. also any script with read access to to the chef client can search chef server and obtain the list independently .


following is sample ruby code

require 'chef'
Chef::Config.from_file '/etc/chef/client.rb'
q = Chef::Search::Query.new
q.search(:node, '*:*')

cheers
ranjib


On Mon, Feb 10, 2014 at 3:03 PM, Manoj Thakkar < " target="_blank"> > wrote:
Hi,

Here is my scenario, i have list of servers in my clusterA , i want to provide that list of servers to a script , 

the script will then read this list( of servers)  and will do some action on a file, basically add/remove entires of those hosts in the file.

How can i achieve this, i can create this list dynamically using the knife search query from a recipe and then put the output in a file , but i have to have knife installed on all nodes then correct ?

Or i can run this knife query from outside on the chef server  put the output in the cookbook file folder , that also is a process breaker as i have to run it on the server first then do the other stuff .


Is there a better way to handle this scenario , Please advise.

Thanks
Manoj




Archive powered by MHonArc 2.6.16.

§