Skip to content

Instantly share code, notes, and snippets.

@mmzyk
Last active December 10, 2015 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmzyk/4505785 to your computer and use it in GitHub Desktop.
Save mmzyk/4505785 to your computer and use it in GitHub Desktop.
A script to test uploading of cookbooks to Hosted Chef
#!/usr/bin/env ruby
NoteOnUsage = <<USAGE
This script allows you to upload multiple cookbooks automatically.
Use -d to download the cookbooks
Use -p to purge cookbooks
Using either option will require some user input
In the cookbooks string array, replace the list with the cookbooks
you want to use
This assumes you have a working knife setup with a valid config
and valid hosted account
USAGE
purge = false
download = false
ARGV.each do |arg|
if arg == "-p"
purge = true
end
if arg == "-d"
download = true
end
end
cookbooks = %w{apache2 build-essential ucspi-tcp daemontools unicorn bluepill djbdns}
if purge
cookbooks.each do |cookbook|
system("knife cookbook delete -p -a #{cookbook}")
end
end
if download
cookbooks.each do |cookbook|
system("knife cookbook site download #{cookbook}")
system("knife cookbook site install #{cookbook}")
end
end
cookbooks.each do |cookbook|
system("knife cookbook upload #{cookbook} -VV")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment