Last active
February 2, 2017 17:09
-
-
Save acharlieh/ada96c900ec9e9d37c32455ff6070590 to your computer and use it in GitHub Desktop.
Quick Script to pull versions of all cookbooks from a node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
# Cookbooks from a folder (like when you do a berks vendor) | |
# json = Dir.glob('./*/metadata.json').collect do |file| | |
# Cookbooks from a node cache | |
json = Dir.glob('/var/chef/cache/cookbooks/*/metadata.json').collect do |file| | |
hash = JSON.parse(File.read(file)) | |
{ hash['name'] => hash['version'] } | |
end.reduce({}, :merge).to_json | |
puts json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment