It sounds like you might want to update the gem source during the compile phase of the chef-client run. The client runs in two phases: (1) compile phase that determines all recipes/resources to run with necessary attribute values, and (2) execution phase
that actually performs the specific actions.
Try:
execute 'add_rubygems.org_gemrepo' do
action :nothing
command '/usr/bin/gem sources --add https://rubygems.org/'
end.run_action(:run)
Add this before your gem_package resource and it will update the gem sources during the compile phase (1), then install the gem during the execution phase (2).
This blog post has some additional information that might be useful, https://www.getchef.com/blog/2013/09/04/demystifying-common-idioms-in-chef-recipes/.
Curtis Consultant Skype cstewart8710
Cloud Migration - Architecture - DevOps - Big Data - App Dev
From: DV <
>
Sent: Wednesday, October 8, 2014 5:27 PM To: Subject: [chef] gem sources chicken & egg problem Hi guys,
Thought I'd get your advice on the following:
I have chef-client run fail on the initial (only) run due to host's default gem sources not having the version of gem chef-client is trying to install. To be more specific, it's passenger gem from passenger_apache2::source cookbook here: gem_package "passenger" do
version node['passenger']['version']
end
The default gem sources on the host simply don't have passenger gem and/or its dependencies so of course it fails.
My goal is to make chef-client aware of an additional gem source at first run. So far I've tried the following:
execute 'add_rubygems.org_gemrepo' do
action :run
command '/usr/bin/gem sources --add https://rubygems.org/'
end
I see the code being executed on chef-client run, nevertheless, first chef-client run fails to find passenger gem. So there must be some caching going on that I need to override.
All further chef-client runs succeed, though.
So my question is, how can I make chef-cilent aware of additional gem sources on its very first run?
Best regards, Dmitriy V. |
Archive powered by MHonArc 2.6.16.