Created
February 13, 2013 01:21
-
-
Save gmcmillan/4802975 to your computer and use it in GitHub Desktop.
Quick ruby script to download all cookbooks (all versions) from a Chef server.
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
#!/usr/bin/env ruby | |
cookbook_list = `knife cookbook list -a`.split("\n") | |
cookbook_list.each do |line| | |
line.strip! | |
line.match(/^([a-z0-9]+\-[a-z0-9-]+|\w+)\s+(\d\.\d\.\d|.+)$/) | |
name = $1 | |
versions = $2 | |
versions_array = versions.split(" ") | |
versions_array.each do |version| | |
if File.directory?("cookbooks_archived/#{name}-#{version}") | |
puts "Skipping #{name}, version #{version}. Cookbook exists." | |
else | |
puts "Downloading #{name}, version #{version}" | |
`knife cookbook download #{name} #{version} -d cookbooks_archived` | |
end | |
end | |
end |
getting error, can u pls help here
cookbook.rb:12:in block in <main>': undefined method
split' for nil:NilClass (NoMethodError)
from cookbook.rb:6:in each' from cookbook.rb:6:in
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If cookbook has
-
instead of_
its not matchingfor ex:
testing_ca-certs
. may be need to update regex?