Created
October 10, 2012 06:28
-
-
Save jeremyolliver/3863488 to your computer and use it in GitHub Desktop.
Fix rbenv chef recipe issues downloading .tar.gz files from ruby-lang.org
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
# attributes/default.rb | |
default[:ruby][:version] = '1.9.3-p194' | |
default[:ruby][:global_version] = false |
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
# files/default/curlrc | |
# This prevents the gzip file from deflating into an uncompressed version when downloading gzip files | |
header "Accept-Encoding: gzip" |
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
# libraries/chef_mixin_rbenv.rb | |
# We'll monkey patch to insert $HOME, which we need for $HOME/.curlrc overrides | |
require 'chef/mixin/shell_out' | |
class Chef | |
module Mixin | |
module Rbenv | |
def shell_out(*command_args) | |
last_arg = command_args[-1] | |
if last_arg.is_a?(Hash) || last_arg.is_a?(Mash) | |
command_args[-1] = Chef::Mixin::DeepMerge.deep_merge!({:env => {'HOME' => '/home/rbenv'}}, command_args[-1]) | |
end | |
super(*command_args) | |
end | |
end | |
end | |
end |
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
# recipes/default.rb | |
# Fix .tar.gz download | |
directory "/home/rbenv" do | |
owner 'rbenv' | |
group 'rbenv' | |
mode '0711' | |
end | |
cookbook_file "/home/rbenv/.curlrc" do | |
source "curlrc" | |
owner 'rbenv' | |
group 'rbenv' | |
mode "0755" | |
end | |
# End fix .tar.gz download | |
# Install ruby as per usual with rbenv cookbook e.g.: | |
rbenv_ruby node[:ruby][:version] do | |
ruby_version node[:ruby][:version] | |
force true # Use force and checking if file exists to ensure errors within compiling are retried | |
global true if node[:ruby][:global_version] # Passenger can only run one ruby version | |
not_if { File.exists?("#{node[:rbenv][:install_prefix]}/rbenv/versions/#{node[:ruby][:version]}/bin/ruby") } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment