Is any one aware of a way to change the gem sources for a chef-client run?
My node of concern is behind a firewall, so I want to replace rubygems.org with an internal Nexus repo (https://github.com/sonatype/nexus-ruby-support). I tried updating the source list for 'chef embedded gem', but the offending chef_gem calls seem to be using a different source list that still refers to rubygems.org.
Managing Gem Sources To list all gem sources, use the -l flag. To remove a gem source, use the r flag followed by the URL of the source to be removed.
The chef_gem and gem_package resources are both used to install Ruby gems. For any machine on which the chef-client is installed, there are two instances of Ruby. One is the standard, system-wide instance of Ruby and the other is a dedicated instance that is available only to the chef-client.
By default, binaries installed by gem will be placed into: /usr/local/lib/ruby/gems/3.1. 0/bin You may want to add this to your PATH.
Publish the new release to RubyGem If you haven't done it already, you will need to create an account at https://rubygems.org/users/new. This last step will take a few seconds to complete. You should receive an email shortly after, confirming that a new release was published.
You can override the source URLs in /root/.gemrc
The format is as follows:
:sources:
- http://your.mirror.com/
The documentation is very spartan, but if you look up the "gem source" command you can eventually hunt this up. Remember that Chef embeds its own gem interpreter, so the gem command used by chef is NOT in the system path.
/opt/chef/embedded/bin/gem sources -r ...
/opt/chef/embedded/bin/gem sources -a "http://mygems.example.com/"
I was on the right path with the initial idea; the gem sources just need to be changed for root, rather than the 'sudo user', and chef-client will pick them up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With