Created
August 19, 2011 21:58
-
-
Save focusaurus/1158126 to your computer and use it in GitHub Desktop.
Chef Recipe
This file contains hidden or 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 'rubygems' | |
require 'json' | |
CONF_PATH = '/tmp/clouddial_conf.json' | |
cookbook_file CONF_PATH do | |
source File.basename CONF_PATH | |
mode '0444' | |
backup false | |
end | |
def install_packages | |
log "Reading package list from JSON at #{CONF_PATH}" | |
conf = JSON.parse IO.read CONF_PATH | |
#TODO we need to support both APT packages and TGZ. | |
#Only handling APT currently | |
packages = conf['packages'].select {|p| p['type'] == 'APT'} | |
package_names = packages.map {|p| p['name']} | |
if conf['post_command'] | |
log "Running post_command: #{conf['post_command']}" | |
system conf['post_command'] | |
end | |
package_names.each do |pkg| | |
package pkg do | |
action :install | |
end | |
end | |
end | |
if File.exist? CONF_PATH | |
install_packages | |
else | |
log "Error: Configuration file #{CONF_PATH} not found." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment