Skip to content

Instantly share code, notes, and snippets.

@focusaurus
Created August 19, 2011 21: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 focusaurus/1158126 to your computer and use it in GitHub Desktop.
Save focusaurus/1158126 to your computer and use it in GitHub Desktop.
Chef Recipe
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