noahgibbs / madscience

Obsolete: deploy your Rails app with a full dedicated server in an hour! The source for Ruby Mad Science and Rails Deploy In An Hour (Note: link is now to a different project!)
http://rubymadscience.com
MIT License
67 stars 2 forks source link

Provisioner not found #21

Open saturnflyer opened 9 years ago

saturnflyer commented 9 years ago

Still working on getting this working and got to this point:

 sudo madscience construct
Password:
Running madscience 0.0.27...
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
Installing apt (2.6.1)
Installing chef_handler (1.1.6)
Installing dmg (2.2.2)
Installing windows (1.36.6)
Installing vagrant (0.2.2)
Installing yum (3.5.3)
Installing virtualbox (0.7.2)
fatal: Not a git repository (or any of the parent directories): .git
/Users/jim/.rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/chef-11.18.6/lib/chef/data_bag_item.rb:161: warning: circular argument reference - data_bag
Starting Chef Client, version 11.18.6
Compiling Cookbooks...
Converging 15 resources
Recipe: vagrant::mac_os_x
  * dmg_package[Vagrant] action install (up to date)
Recipe: vagrant::install_plugins
  * vagrant_plugin[vagrant-omnibus] action install (up to date)
  * vagrant_plugin[vagrant-librarian-chef] action install (up to date)
  * vagrant_plugin[vagrant-aws] action install (up to date)
  * vagrant_plugin[vagrant-digitalocean] action install (up to date)
  * vagrant_plugin[vagrant-linode] action install (up to date)
  * vagrant_plugin[vagrant-host-shell] action install (up to date)
Recipe: virtualbox::default
  * dmg_package[VirtualBox] action install (up to date)
Recipe: madscience-vagrant-cookbook::default
  * directory[/Users/jim/.deploy_credentials] action create (up to date)
  * execute[generate ssh provisioning keys for jim.] action run (up to date)
  * execute[generate ssh app-deploy keys for jim.] action run (up to date)
  * cookbook_file[digital_ocean.json] action create_if_missing (up to date)
  * cookbook_file[aws.json] action create_if_missing (up to date)
  * cookbook_file[linode.json] action create_if_missing (up to date)
  * file[/Users/jim/.deploy_credentials/authorized_keys] action create_if_missing (up to date)

Running handlers:
Running handlers complete
Chef Client finished, 0/15 resources updated in 25.325728 seconds
Cloning into 'madscience'...
warning: templates not found /Users/jim/.git_template
remote: Counting objects: 870, done.
remote: Compressing objects: 100% (309/309), done.
remote: Total 870 (delta 477), reused 868 (delta 475), pack-reused 0
Receiving objects: 100% (870/870), 108.12 KiB | 0 bytes/s, done.
Resolving deltas: 100% (477/477), done.
Checking connectivity... done.
Could not find rake-10.3.2 in any of the sources
Run `bundle install` to install missing gems.
Bringing machine 'app-server' up with 'virtualbox' provider...
There are errors in the configuration of this machine. Please fix
the following errors and try again:

vm:
* The '' provisioner could not be found.

/Users/jim/.rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/madscience-0.0.27/bin/madscience:119:in `block in do_deploy': Deploy process failed with status 1! Fix and/or re-run using 'vagrant provision'! (RuntimeError)
    from /Users/jim/.rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/madscience-0.0.27/bin/madscience:106:in `chdir'
    from /Users/jim/.rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/madscience-0.0.27/bin/madscience:106:in `do_deploy'
    from /Users/jim/.rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/madscience-0.0.27/bin/madscience:161:in `<top (required)>'
    from /Users/jim/.rubies/ruby-2.2.1/bin/madscience:23:in `load'
    from /Users/jim/.rubies/ruby-2.2.1/bin/madscience:23:in `<main>'
noahgibbs commented 9 years ago

That's a bug I've hit too :-(

It seems the Vagrant cookbook sometimes installs plugins wrong somehow, so that it's convinced they're installed and Vagrant isn't (you can try "vagrant plugin list" and you won't see them.)

The easiest way to handle this is probably to uninstall Vagrant (including that pkgutil command) and reinstall. The second-easiest is to install the plugin that's missing -- probably "vagrant plugin install vagrant-host-shell --plugin-version 0.0.4".

The list of plugins that need to be installed, taken from the cookbook:

node.default['vagrant']['plugins'] = [ { 'name' => 'vagrant-omnibus', 'version' => '1.4.1' }, { 'name' => 'vagrant-librarian-chef', 'version' => '0.2.1' }, { 'name' => 'vagrant-aws', 'version' => '0.6.0' }, { 'name' => 'vagrant-digitalocean', 'version' => '0.7.3' }, { 'name' => 'vagrant-linode', 'version' => '0.1.1' }, { 'name' => 'vagrant-host-shell', 'version' => '0.0.4' }, ]

noahgibbs commented 9 years ago

(I've figured out how to detect the bug, but it's going to take me longer to fix it. And my company just went out of business, so I've been derelict on pushing my changes. It'll happen pretty soon.)

saturnflyer commented 9 years ago

No problem! I'll continue reporting what I find. Thanks so much Noah!

saturnflyer commented 9 years ago

I have a feeling this is a problem with my system.

After installing the missing vagrant plugins, I did cd madscience. It wasn't clear to me that I'd need to do that; still not sure if that's correct. Then:

$ vagrant up
Bringing machine 'app-server' up with 'virtualbox' provider...
==> app-server: Importing base box 'ubuntu/trusty64'...
==> app-server: Matching MAC address for NAT networking...
==> app-server: Checking if box 'ubuntu/trusty64' is up to date...
==> app-server: Setting the name of the VM: madscience_app-server_1428589831406_26866
==> app-server: Clearing any previously set forwarded ports...
==> app-server: Installing Chef cookbooks with Librarian-Chef...
==> app-server: Clearing any previously set network interfaces...
==> app-server: Preparing network interfaces based on configuration...
    app-server: Adapter 1: nat
==> app-server: Forwarding ports...
    app-server: 80 => 4321 (adapter 1)
    app-server: 8800 => 4322 (adapter 1)
    app-server: 8900 => 4323 (adapter 1)
    app-server: 9000 => 4324 (adapter 1)
    app-server: 9100 => 4325 (adapter 1)
    app-server: 22 => 2222 (adapter 1)
==> app-server: Running 'pre-boot' VM customizations...
==> app-server: Booting VM...
==> app-server: Waiting for machine to boot. This may take a few minutes...
The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'poweroff' state. Please verify everything is configured
properly and try again.

If the provider you're using has a GUI that comes with it,
it is often helpful to open that and watch the machine, since the
GUI often has more helpful error messages than Vagrant can retrieve.
For example, if you're using VirtualBox, run `vagrant up` while the
VirtualBox GUI is open.

So I opened my VirtualBox GUI to see what's going on. Found my VM there and hit the start button and it raised this error:

Failed to open a session for the virtual machine madscience_app-server_1428589831406_26866.
The virtual machine 'madscience_app-server_1428589831406_26866' has terminated unexpectedly during startup with exit code 1.

Result Code: 
NS_ERROR_FAILURE (0x80004005)
Component: 
Machine
Interface: 
IMachine {480cf695-2d8d-4256-9c7c-cce4184fa048}
cowlibob commented 9 years ago

It might be worth configuring with GUI enabled:

config.vm.provider "virtualbox" do |v|
  v.gui = true
end

http://docs.vagrantup.com/v2/virtualbox/configuration.html

noahgibbs commented 9 years ago

Yes, "cd madscience" is correct. I should probably make that clearer.

Have you tried "vagrant plugin list" to make sure everything shows up? Though it sounds like you're not having that same problem again.

Yeah, haven't seen that new error before :-/ Not sure what's up with that.

noahgibbs commented 9 years ago

Hey, Jim. After some investigation, looks like Vagrant plugins aren't installed under Vagrant. Oy. So "reinstall Vagrant" isn't useful advice here. Instead, do me a favor and do this:

rm ~/.vagrant.d/plugins.json rm -rf ~/.vagrant.d/gems

This will remove all install Vagrant plugins -- running "madscience setup" or "madscience construct" should reinstall them.

I'm still figuring out why this happens, but madscience version 0.0.28+ should at least come to a screeching halt if it does happen, including listing a plugin that isn't installed and how to install it.

noahgibbs commented 9 years ago

Oh God. Since Vagrant installs plugins in the user's home directory, I'm getting a completely unrelated set with sudo/rvmsudo than I get when I'm not doing that.

So I need to install the plugins in both root and non-root directories, or install again after dropping root privileges, or...

Don't know. I definitely need to think through this now. The easiest answer would be to install this in the user's home dir (not root's, generally) and then forbid running "vagrant up" (etc) via sudo. I have a suspicion that that won't end well.

Will figure it out.

noahgibbs commented 9 years ago

Also: how did this ever work?

Cinderhaze commented 9 years ago

Is there any way to specify your own plugin path for part of it? I know in puppet you can do --modulepath and point to a specific directory... Not sure if there is some way you can create some common directory to tell it to use?

noahgibbs commented 9 years ago

Huh. And the periodic failures are more mysterious when I take into account that my detection code is in Chef, and it successfully detects the problem. That means we're definitely seeing the occasional failures even within the sudo environment, completely ignoring the post-sudo environment. This looks like some kind of error where plugins.json doesn't agree with the installed gem, or something along those lines.

noahgibbs commented 9 years ago

@Cinderhaze, there's a way to install into other user's Vagrant dir in the latest version of the Vagrant cookbook. I need to port my changes on top of it (current plugin version detection is broken) and then use it.

So yeah, there's absolutely a way to do that. It's just running the plugin command as that user.

noahgibbs commented 9 years ago

Okay. It works (ish) because it's more complicated than that, and when running with sudo you're often still using your own home directory, not root's. Sometimes. Ish.

But installing the plugins with Vagrant can absolutely be made to do it in a user dir, which I'm doing locally.

And I believe that will fix the root/not-root problem, though not necessarily all the others.

Pushed as madscience-0.0.29.gem.

saturnflyer commented 9 years ago

I kept getting the error The guest machine entered an invalid state while waiting for it... and updated to the latest VirtualBox (4.3.26) and things seem to be installing correctly for me (with madscience 0.0.29). I'll probably try to blow it all away and see if the plugins install properly without manual intervention but I'm focused on getting it working for me at the moment.

noahgibbs commented 9 years ago

Weird. Well, I can certainly upgrade madscience_gem to the latest VirtualBox without a problem.

Have you tried turning the gui option on to see it's obvious what the problem is? This is one I haven't seen myself :-(