[chef] Re: Re: Listing all cookbooks used in an environment


Chronological Thread 
  • From: DV < >
  • To:
  • Subject: [chef] Re: Re: Listing all cookbooks used in an environment
  • Date: Wed, 8 May 2013 11:35:03 -0700

Thanks :) I gave it a try and so far after correcting syntax errors it's saying that there's no recipes attribute for the array (n, I guess), so I'll have to look into that.


On Mon, May 6, 2013 at 4:01 PM, Ranjib Dey < " target="_blank"> > wrote:
try something like this,
check for syntax . i havent run this :-)


On Mon, May 6, 2013 at 3:43 PM, DV < " target="_blank"> > wrote:
Hey all,

So I've been trying to write a script which will show me which cookbooks are used in an environment that are not version-locked.

I thought I have it all figured out, with the following command fetching a list of cookbooks used in an environment. It collects "recipes" attribute of all nodes in the environment and extracts cookbook names:

knife search node "chef_environment:${CHEF_ENVIRONMENT}" -a recipes| grep -v -e ^id -e ^recipes -e found$ -e ^$ | awk -F':' '{print $1}' | sed 's/^ *//; s/; */;/g' |sort|uniq

The command does its job, but it has a major downside: it doesn't list cookbooks that are not explicitly listed in the "recipes" attribute. So, for example, if "tomcat" cookbook calls "java" cookbook, and "tomcat" cookbook is assigned to some node in the environment, the command above will list "tomcat" but not "java".

Is there a better way to fetch a list of cookbooks? Or should I add logic to resolve cookbook dependencies? Thanks.

--
Best regards, Dmitriy V.




--
Best regards, Dmitriy V.



Archive powered by MHonArc 2.6.16.

§