Whenever I run ‘kitchen converge’, the “Installing Cookbook Gems:” part takes pretty long time to pass.
I tried using a proxy configuring .kitchen.yml as follow
and added following script in the install_chef_script.sh to make embedded ruby gem refers that file after installing chef client.
sudo bash -c “cat << EOF > /opt/chef/embedded/etc/gemrc
gem: --no-ri --no-rdoc
But after that, it still takes long time connecting the proxy server but downloading gem files using https://rubygems.org/ which doesn’t cache contents. I expect it will be faster when using http since the proxy(squid) caches contents when used with http.
Is there some way to configure ‘sources’ repos for embedded ruby gem to change the default one with ‘http’? or Is there someone who knows better approach to solve this problem?
While you can technically use the
rubygems_url config option in your client.rb or solo.rb to change this, I should point out that like most websites, rubygems.org no longer allows non-HTTPS requests so you’ll just get redirected anyway. If you need to run an internal mirror, I would do that and then point
rubygems_url at that instead.
That’s good to know that http request is being redirected. I guess I should probably setup a local mirror as you said.
Thank you for your advice!
How do you stop “Installing Cookbook Gems” running at all? If we know that then it’s possible to create a timestamp file that will restrict it to running eg once per day.
There isn’t really a way to disable the installing of gems if they are set in
metadata.rb of a cookbook as this is an in-built feature of chef-client. At least nothing short of making sure that no cookbooks in a given dependency tree utilize this feature so that it would be effectively a no-op.
FYI: Using Vagrant + VMWare Fusion I have super slow DNS resolving for SRV records which are used by rubygems. As you are using test-kitchen, maybe you have the same issue? Details at https://github.com/chef/bento/issues/941 - usually circumventing the VMWare Fusion DNS proxy by using Google DNS or any other speeds up any rubygems taks.