hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.27k stars 4.43k forks source link

Chef Provisioner: chef never successfully completed! #9040

Closed conor123 closed 7 years ago

conor123 commented 7 years ago

Vagrant version

2.0.0

Host operating system

Mac El capitan

Guest operating system

various including bento/centos-7.2

Vagrantfile

config.omnibus.chef_version = :latest
config.vm.provision :chef_client do |chef|
  chef.provisioning_path = "/etc/chef"
  chef.chef_server_url = "https://api.chef.io/organizations/orgname"
  chef.validation_client_name = "username"
  chef.validation_key_path = "/user.pem"
  chef.node_name = "server"
end

Debug output

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Installing Ohai plugin
==> default: Installing Chef latest Omnibus package...
==> default: ubuntu 14.04 x86_64
==> default: Getting information for chef stable latest for ubuntu...
==> default: downloading https://omnitruck-direct.chef.io/stable/chef/metadata?v=latest&p=ubuntu&pv=14.04&m=x86_64
==> default:   to file /tmp/install.sh.5040/metadata.txt
==> default: trying wget...
==> default: sha1       bbab1e399574b036efdd956156460378425c0d7c
==> default: sha256     2793306c40ee63e516cc48878071109169b0106c4553e7032a912362f9713718
==> default: url        https://packages.chef.io/files/stable/chef/13.5.3/ubuntu/14.04/chef_13.5.3-1_amd64.deb
==> default: version    13.5.3

==> default: downloaded metadata file looks valid...
==> default: downloading https://packages.chef.io/files/stable/chef/13.5.3/ubuntu/14.04/chef_13.5.3-1_amd64.deb
==> default:   to file /tmp/install.sh.5040/chef_13.5.3-1_amd64.deb
==> default: trying wget...
==> default: Comparing checksum with sha256sum...
==> default: Installing chef latest
==> default: installing with dpkg...
==> default: (Reading database ... 72882 files and directories currently installed.)
==> default: Preparing to unpack .../chef_13.5.3-1_amd64.deb ...
==> default: Unpacking chef (13.5.3-1) over (13.5.3-1) ...
==> default: Setting up chef (13.5.3-1) ...
==> default: Thank you for installing Chef!
==> default: Running provisioner: chef_client...
==> default: Detected Chef (latest) is already installed
==> default: Creating folder to hold client key...
==> default: Uploading chef client validation key...
==> default: Generating chef JSON and uploading...
==> default: Warning: Chef run list is empty. This may not be what you want.
==> default: Running chef-client...
==> default: [2017-10-07T22:08:02+00:00] FATAL: Configuration error NoMethodError: undefined method `<<' for nil:NilClass
==> default: [2017-10-07T22:08:02+00:00] FATAL:   /etc/chef/client.rb:31:in `from_string'
==> default: [2017-10-07T22:08:02+00:00] FATAL: Aborting due to error in '/etc/chef/client.rb'
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

Expected behavior

chef should have been provisioneed

Actual behavior

Error: Chef never successfully completed!

Steps to reproduce

  1. vagrant up

References

Notes

The client.rb:

Chef::Config.from_file "/etc/chef/custom-config.rb"

which is:

Ohai::Config[:plugin_path] << "/etc/chef/ohai_plugins"

Anyone who uses Vagrant to provision chef and may have an insight here your comments would be much appreciated.

Possibly related to:

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:

Unable to resolve dependency: user requested 'vbguest (> 0)'

Possible issue?

For anyone who had the same it looks like a vagrant issue. Install or upgrade virtualbox, vagrant and vagrant-manager. Plugins will need to be expunged and reinstalled and one plugin was troublesome - remove it.

vagrant plugin expunge --reinstall

vagrant plugin uninstall vagrant-vbguest

Actually looking at the vagrant-ohai plugin, maybe I have some misconfigured ohai code somewhere?

briancain commented 7 years ago

Hi @conor123 - Could you provide a link to a gist containing the full debug output when you try to vagrant up? That'll give us a better idea of where the error is coming from...thanks!

conor123 commented 7 years ago

@briancain hiya, yes sure here you go. Thanks: https://gist.github.com/conor123/7c1c2efc42aaf834458cc005a327625f

briancain commented 7 years ago

@conor123 hmm, can you run vagrant provision with the --debug flag? (i.e. vagrant provision --debug). Thanks!

conor123 commented 7 years ago

@briancain yes thanks there you go: https://gist.github.com/conor123/f7c89df4a19a238a9993eaf52cdeab9e

briancain commented 7 years ago

Alright thanks @conor123! From what I can tell this is a configuration issue with chef, and not a vagrant bug. You might be able to gain more insight from this link: https://docs.chef.io/config_rb_client.html#ohai-settings

I recommend emailing the vagrant mailing list as you should be able to find some help there if you are still stuck after looking at those docs. https://groups.google.com/forum/#!forum/vagrant-up Thanks!

a2k42 commented 7 years ago

@conor123 Were you able to find a solution to this problem? Thanks

conor123 commented 7 years ago

@Andy2K11 I actually disabled/removed the ohai-vagrant plugin as a work around cause I didn't really need it. The bug may have been in a file I uploaded from another developer but I didn't deep dive the issue. Did you run into same issue? The affected code in my case came from a Udemy Chef course.

a2k42 commented 7 years ago

Hi @conor123 it sounds like we took the same Udemy course lol. Having looked through your debug logs it looks like the exact same issue. I've tried various versions of VirtualBox, Vagrant, and plugins without much luck. I might try starting from scratch with a fresh install and setting up a minimal example as I seem to be running into lots of other errors now. If I get anywhere I'll post back.

conor123 commented 7 years ago

@Andy2K11 my next move will be to remove all the ohai code from my chef server/local cookbooks as that's most likely the issue. Not likely to be a vagrant issue and less so a Chef SDK one so clean installs probably won't help - though if you find that works let me know. It's something about an interaction between the our ohai code on our chef server(or local cookbook possibly) and the vagrant plugin

a2k42 commented 7 years ago

@conor123 That took a while! Vagrant 2.0.0 causes an rsync error on Windows 10 hosts, although I believe a fix is coming out in the next version. Virtualbox 5.2 isn't compatible with older versions of Vagrant. Anyway, have got a simple example working now. Will come back to it and try finding out exactly what caused the problem when I have time.

https://github.com/Andy2K11/vmbox

Of note is that the nodes folder is correctly populated with a json file during provisioning which wasn't happening before (It's been added to my .gitignore because I don't want all the system info in the public domain). You might be right about ohai as I don't have the vagrant-ohai plugin installed anymore.

conor123 commented 7 years ago

@Andy2K11 cool, for what it's worth I'm on a Mac, and I had updated both VB and Vagrant but that didn't affect the particular bug I was having.

a2k42 commented 7 years ago

@coner123 Yeah the problem I've been having with versions just seems to be a Windows thing and not related to this issue.

After checking that my main project now works (which it does 👍 ) I installed vagrant-ohai and was able to reproduce the error. The fix then is to run

vagrant plugin uninstall vagrant-ohai

and remove any code in the Vagrantfile which requires this plugin (like the one from that Udemy course). I had (erroneously) thought that vagrant-ohai was needed to create the nodes json file, but at least in the case of provisioning with chef_zero it clearly isn't.

Thanks for your help.

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.