Skip to content

Instantly share code, notes, and snippets.

@sean-horn
Created February 7, 2013 16:37
Show Gist options
  • Save sean-horn/4732213 to your computer and use it in GitHub Desktop.
Save sean-horn/4732213 to your computer and use it in GitHub Desktop.
Example cookbook Ruby code to show all versions of all cookbooks for the _default env
log "---writing all ckbks and version---"
require 'rest_client'
env = "_default"
num_versions = "num_versions=all"
api_endpoint = env ? "/environments/#{env}/cookbooks?#{num_versions}" : "/cookbooks?#{num_versions}"
r = Chef::REST.new(Chef::Config[:chef_server_url])
cookbook_versions = r.get_rest(api_endpoint)
log "#{cookbook_versions}"
log "---End writing all ckbks and version---"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment