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
Related
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
I'm trying to install mysql2 gem in my vagrant machine with chef solo. I am getting the following error
ERROR: mysql2_chef_gem_installer[default] (mysql2_chef_gem::default line 20) had an error:
Chef::Exceptions::RecipeNotFound: could not find recipe client for cookbook mysql
I have included the cookbook mysql and the dependencies are added in the metadata.rb
Following is the code snippet
mysql2_chef_gem_installer 'default' do
type 'mysql'
action :install
end
Could somebody explain what is it I am doing wrong ?
Edit: Bug in rubygems 2.4.4. (fixed in 2.4.5)
I'm having trouble installing gems with the embedded ruby that comes with Chef Client v12.2.1, using the chef_gem resource:
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
chef_gem[zabbixapi] (generic_server_win::libzabbix-deps line 6) had an error: Mixlib::ShellOut::ShellCommand Failed: Expected process to exit with [0], but received '1'
---- Begin output of C:/opscode/chef/embedded/bin/gem install c:/chef/cache/zabbixapi-2.2.2.gem -q --no-rdoc --no-ri -v "2.2.2" ----
STDOUT:
STDERR: ERROR: While executing gem ... (Errno::EADDRNOTAVAIL)
The requested address is not valid in its context. - connect(2)
---- End output of C:/opscode/chef/embedded/bin/gem install c:/chef/cache/zabbixapi-2.2.2.gem -q --no-rdoc --no-ri -v "2.2.2" ----
Ran C:/opscode/chef/embedded/bin/gem install c:/chef/cache/zabbixapi-2.2.2.gem -q --no-rdoc --no-ri -v "2.2.2" returned 1
Also:
Same result when running the command manually on the command-line as an Administrator with the --local option
Same error occurs for other gems.
The servers that I'm trying to run this on have no internet access
I'm unable to reproduce the problem on a newly installed test machine (with internet access)
The version of ruby used is 2.0.0: ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
Here is my Chef recipe:
cookbook_file "#{Chef::Config[:file_cache_path]}/zabbixapi-2.2.2.gem" do
source 'zabbixapi-2.2.2.gem'
end
chef_gem "zabbixapi" do
source "#{Chef::Config[:file_cache_path]}/zabbixapi-2.2.2.gem"
end
You're problem is that the chef_gem resource is special in the way it enforce the use of the embedded ruby in chef installation and that it is run before convergence to allow the gem to be required in recipes. documentation about it here
To use a local source deployed with chef you have to ensure the file is present before, if not the gem command will try to download it (and fail with no internet access).
To ensure your local file is present before the chef_gem call you have to ensure the cookbook_file resource is called at compile time with this trick
in your specific case this should do:
cookbook_file "#{Chef::Config[:file_cache_path]}/zabbixapi-2.2.2.gem" do
action :nothing
source 'zabbixapi-2.2.2.gem'
end.run_action(:create)
chef_gem "zabbixapi" do
source "#{Chef::Config[:file_cache_path]}/zabbixapi-2.2.2.gem"
end
The action nothing in the resource is to avoid having it called twice (once in compile phase and once in converge phase, even if the later won't have any impact, it's better to save time no evaluating it twice) then calling the action :create at end of the definition will trigger the action in the compile phase and the file will be present for the chef_gem call later.
I'm trying to add the vagrant-aws plugin to my installation of Vagrant. Upon running this command:
vagrant plugin install vagrant-aws
I get this error message:
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:
An error occurred while installing json (1.8.2), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.2'` succeeds before bundling.
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
"c:/Program Files (x86)/Vagrant/embedded/bin/ruby.exe" extconf.rb
creating Makefile
make "DESTDIR="
generating generator-i386-mingw32.def
/bin/sh: -c: line 0: syntax error near unexpected token `x86'
/bin/sh: -c: line 0: `/c/Program\ Files\ (x86)/Vagrant/embedded/bin/ruby -e "puts 'EXPORTS', 'Init_generator'" > generator-i386-mingw32.def'
make: *** [generator-i386-mingw32.def] Error 2
Gem files will remain installed in C:/Users/Steve/.vagrant.d/gems/gems/json-1.8.2 for inspection.
Results logged to C:/Users/Steve/.vagrant.d/gems/gems/json-1.8.2/ext/json/ext/generator/gem_make.out
At first I thought I would need to manually install Ruby and Gem in order to fix this, but then I realized that Vagrant's Bundler system should automatically take care of all this. I'm at a loss and would appreciate any help.
Ahh.. Windows and Linux build/make tools will never get along.
As you can see from the error: /bin/sh: -c: line 0: syntax error near unexpected token ``x86' - The problem is with the parentheses characters in the path.
I think newer Vagrant version solved these problems by installing Vagrant in Program Data directories.
I feel your pain, I stayed up for awhile fighting with this issue. I had just switched over to Linux Mint 17.1 Rebecca from being a long time windows user.
Vagrant version 1.7.2, pretty fresh install of Mint 17.1
Kept getting that same error when trying to install various plugins for vagrant, mainly hostsupdater but I bet this fixes all the issues as it is the same error. I read tons of threads and answers and this is what ended up working.
1: Followed this guide and installed Ruby 2.2.0
http://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you
Note: Make sure you visit the sites where he links off to the README for installing ruby, his copy paste for code is messed up.
2: You were expecting more, nope!
Installing all plugins just worked perfect after that, did need to use sudo though but other than that.
Hope this saves someone a ton of time looking...
Just updated to vagrant 1.6.2
Ran vagrant up and got the following error
Vagrant failed to initialize at a very early stage:
The plugins failed to load properly. The error message given is shown below.
undefined method `[]' for nil:NilClass
I ran vagrant up --debug and saw the following error message
ERROR vagrant: Vagrant experienced an error! Details:
ERROR vagrant: #<Vagrant::Errors::PluginLoadError: The plugins failed to load properly. The error message given is shown below.
undefined method `[]' for nil:NilClass>
ERROR vagrant: The plugins failed to load properly. The error message given is shown below.
undefined method `[]' for nil:NilClass
ERROR vagrant: /Applications/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant.rb:265:in `rescue in <top (required)>'
/Applications/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant.rb:261:in `<top (required)>'
/Applications/Vagrant/bin/../embedded/gems/gems/vagrant-1.6.2/bin/vagrant:101:in `require'
/Applications/Vagrant/bin/../embedded/gems/gems/vagrant-1.6.2/bin/vagrant:101:in `<main>'
Vagrant failed to initialize at a very early stage:
The plugins failed to load properly. The error message given is shown below.
undefined method `[]' for nil:NilClass
I then tried
vagrant plugin update
This produced the following complaint
Bundler, the underlying system Vagrant uses to install plugins, reported an error. The error is shown below. These errors are usually caused by misconfigured plugin installations or transient network issues. The error from Bundler is:
An error occurred while installing nokogiri (1.6.2.1), and Bundler cannot continue. Make sure that `gem install nokogiri -v '1.6.2.1'` succeeds before bundling.
So I ran
gem install nokogiri -v '1.6.2.1'
And this succeeded.
But it didn't solve the problem...
When I now run
vagrant plugin update
I still get the same error I got before installing nokogiri.
Bundler, the underlying system Vagrant uses to install plugins, reported an error. The error is shown below. These errors are usually caused by misconfigured plugin installations or transient network issues. The error from Bundler is:
An error occurred while installing nokogiri (1.6.2.1), and Bundler cannot continue. Make sure that `gem install nokogiri -v '1.6.2.1'` succeeds before bundling.
Anyone have a solution for this?
This is a Vagrant issue and is being tracked in https://github.com/mitchellh/vagrant/issues/3769.
Ok. I solved the problem for me at least.
I uninstalled vagrant 1.6.2 and installed vagrant 1.6.1