[chef] Re: Re: How to do conditional checks for gem installation?


Chronological Thread 
  • From: Sachin Sagar Rai < >
  • To:
  • Subject: [chef] Re: Re: How to do conditional checks for gem installation?
  • Date: Thu, 8 Mar 2012 20:48:21 +0545

@Bryan

Yup, I want to use the gem immediately as well.
So, did u mean to wrap as the following:


    gems = %w(aws-sdk gist)
    gems.each do |name|
      gem_package name do
        version node["dev_tools"]["#{name}_version"]
        not_if "true"
      end
      if !system('false')
        r.run_action(:install)
      end
    end



-------------------------------------------
@millisami
~ Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.tumblr.com
Sent with Sparrow

On Thursday, March 8, 2012 at 8:30 PM, Bryan McLellan wrote:

On Thu, Mar 8, 2012 at 4:46 AM, Sachin Sagar Rai < "> > wrote:
Following installs the ruby gems on each chef-client run.

gems = %w(aws-sdk gist)
gems.each do |name|
  r = gem_package name do
    version node["dev_tools"]["#{name}_version"]
    action :nothing
  end

  r.run_action(:install)
end

How to apply the `not_if` conditional checking for the
`r.run_action(:install)` action?

As I mentioned in the other email thread, this pattern is a bit of a
kludge to install the gem immediately so they can be used in a Chef
recipe, and the pattern is replaced with chef_gem in the next version
of Chef. If you don't need to use the gem in the Chef recipe, use the
standard pattern:

gems = %w(aws-sdk gist)
gems.each do |name|
  gem_package name do
    version node["dev_tools"]["#{name}_version"]
    not_if "true"
  end
end

If you do need them immediately you could use the existing kludge
pattern but wrap the call to run_action in a conditional:

if !system('false')
r.run_action(:install)
end

Bryan




Archive powered by MHonArc 2.6.16.

§