- From: Bryan McLellan <
>
- To:
- Subject: [chef] Re: How to do conditional checks for gem installation?
- Date: Thu, 8 Mar 2012 09:45:16 -0500
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.