Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Several sets of changes #26

Merged
merged 4 commits into from

2 participants

@temujin9

First commit fixes a bug with rvm::system and mysql::client (which runs gem_package at compile time).

Second commit is a workaround for an internal bug resulting in GID collision between recipes. It's less likely to be generally useful, but probably still worth including.

Third commit fixes an (intermittent?) bug found in first commit.

Fourth commit uses gem_package's native code if ruby_string == 'system', which will be a bit more useful once rvm::gem_package can use multiple environments.

@fnichol
Collaborator

These are great adds and fixes, thanks! There's only one thing I had a question about. I was looking at pushing the rvm gem install into the execute phase to be more in line with the other opscode cookbooks. It looks like most are being updated to clear out these kinds of problems (chef/cookbooks@9597eb7). But you're right that if there are cookbooks running gem_package in the compilation phase then we don't have an RVM environment setup yet.
Other than the mysql cookbook (which looks updated now currently), can you think of other cookbooks with this kind of problem? I'm hoping I can get a few comments back (https://twitter.com/#!/fnichol/status/82127542496149504).
Otherwise, the other commits look ripe for pulling in.

@temujin9

I can see legitimate need for other cookbooks to put gem_package calls in the compile phase, but MySQL's the only cookbook that we encountered this problem with so far.

@fnichol fnichol merged commit 17662f2 into martinisoft:master
@fnichol
Collaborator

Pulled in and updated a couple of things. Mainly:

  • We only need to install RVM in the compilation phase if recipe[rvm::gem_package] is included in the run_list. So default behavior can stay the same, but will be altered on inclusion of the gem_package recipe.
  • The default RVM ruby and list of rubies don't need to be installed in the compilation phase. The RVMRubygems package provider calls the rvm_environment resource just before installing the gem, so whatever RVM ruby/gemset will get "lazily" created on demand at that point.
  • Adding support for multiple rubies in gem_packge's rvm_string parameter meant some adjustments to the fourth commit, but I believe the desired behavior remains.

Thanks again for your help, I think we have a more robust gem_package solution as a result.

@temujin9

My pleasure. Some more bug-fixes on this coming shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 16, 2011
  1. @temujin9

    Updated rvm::default and rvm::system to run steps during compile phas…

    temujin9 authored
    …e, so that rvm::gem_package is compatible with cookbooks that run gem_package during compile phase.
  2. @temujin9

    Added an optional attribute to allow setting group ID (to avoid colli…

    temujin9 authored
    …sion w/ expected GIDs in other cookbooks)
Commits on Jun 17, 2011
  1. @temujin9

    Fixing action[:nothing] bug

    temujin9 authored
  2. @temujin9
This page is out of date. Refresh to see the latest.
View
1  attributes/default.rb
@@ -20,6 +20,7 @@
#
default['rvm']['root_path'] = "/usr/local/rvm"
+default['rvm']['group_id'] = 'default'
default['rvm']['group_users'] = []
default['rvm']['rvmrc'] = Hash.new
View
2  libraries/rvm_rubygems_package.rb
@@ -67,6 +67,8 @@ def ruby_string
def install_package(name, version)
ruby_string_normalized = normalize_ruby_string(ruby_string)
+ super if ruby_string_normalized == 'system'
+ next if ruby_string_normalized == 'system'
# ensure ruby is installed and gemset exists
e = rvm_environment ruby_string_normalized do
View
8 recipes/default.rb
@@ -36,13 +36,17 @@
include_recipe "rvm::system"
+# For more information on the 'action :nothing' and 'run_action(:foo)' usages see
+# http://wiki.opscode.com/display/chef/Evaluate+and+Run+Resources+at+Compile+Time
if node['rvm']['install_rubies'] == true || node['rvm']['install_rubies'] == "true"
# set a default ruby
- rvm_default_ruby node['rvm']['default_ruby']
+ d = rvm_default_ruby node['rvm']['default_ruby']
+ d.run_action(:create)
# install additional rubies
node['rvm']['rubies'].each do |rubie|
- rvm_ruby rubie
+ r = rvm_ruby rubie
+ r.run_action(:install)
end
# install global gems
View
31 recipes/system.rb
@@ -21,6 +21,9 @@
# - http://www.agileweboperations.com/chef-rvm-ruby-enterprise-edition-as-default-ruby/
# - http://github.com/denimboy/xprdev/blob/master/rvm/recipes/default.rb
+# For more information on the 'action :nothing' and 'run_action(:foo)' usages see
+# http://wiki.opscode.com/display/chef/Evaluate+and+Run+Resources+at+Compile+Time
+
script_flags = ""
if node['rvm']['version']
script_flags += " --version #{node['rvm']['version']}"
@@ -44,26 +47,46 @@
end
pkgs.each do |pkg|
- package pkg
+ p = package pkg do
+ action :nothing
+ end
+ p.run_action(:install)
+end
+
+# Build the rvm group ahead of time, if it is set. This allows avoiding
+# collision with later processes which may set a guid explicitly
+if node[:rvm][:group_id] != 'default'
+ g = group 'rvm' do
+ group_name 'rvm'
+ gid node[:rvm][:group_id]
+ action :nothing
+ end
+ g.run_action(:create)
end
-execute "install system-wide RVM" do
+i = execute "install system-wide RVM" do
user "root"
command <<-CODE
bash -c "bash <( curl -Ls #{node['rvm']['installer_url']} )#{script_flags}"
CODE
not_if rvm_wrap_cmd(%{type rvm | head -1 | grep -q '^rvm is a function$'})
+ action :nothing
end
+i.run_action(:run)
-template "/etc/rvmrc" do
+t = template "/etc/rvmrc" do
source "rvmrc.erb"
owner "root"
group "rvm"
mode "0644"
+ action :nothing
end
+t.run_action(:create)
-execute "upgrade RVM to #{upgrade_strategy}" do
+u = execute "upgrade RVM to #{upgrade_strategy}" do
user "root"
command rvm_wrap_cmd(%{rvm get #{upgrade_strategy}})
only_if { %w{ latest head }.include? upgrade_strategy }
+ action :nothing
end
+u.run_action(:run)
Something went wrong with that request. Please try again.