Get list of installed cookbooks along with their version

风流意气都作罢 提交于 2019-12-10 21:32:40

问题


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?


回答1:


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



回答2:


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



回答3:


First of all there is no oficial chef way to get list of cookbooks versions installed.

But you can use such tools as berkshelf or librarian-chef, put all cookbooks you need.




回答4:


This worked for me on CentOS 6.6:

for filename in `ls /var/cache/chef/cookbooks`; \
do \
    echo -n "$filename "; \
    grep version /var/cache/chef/cookbooks/$filename/metadata.rb; \
done | column -t



来源:https://stackoverflow.com/questions/30188856/get-list-of-installed-cookbooks-along-with-their-version

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!