[chef-dev] Re: Re: Re: Re: Installing Gems for a LWRP


Chronological Thread 
  • From: Brandon Martin < >
  • To: Ryan Hass < >
  • Cc: " " < >
  • Subject: [chef-dev] Re: Re: Re: Re: Installing Gems for a LWRP
  • Date: Thu, 2 May 2013 17:02:05 -0700

I wouldn't call it 'proper' or even arguably less ugly than the cb dependency route, but it works.  This assumes the gem is already available in your current sources, otherwise you'll need to add a known good source to Gem.sources as well or it will bail..  You would also need to modify this if you had dependencies to said 'miraclegem' with other sources.

# DISCLAIMER:: PseudoRuby(tm)
# **may not actually work as-is  
begin
  Gem::Specification.find_by_name('miraclegem', '>= 1.0.0')
rescue Gem::LoadError
  ::Chef::Log.info("Missing the miraclegem Gem.  Installing...")
  require 'rubygems/dependency_installer'
  Gem::DependencyInstaller.new(Gem::DependencyInstaller::DEFAULT_OPTIONS).install('miraclegem')
end

require 'miraclegem'

hope that helps a bit..

Brandon



On Thu, May 2, 2013 at 3:15 PM, Ryan Hass < " target="_blank"> > wrote:
I tried this for my LWRP, but the issue I have is the first execution results in an error being thrown due to the gem not being installed until after the node is converged. It seems like I may have to create a cookbook with the sole purpose of installing the required gem, and force the openssl cookbook to have a dependency on said cookbook; but doing so is pretty ugly.

-Ryan H.


On 05/02/2013 02:19 AM, Julian Dunn wrote:
Ditto what he said, but check out what we do in the AWS cookbook.


Granted this is a library, so adapt as needed.

- Julian

Sent from my smartphone. Sorry about any typos.

On May 2, 2013, at 1:15 AM, Matthew Hooker < " target="_blank"> > wrote:

That's difficult. I've found the easiest way is to put the onus of the dependency on the client of your lwrp

Plaese forgive typos -- sent via phone

On May 1, 2013, at 20:55, Ryan Hass < " target="_blank"> > wrote:

Hello,

I am working on implementing COOK-847, and have encountered a
chicken-and-egg problem. I need to install the certificate_authority
gem; normally I would simply call chef_gem for something like this.
However, since the default recipe is likely to be executed after the
provider I am not able to do this. I also am unable to find a standard
Mixin for chef_gem in Chef 11.x.

What is the correct way to install a gem for Chef to use so I can
require it in my provider?

-Ryan H.
This electronic message contains information which may be confidential or privileged. The information is intended for the use of the individual or entity named above. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic transmission in error, please notify us by e-mail at ( " target="_blank"> ) immediately.


This electronic message contains information which may be confidential or privileged. The information is intended for the use of the individual or entity named above. If you are not the intended recipient, be aware that any disclosure, copying, distribution or use of the contents of this information is prohibited. If you have received this electronic transmission in error, please notify us by e-mail at ( " target="_blank"> ) immediately.





Archive powered by MHonArc 2.6.16.

§