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

Replaced deprecated config_global with vagrantfile.config #81

Merged
merged 2 commits into from
Mar 16, 2014

Conversation

januzis
Copy link
Contributor

@januzis januzis commented Mar 12, 2014

Partially fixes issue #80 (for people who do not use hostmanager as provisioner).

@benmoss
Copy link

benmoss commented Mar 12, 2014

I tried this out and am getting this when I run vagrant hostmanager

/Users/moss/.vagrant.d/gems/gems/vagrant-hostmanager-1.3.0/lib/vagrant-hostmanager/hosts_file.rb:104:in `get_machines': undefined method `hostmanager' for nil:NilClass (NoMethodError)
    from /Users/moss/.vagrant.d/gems/gems/vagrant-hostmanager-1.3.0/lib/vagrant-hostmanager/hosts_file.rb:74:in `update_content'
    from /Users/moss/.vagrant.d/gems/gems/vagrant-hostmanager-1.3.0/lib/vagrant-hostmanager/hosts_file.rb:64:in `update_file'
    from /Users/moss/.vagrant.d/gems/gems/vagrant-hostmanager-1.3.0/lib/vagrant-hostmanager/hosts_file.rb:22:in `update_guest'
    from /Users/moss/.vagrant.d/gems/gems/vagrant-hostmanager-1.3.0/lib/vagrant-hostmanager/action/update_guest.rb:21:in `call'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.0/lib/vagrant/action/warden.rb:34:in `call'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.0/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.0/lib/vagrant/action/warden.rb:34:in `call'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.0/lib/vagrant/action/builder.rb:116:in `call'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.0/lib/vagrant/action/runner.rb:69:in `block in run'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.0/lib/vagrant/util/busy.rb:19:in `busy'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.0/lib/vagrant/action/runner.rb:69:in `run'
    from /Users/moss/.vagrant.d/gems/gems/vagrant-hostmanager-1.3.0/lib/vagrant-hostmanager/command.rb:25:in `block in execute'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.0/lib/vagrant/plugin/v2/command.rb:200:in `block in with_target_vms'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.0/lib/vagrant/plugin/v2/command.rb:194:in `each'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.0/lib/vagrant/plugin/v2/command.rb:194:in `with_target_vms'
    from /Users/moss/.vagrant.d/gems/gems/vagrant-hostmanager-1.3.0/lib/vagrant-hostmanager/command.rb:24:in `execute'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.0/lib/vagrant/cli.rb:42:in `execute'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.0/lib/vagrant/environment.rb:244:in `cli'
    from /Applications/Vagrant/bin/../embedded/gems/gems/vagrant-1.5.0/bin/vagrant:147:in `<main>'

@januzis
Copy link
Contributor Author

januzis commented Mar 12, 2014

Sorry about that, should be ok now.

@yakobe
Copy link

yakobe commented Mar 13, 2014

i am getting this too? any idea when the fix will be released?

@januzis
Copy link
Contributor Author

januzis commented Mar 13, 2014

@yakobe No idea, but if you're not using hostmanager as a provisioner, you can clone my fork, build the gem and install the plugin from your filesystem via vagrant plugin install hostmanager_src/vagrant-hostmanager-1.3.0.gem

@yakobe
Copy link

yakobe commented Mar 13, 2014

rolling back to vagrant 1.4.0 for now ;)

@timrobertson100
Copy link

@januzis I am trying to use your fork. I downloaded it, ran

$ gem build vagrant-hostmanager.gemspec

and installed with

$ vagrant plugin install vagrant-hostmanager-1.3.0.gem
Installing the 'vagrant-hostmanager-1.3.0.gem' plugin. This can take a few minutes...
Installed the plugin 'vagrant-hostmanager (1.3.0)'!

but then running vagrant up:

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
There are errors in the configuration of this machine. Please fix
the following errors and try again:

Vagrant:
* Unknown configuration section 'hostmanager'.

Any ideas? Thanks a million.

@januzis
Copy link
Contributor Author

januzis commented Mar 13, 2014

@timrobertson100 Have you checked out vagrat-1.5-support branch before building? How does your Vagrantfile look like? Try running rake test in plugin's directory, see if it reveals something.. My hostmanager portion in Vagrantfile looks like this:

# Hostmanager plugin (vagrant-hostmanager)
# Automatically adds entries to hosts file for host and guest systems
if Vagrant.has_plugin?("vagrant-hostmanager")
  config.hostmanager.enabled = true
  config.hostmanager.manage_host = true
else
  # Required, since current apache vhost configuration always redirects
  # to the APP_HOSTNAME, and request fails if /etc/hosts is not set up
  raise Vagrant::Errors::VagrantError.new,
        "Required plugin missing: vagrant-hostmanager (1.3.0 tested). To install, run the following:\n" +
        "vagrant plugin install vagrant-hostmanager --plugin-version 1.3.0"
end

@timrobertson100
Copy link

Thanks @januzis

I did build the branch and my VagrantFile looks like yours, but:

$ rake test
rake aborted!
cannot load such file -- bundler/gem_helper

Is not a critical issue for me right now - I can easily use IP addresses in my ansible files... Thanks for replying

@januzis
Copy link
Contributor Author

januzis commented Mar 13, 2014

@timrobertson100 You need to install bundler: gem install bundler

@timrobertson100
Copy link

Indeed - thanks @januzis

Looks like tests show the same issue: http:https://pastebin.com/6biFcLPv

@januzis
Copy link
Contributor Author

januzis commented Mar 13, 2014

@timrobertson100 Try removing and adding the plugin, maybe there is a problem because you installed modified plugin on top of the old one.. The error message is exactly what you get, if you have no hostmanager plugin installed, and try to modify config.hostmanager section. Issue #77 has the same error message, solved by reinstalling everything.

@pbitty
Copy link
Contributor

pbitty commented Mar 14, 2014

@timrobertson100 This might be caused by the new way vagrant 1.5 handles plugins under bundler.

Check out this vagrant blog entry.

Basically the Gemfile has to be changed to have vagrant-hostmanager inside a :plugins group.

It should go from this:

source 'https://rubygems.org'

group :development do
  gem 'vagrant', :git => 'git:https://github.com/mitchellh/vagrant.git', :tag => 'v1.2.7'
end

gemspec

To this:

source 'https://rubygems.org'

group :development do
  gem 'vagrant', :git => 'git:https://github.com/mitchellh/vagrant.git', :tag => 'v1.5.0'
end

group :plugins do
  gemspec
end

note: I also changed the vagrant tag.

I was able to get vagrant to find the plugin again, but I've run into other problems because I'm using ruby 1.9.3 and vagrant now uses ruby 2.0.

I'll try to test this as soon as I can.

@timrobertson100
Copy link

Thanks for all the info.
I'm ok for now with the IP approach (and fixing all the other things broken from a mavericks upgrade) but I'll come back to this shortly to test. I'm also on ruby 1.9.3 so would expect issues too.

pbitty added a commit that referenced this pull request Mar 16, 2014
Replaced deprecated config_global with vagrantfile.config to support vagrant 1.5 API
@pbitty pbitty merged commit c5e3b5e into devopsgroup-io:master Mar 16, 2014
@pbitty
Copy link
Contributor

pbitty commented Mar 16, 2014

Thanks a lot @januzis.

I'm going to look at what's breaking the provisioner code.

@januzis januzis deleted the vagrant-1.5-support branch March 16, 2014 18:31
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

Successfully merging this pull request may close these issues.

None yet

5 participants