Martin Alfke
2011-Nov-25 14:21 UTC
[Puppet Users] Is package gem and provider gem usage in one puppet run possible?
Hi, we want to install the ruby-gem package on a Debian system using puppet. package { ''ruby1.9.1'': ensure => present } In another manifest we want to use the gem provider to install a ruby gem. package { ''bundler'': ensure => present, provider => gem } On the first run the puppet agent run checks for a functional gem binary on the system. It will not find gem installed and claims gem provider to be unusable. On the second run puppet now finds the gem provider. Is there any known method which will allow us to use gem provider also on the first puppet run? Note1: Using stages will not solve this. Note2: We would not like to execute a puppet restart after ruby1.9.1 package installation. Thank you, Kind regards, Martin -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
windowsrefund
2011-Nov-25 14:40 UTC
[Puppet Users] Re: Is package gem and provider gem usage in one puppet run possible?
I came across a similar chicken/egg scenario when I was writing a custom package provider which needed to leverage a gem that I knew did not exist on the system. Here''s how I solved it in my provider: def gem_dependency(name, package nil) raise Puppet::Error, "Required ''name'' argument must be a string." unless name.is_a? String package = name if package.nil? begin require "#{name}" rescue LoadError begin puppet_package_provider(package, "gem") rescue Exception puppet_package_provider(package, "gem", "http:// gems.rubyforge.org") end Gem.clear_paths retry end end # Installs a package with Puppet # source should not be required so the provider can use its configured default(s) def puppet_package_provider(package, provider, source nil) if source.nil? ppp = Puppet::Type.type(:package).new(:name => "#{package}", :provider => provider).provider else ppp = Puppet::Type.type(:package).new(:name => "#{package}", :provider => provider, :source => source).provider end ppp.install if ppp.properties[:ensure] == :absent end Then in my install method... def install gem_dependency(''sys/filesystem'', ''sys-filesystem'') end The magic happens with the call to Gem.clear_paths Best, Adam -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Luke Bigum
2011-Nov-25 14:46 UTC
Re: [Puppet Users] Is package gem and provider gem usage in one puppet run possible?
I believe this is covered in Feature #6907, which has had a bit of activity of late so may be coming soon. Feel free to "Watch" the issue for it to gain priority. On 25/11/11 14:21, Martin Alfke wrote:> Hi, > > we want to install the ruby-gem package on a Debian system using puppet. > package { ''ruby1.9.1'': ensure => present } > > In another manifest we want to use the gem provider to install a ruby gem. > package { ''bundler'': ensure => present, provider => gem } > > On the first run the puppet agent run checks for a functional gem binary on the system. > It will not find gem installed and claims gem provider to be unusable. > On the second run puppet now finds the gem provider. > > Is there any known method which will allow us to use gem provider also on the first puppet run? > > Note1: Using stages will not solve this. > Note2: We would not like to execute a puppet restart after ruby1.9.1 package installation. > > Thank you, > > Kind regards, > > Martin >-- Luke Bigum Information Systems +44 (0) 20 3192 2520 Luke.Bigum@lmax.com | http://www.lmax.com LMAX, Yellow Building, 1A Nicholas Road, London W11 4AN The information in this e-mail and any attachment is confidential and is intended only for the named recipient(s). The e-mail may not be disclosed or used by any person other than the addressee, nor may it be copied in any way. If you are not a named recipient please notify the sender immediately and delete any copies of this message. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. Any view or opinions presented are solely those of the author and do not necessarily represent those of the company. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
madAndroid
2011-Nov-28 13:47 UTC
[Puppet Users] Re: Is package gem and provider gem usage in one puppet run possible?
I''m not 100% sure if this works as you would expect in your manifests, but I''ve used something like this to build a redmine class: class ruby-gems::install { package { ''ruby1.9.1'': ensure => present } } class bundler::install { Package { require => Class [ruby-gems::install], before => Class [ruby-gems::install], } package { ''bundler'': ensure => present, provider => gem } } Would be interested in how you ended up resolving this though ... On Nov 25, 2:21 pm, Martin Alfke <tux...@gmail.com> wrote:> Hi, > > we want to install the ruby-gem package on a Debian system using puppet. > package { ''ruby1.9.1'': ensure => present } > > In another manifest we want to use the gem provider to install a ruby gem. > package { ''bundler'': ensure => present, provider => gem } > > On the first run the puppet agent run checks for a functional gem binary on the system. > It will not find gem installed and claims gem provider to be unusable. > On the second run puppet now finds the gem provider. > > Is there any known method which will allow us to use gem provider also on the first puppet run? > > Note1: Using stages will not solve this. > Note2: We would not like to execute a puppet restart after ruby1.9.1 package installation. > > Thank you, > > Kind regards, > > Martin-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.