- From: "Moser, Kevin" <
>
- To: Matthew Hooker <
>, Ryan Hass <
>
- Cc: "<
>" <
>
- Subject: [chef-dev] Re: Re: Installing Gems for a LWRP
- Date: Mon, 6 May 2013 18:38:28 +0000
- Accept-language: en-US
I am doing something similar for a a LWRP I am writing and in a helper
library I define the following method:
def install_chef_vault(source="
http://rubygems.org", version="1.2.0")
installed ||= begin
gem_installer = Chef::Resource::ChefGem.new("chef-vault", run_context)
gem_installer.version version
gem_installer.options "--clear-sources --source #{source}"
gem_installer.action :install
gem_installer.after_created
require 'chef-vault'
end
end
Then where I need to know that the gem is installed for use (in other
functions in the library) I just call this method.
It's not perfect yet because you would probably want to parameterize the
source and version but that could be easy enough to do.
Hope that helps!
Kevin
On 5/1/13 10:15 PM, "Matthew Hooker"
<
>
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
>
<
>
>
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
>
>(
)
>
> immediately.
>
>
Archive powered by MHonArc 2.6.16.