Unable to install Chef gems during chef-clien run - ruby

I am working on a chef environment with below versions
OS & Version details are as below:
Chef Server - RHEL7
Chef Workstation - Windows 7 Professional
Chef node : Windows 2016 Server Datacenter
Chef Development Kit Version: 3.3.23
chef-client version: 14.14.25
berks version: 7.0.6
kitchen version: 1.23.2
inspec version: 2.2.112
I am running a chef-client on a node which is configured during initial run installing chef gems failed with below errors.
On checking it was not able to connect to ruby site to install gems, but my server has active internet connection. I got these details from Bundle Install Not Working
Installing Cookbook Gems:
Running handlers:
[2019-10-17T19:09:35+08:00] ERROR: Running exception handlers
Running handlers complete
[2019-10-17T19:09:35+08:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 05 minutes 13 seconds
[2019-10-17T19:09:35+08:00] INFO: Sending resource update report (run-id: 942e7eaa-14c0-487d-8a6c-6d96a49c99ff)
[2019-10-17T19:09:36+08:00] FATAL: Stacktrace dumped to c:/chef/cache/chef-stacktrace.out
[2019-10-17T19:09:36+08:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2019-10-17T19:09:36+08:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received
'17'
---- Begin output of bundle install ----
STDOUT: Fetching source index from https://www.rubygems.org/
Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from https://www.rubygems.org/
Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from https://www.rubygems.org/
Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from https://www.rubygems.org/
Could not fetch specs from https://www.rubygems.org/
STDERR:
---- End output of bundle install ----
Ran bundle install returned 17
Can it be DNS issue?
I have active internet connection from the server and can land on ruby site manually.
Is there a way I can manually install ruby/cookbook gems?

Can it be DNS issue? I have active internet connection from the server and can land on ruby site manually.
if you are running chef-client on a node, then what the server has to do with "active internet connection". you should verify that an internet connection is available on the node itself.
Is there a way I can manually install ruby/cookbook gems?
sure you can. if you wish to install a rubygem into chef embedded ruby (same as chef_gem resource), then use gem with chef embedded ruby.
$ /opt/chef/bin/gem install <rubygem-name>
otherwise, you can install it to the ruby system as usuall (same as gem_package resource)
$ gem install <rubygem-name>
i also advise you to run chef-client with debug log level to get more information about the problem
$ chef-client --log_level debug

Related

bundle install gives error Bundler::HTTPError Could not fetch specs from http://rubygems.org/

Running bundle install gave the following
Fetching source index from https://rubygems.org/
Retrying fetcher due to error (2/4): Net::HTTPServerException 403 "Forbidden"
Retrying fetcher due to error (3/4): Net::HTTPServerException 403 "Forbidden"
Retrying fetcher due to error (4/4): Net::HTTPServerException 403 "Forbidden"
Could not fetch specs from https://rubygems.org/
Followed this and changed to http in Gemfile. Problem Still exists. I didn't install any other ruby version. Default on Mac Ruby version : ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18], bundle version 2.0.1.
Running bundle update then gave
Authentication is required for http://rubygems.org/. Please supply credentials for this source. You can do this by running: bundle config http://rubygems.org/ username:password
No idea what the credentials should be, but I signed up at rubygems.org and used that username/password (Pardon if that was silly) and got
Bad username or password for http://username#rubygems.org/. Please double-check your credentials and correct them.
Followed this and turned off IPV6 and still same problem.(If anything the errors showed up a little faster)
Infact now realised none of the gem command works and gives errors like
gem install jekyll bundler
ERROR: While executing gem ... (Net::HTTPServerException)
403 "Forbidden"
While I did install jekyll and bundler yesterday. Today I ran bundle exec jekyll serve and got
Could not find gem 'minima (~> 2.0)' in any of the gem sources listed in your Gemfile.
Run bundle install to install missing gems.
Hence, it all started with trying to get Jekyll working.
OS : MacOS(10.14.3)
So I have a proxy in my organization's network which I knew would cause problems so I was infact using a different network. I finally tried to comment out the proxy settings in my .bash_profile, and it was still giving the same errors. I shut down the system and then tried again and it worked.
Such a bummer. Anyway I'm not deleting the question hoping for a better work around than this. I mean if every time I want to use gem I have to do this it's kind of a hassle.
Using http instead of https in your Gemfile should do the trick.
Use:
http://rubygems.org
Disable IPv6 and HTTPS .
(Windows) -
Open Gem file and replace :
source "https://rubygems.org"
with
source "http://rubygems.org"
then , Go To Control Panel\Network and Internet\Network Connections
Right Click on your adapter , and select properties .
Untick IPv6 there

How to install vagrant plugin on Windows 7 without internet connection?

I'm trying to install vagrant-hostmanager plugin on Windows 7 without internet connection.
I have downloaded gem file from rubygems.org and copied to this machine to D:\distr\Vagrant.
Then I move to this folder and run in Command Prompt with Ruby (with Administrator privilegies):
vagrant plugin install vagrant-hostmanager --entry-point vagrant-hostmanager-1.8.6.gem
And get the following error:
Installing the 'vagrant-hostmanager' plugin. This can take a few minutes...
Vagrant failed to load a configured plugin source. This can be caused
by a variety of issues including: transient connectivity issues, proxy
filtering rejecting access to a configured plugin source, or a configured
plugin source not responding correctly. Please review the error message
below to help resolve the issue:
Errno::ECONNREFUSED: No connection could be made because the target machine ac
tively refused it. - connect(2) for "api.rubygems.org" port 443 (https://api.rub
ygems.org/specs.4.8.gz)
Source: https://rubygems.org/
I put specs.4.8.gz to his folder too but it didn't help. I also put specs.4.8 to SPEC CACHE DIRECTORY and gem file to GEM PATHS defined in gem environment. It also didn't help.
Versions:
Windows Enterprise Service Pack 1 (32 bit)
vagrant_1.9.5.msi
VirtualBox-5.1.22-115126-Win.exe
rubygems 2.5.2
rubyinstaller 2.3.3 (2016-11-21 patchlevel 222) [i386-mingw32]
I also tried with another versions of vagrant and gem: vagrant_1.8.4.msi and vagrant-hostmanager-1.8.5.gem. Result is the same.
Is it possible to install vagrant plugin offline?
Thanks!

Chef 'application_wlp' cookbook throws Load Error

I am trying to set up a virtual machine running a Liberty profile server with a sample application deployed following the instructions given in this link : https://developer.ibm.com/wasdev/docs/getting-started-chef-cookbooks-liberty-profile/
But instead of using vagrant, I use an EC2 instance as a virtual machine. I get the following error when I ssh and run "sudo chef-client" in the virtual machine.
Starting Chef Client, version 12.5.1
resolving cookbooks for run list: ["apt", "starter::JSPExamples"]
Synchronizing Cookbooks:
- starter (1.0.0)
- apt (2.9.2)
- application (5.0.0)
- poise-service (1.0.2)
- application_wlp (0.2.0)
- wlp (0.3.0)
- java (1.36.0)
- poise (2.4.0)
Compiling Cookbooks...
[2015-11-12T10:20:23+00:00] WARN: Chef::Mixin::LanguageIncludeRecipe is deprecated, use Chef::DSL::IncludeRecipe instead.
[2015-11-12T10:20:23+00:00] WARN: Called from: /var/chef/cache/cookbooks/application_wlp/providers/wlp_application.rb:20:in `class_from_file'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/mixin/from_file.rb:42:in `class_eval'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/mixin/from_file.rb:42:in `class_from_file'
=======================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/application_wlp/resources/wlp_application.rb
=======================================================================
LoadError
---------
cannot load such file -- ApplicationCookbook
Kindly help me out.
The application cookbook recently released a new major version (5.0.0) which is not backwards compatible with the earlier releases. The tutorial you are following is out of date and needs to be updated. In the short term you can probably fix your issue by explicitly downloading the last 4.x version of the application cookbook from https://supermarket.chef.io/.

"Kitchen list" command fails with "Could not load the 'ssh' transport from the load path"

I'm trying to add a Test Kitchen to a Chef cookbook but am getting the error "Could not load the 'ssh' transport from the load path".
I have previously set up a Test Kitchen following the exact same steps without issue, but that was on a different machine.
I've tried running
gem install net-ssh
But that doesn't seem to fix the problem
Solved it.
I ran
gem list
Which gave the output
..
net-ssh (2.10.0.beta2, 2.9.2)
..
I then issued the command:
gem uninstall net-ssh 2.10.9.beta2
And got the output:
Select gem to uninstall:
1. net-ssh-2.10.0.beta2
2. net-ssh-2.9.2
3. All versions
Whereupon I selected option 1, the gem was removed and then running
kitchen list
Worked as expected
I was running into the same problem for Java SE Chef cookbook on Travis-CI with:
Chef Development Kit Version: 0.10.0
chef-client version: 12.6.0
berks version: 4.0.1
kitchen version: 1.5.0
Throwing this:
-----> Starting Kitchen (v1.5.0)
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ClientError
>>>>>> Message: Could not load the 'ssh' transport from the load path. Please ensure that your transport is installed as a gem or included in your Gemfile if using Bundler.
>>>>>> ----------------------
I had to switch to Dokken to get it to work:
https://github.com/someara/kitchen-dokken
To fix:
Update .travis.yml to install kitchen-dokken:
/opt/chefdk/embedded/bin/chef gem install kitchen-dokken
And update .kitchen.docker.yml with:
transport:
name: dokken
provisioner:
name: dokken
verifier:
root_path: '/opt/verifier'
sudo: false
driver:
name: dokken

Chef-Client fails to get the ruby gem during chef provisioning

I am following the chef blog: https://www.chef.io/blog/2014/11/12/chef-provisioning-infrastructure-as-code/
On trying the command
chef-client -z <myenv>.rb, it fails with the following exception
Running handlers:
[2015-05-12T08:58:25-07:00] ERROR: Running exception handlers
Running handlers complete
[2015-05-12T08:58:25-07:00] ERROR: Exception handlers complete
[2015-05-12T08:58:25-07:00] FATAL: Stacktrace dumped to /scratch/ChefWorkstation/.chef/local-mode-cache/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 1.536536008 seconds
[2015-05-12T08:58:25-07:00] ERROR: cannot load such file -- chef/provisioning/docker_driver
[2015-05-12T08:58:27-07:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
If i try,
chef gem list and chef gem which chef/provisioning/docker_driver shows the gem listed and the path respectively
Can somebody please help here.
The issue was because I was running the command as sudo. But if I do not use sudo I see docker issues. However, this problem is resolved

Resources