Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get list of installed cookbooks along with their version

Tags:

chef-infra

I have a server that has been provisioned via chef. Now I like to know exactly which cookbook versions have been installed on this server.

Being a chef-newbee, I worked around using grep like the following, but I like to know whether or not there is some official way of getting that information.

sudo grep -E '^version|"version":' /var/chef/cache/cookbooks/*/metadata*

Is there a chef command that lists all the installed cookbooks along with their versions?

like image 854
muhqu Avatar asked Mar 17 '23 02:03

muhqu


2 Answers

Try the following:

knife cookbook list | awk '{printf "knife cookbook show %s\n",$1}'| bash

Will print out the versions associated with each cookbook. For example:

java   1.31.0  1.29.0
mysql   6.0.22  6.0.21
rbac   1.0.3
smf   2.2.6
yum   3.6.0
yum-mysql-community   0.1.17
like image 134
Mark O'Connor Avatar answered Apr 06 '23 11:04

Mark O'Connor


Variation on some of the above.

sudo grep -o -e '\"version\"\:\"[a-zA-Z0-9.]*\"' -e '\"version\"\: \"[a-zA-Z0-9.]*\"' /var/chef/cache/cookbooks/*/metadata.json
like image 30
Saedar Avatar answered Apr 06 '23 10:04

Saedar