问题
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