Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin path config value isn't initialized to an array : causes no method error #22

Open
anadimisra opened this issue May 19, 2018 · 1 comment

Comments

@anadimisra
Copy link

Vagrant version

Anadis-MacBook-Pro:vbox-vm anadi$ vagrant -v
Vagrant 2.1.1

Host operating system

OSX High Sierra

Guest operating system

ubuntu 16.04 x86_64

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
  config.vm.define "provisioner" do |provisioner|
    provisioner.vm.box = "ubuntu/xenial64"
    provisioner.vm.box_version = "20180509.0.0"
    provisioner.vm.box_check_update = false
    provisioner.omnibus.chef_version = :latest
    provisioner.vm.network "forwarded_port", guest: 80, host: 8989
    provisioner.vm.provider :virtualbox do |vbox|
      vbox.name = "chef-provisioned"
    end
    provisioner.vm.provision "chef_solo" do |chef|
      chef.node_name = "chef-provisioned"
      chef.cookbooks_path = "../../cookbooks"
      chef.verbose_logging = true
      chef.add_recipe "learn_chef_apache2"
    end
  end
end

Debug output

https://gist.github.com/anadimisra/a370cf4178c842ad1d261907eca637ae

Expected behavior

Vagrant Provisions an Ubuntu machine through chef with Apache HTTPD web server installed

Actual behavior

Fails with FATAL error

==> provisioner: Running chef-solo...
==> provisioner: [2018-05-15T10:40:14+00:00] FATAL: Configuration error NoMethodError: undefined method `<<' for nil:NilClass
==> provisioner: [2018-05-15T10:40:14+00:00] FATAL:   /tmp/vagrant-chef/solo.rb:24:in `from_string'
==> provisioner: [2018-05-15T10:40:14+00:00] FATAL: Aborting due to error in '/tmp/vagrant-chef/solo.rb'
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

Steps to reproduce

  1. Use Vagrant with Virtualbox provider
  2. Create a simple chef provisioner
  3. run vagrant up

Generated solo.rb file from the Guest VM

node_name "chef-provisioned"
file_cache_path    "/var/chef/cache"
file_backup_path   "/var/chef/backup"
cookbook_path ["/tmp/vagrant-chef/4cf62a940e70dd6c25094e15c3d06903/cookbooks"]
log_level :info
verbose_logging true

encrypted_data_bag_secret nil






http_proxy nil
http_proxy_user nil
http_proxy_pass nil
https_proxy nil
https_proxy_user nil
https_proxy_pass nil
no_proxy nil


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

and in the /tmp/vagrant-chef/custom-config.rb file

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

looks like the problem is in this method

      def ohai_custom_config(current_conf)
        tmp = Tempfile.new(["chef-custom-config", ".rb"])
        tmp.puts 'Ohai::Config[:plugin_path] << "/etc/chef/ohai_plugins"'
        tmp.write(File.read(current_conf)) if current_conf
        tmp.close
        tmp
end

When I uninstall vagrant-ohai and run the vagrant file it works fine

@ghost
Copy link

ghost commented May 27, 2018

I hit the problem and fixed it. Issued a pull request which is waiting on the owner of this repo.
https://github.com/avishai-ish-shalom/vagrant-ohai/pull/21/files

Before:
tmp.puts 'Ohai::Config[:plugin_path] << "/etc/chef/ohai_plugins"'

After:
tmp.puts 'ohai.plugin_path << "/etc/chef/ohai_plugins"'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant