Puppet: System Administration Automated

Support

Ticket #992 (closed enhancement: fixed)

Opened 11 months ago

Last modified 9 months ago

puppet doesn't seem to support rubygems 1.0.1

Reported by: kelp Assigned to: community
Priority: normal Milestone: 0.24.2
Component: client Version: 0.23.1
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Attached Patches: None Complexity: Unknown

Description (Last modified by luke)

It looks like rubygems 1.0.1 changes some things breaking puppets gem provider:

Puppet always fails to find installed gems:

# /usr/bin/gem install -v 1.0.6 --include-dependencies flvtool2

Then from the puppet run:

debug: package provider gem: Executing '/usr/bin/gem list --local flvtool2'
warning: Could not match

debug: //snvl-b-app96/ilike/Package[flvtool2]: Changing ensure
debug: //snvl-b-app96/ilike/Package[flvtool2]: 1 change(s)
debug: package provider gem: Executing '/usr/bin/gem install -v 1.0.6 --include-dependencies flvtool2'
notice: //snvl-b-app96/ilike/Package[flvtool2]/ensure: created

So it will reinstall every gem every run. Obvious workaround is not upgrade rubygems. I'm not sure yet what version introduced the behavior that breaks things.

Change History

01/28/08 04:49:49 changed by luke

  • stage changed from Unreviewed to Accepted.
  • description changed.
  • milestone set to 0.24.2.

Can you paste in the output from the gem command it's not matching?

02/07/08 21:05:17 changed by josb

The problem is that the output of the 'gem list' command changed in recent versions of Ruby Gems?. The following patch (against 0.23.2) seems to fix things for me with Ruby Gems? 1.0.1; both installing a new gem and upgrading an existing gem now work.

--- /usr/lib/ruby/site_ruby/1.8/puppet/provider/package/gem.rb.orig     2008-02-07 14:58:21.000000000 -0500
+++ /usr/lib/ruby/site_ruby/1.8/puppet/provider/package/gem.rb  2008-02-07 15:02:13.000000000 -0500
@@ -23,7 +23,7 @@
         end
 
         begin
-            list = execute(command).split("\n\n").collect do |set|
+            list = execute(command).split(/\n\n?/).collect do |set|
                 if gemhash = gemsplit(set)
                     gemhash[:provider] = :gem
                     gemhash
@@ -44,8 +44,8 @@
 
     def self.gemsplit(desc)
         case desc
-        when /^\*\*\*/: return nil
-        when /^(\S+)\s+\((.+)\)\n/
+        when /^\*\*\*/, /^\s*$/: return nil
+        when /^(\S+)\s+\((.+)\)/
             name = $1
             version = $2.split(/,\s*/)[0]
             return {

02/08/08 19:41:17 changed by josb

Slightly better patch. We can just split on single newlines since empty lines are removed by the .compact.

--- /usr/lib/ruby/site_ruby/1.8/puppet/provider/package/gem.rb.orig     2008-02-07 14:58:21.000000000 -0500
+++ /usr/lib/ruby/site_ruby/1.8/puppet/provider/package/gem.rb  2008-02-08 13:29:50.000000000 -0500
@@ -23,14 +23,14 @@
         end
 
         begin
-            list = execute(command).split("\n\n").collect do |set|
+            list = execute(command).split("\n").collect do |set|
                 if gemhash = gemsplit(set)
                     gemhash[:provider] = :gem
                     gemhash
                 else
                     nil
                 end
-            end.reject { |p| p.nil? }
+            end.compact
         rescue Puppet::ExecutionFailure => detail
             raise Puppet::Error, "Could not list gems: %s" % detail
         end
@@ -44,8 +44,8 @@
 
     def self.gemsplit(desc)
         case desc
-        when /^\*\*\*/: return nil
-        when /^(\S+)\s+\((.+)\)\n/
+        when /^\*\*\*/, /^\s*$/: return nil
+        when /^(\S+)\s+\((.+)\)/
             name = $1
             version = $2.split(/,\s*/)[0]
             return {

02/09/08 02:14:52 changed by luke

Does this work with older versions of gems?

02/09/08 04:58:55 changed by josb

I don't have a good way to test 0.9.4 or earlier (reinstalling 0.9.4 causes the gem command to bomb) but I believe that with the slight change below things should work. The additional change is to ignore lines that start with one or more spaces, which earlier Ruby Gems? versions use to show the description of each gem when given the 'gem list' command. (Too bad there's no 'gem list --yaml'.)

--- /usr/lib/ruby/site_ruby/1.8/puppet/provider/package/gem.rb.orig     2008-02-07 14:58:21.000000000 -0500
+++ /usr/lib/ruby/site_ruby/1.8/puppet/provider/package/gem.rb  2008-02-08 22:41:38.000000000 -0500
@@ -23,14 +23,14 @@
         end
 
         begin
-            list = execute(command).split("\n\n").collect do |set|
+            list = execute(command).split("\n").collect do |set|
                 if gemhash = gemsplit(set)
                     gemhash[:provider] = :gem
                     gemhash
                 else
                     nil
                 end
-            end.reject { |p| p.nil? }
+            end.compact
         rescue Puppet::ExecutionFailure => detail
             raise Puppet::Error, "Could not list gems: %s" % detail
         end
@@ -44,8 +44,8 @@
 
     def self.gemsplit(desc)
         case desc
-        when /^\*\*\*/: return nil
-        when /^(\S+)\s+\((.+)\)\n/
+        when /^\*\*\*/, /^\s*$/, /^\s+/; return nil
+        when /^(\S+)\s+\((.+)\)/
             name = $1
             version = $2.split(/,\s*/)[0]
             return {

02/12/08 00:28:27 changed by pobrien

I was able to test with 0.9.4 and it worked without issue for me.

02/13/08 23:31:02 changed by luke

  • status changed from new to closed.
  • resolution set to fixed.

applied in [9b1bfc1].