ggiamarchi / vagrant-openstack-provider

Use Vagrant to manage OpenStack Cloud instances.
MIT License
247 stars 101 forks source link

vagrant ssh isn't working #255

Closed visibilityspots closed 8 years ago

visibilityspots commented 8 years ago

The vagrant up command is working fine, vagrant status does show the correct state and using native ssh I can login into the openstack instance.

But if I want to use the vagrant ssh command I get this error:

/home/jan/.vagrant.d/gems/gems/vagrant-openstack-provider-0.7.0/lib/vagrant-openstack-provider/utils.rb:21:in `get_ip_address': Catched Error: Catched Error: Catched Error: undefined method `size' for nil:NilClass (NoMethodError)
    from /home/jan/.vagrant.d/gems/gems/vagrant-openstack-provider-0.7.0/lib/vagrant-openstack-provider/action/read_ssh_info.rb:39:in `read_ssh_info'
    from /home/jan/.vagrant.d/gems/gems/vagrant-openstack-provider-0.7.0/lib/vagrant-openstack-provider/action/read_ssh_info.rb:26:in `block (2 levels) in execute'
    from /home/jan/.vagrant.d/gems/gems/vagrant-openstack-provider-0.7.0/lib/vagrant-openstack-provider/action/read_ssh_info.rb:25:in `synchronize'
    from /home/jan/.vagrant.d/gems/gems/vagrant-openstack-provider-0.7.0/lib/vagrant-openstack-provider/action/read_ssh_info.rb:25:in `block in execute'
    from /home/jan/.vagrant.d/gems/gems/vagrant-openstack-provider-0.7.0/lib/vagrant-openstack-provider/action/read_ssh_info.rb:24:in `tap'
    from /home/jan/.vagrant.d/gems/gems/vagrant-openstack-provider-0.7.0/lib/vagrant-openstack-provider/action/read_ssh_info.rb:24:in `execute'
    from /home/jan/.vagrant.d/gems/gems/vagrant-openstack-provider-0.7.0/lib/vagrant-openstack-provider/action/abstract_action.rb:8:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
    from /home/jan/.vagrant.d/gems/gems/vagrant-openstack-provider-0.7.0/lib/vagrant-openstack-provider/action/connect_openstack.rb:32:in `execute'
    from /home/jan/.vagrant.d/gems/gems/vagrant-openstack-provider-0.7.0/lib/vagrant-openstack-provider/action/abstract_action.rb:8:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
    from /home/jan/.vagrant.d/gems/gems/vagrant-triggers-0.5.2/lib/vagrant-triggers/action/trigger.rb:17:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
    from /home/jan/.vagrant.d/gems/gems/vagrant-triggers-0.5.2/lib/vagrant-triggers/action/trigger.rb:17:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
    from /home/jan/.vagrant.d/gems/gems/vagrant-triggers-0.5.2/lib/vagrant-triggers/action/trigger.rb:17:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/machine.rb:214:in `action_raw'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/machine.rb:191:in `block in action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/environment.rb:516:in `lock'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/machine.rb:178:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/machine.rb:178:in `action'
    from /home/jan/.vagrant.d/gems/gems/vagrant-openstack-provider-0.7.0/lib/vagrant-openstack-provider/provider.rb:25:in `ssh_info'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/machine.rb:415:in `ssh_info'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/ssh_exec.rb:26:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/call.rb:53:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
    from /home/jan/.vagrant.d/gems/gems/vagrant-openstack-provider-0.7.0/lib/vagrant-openstack-provider/action/connect_openstack.rb:32:in `execute'
    from /home/jan/.vagrant.d/gems/gems/vagrant-openstack-provider-0.7.0/lib/vagrant-openstack-provider/action/abstract_action.rb:8:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
    from /home/jan/.vagrant.d/gems/gems/vagrant-triggers-0.5.2/lib/vagrant-triggers/action/trigger.rb:17:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
    from /home/jan/.vagrant.d/gems/gems/vagrant-triggers-0.5.2/lib/vagrant-triggers/action/trigger.rb:17:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
    from /home/jan/.vagrant.d/gems/gems/vagrant-triggers-0.5.2/lib/vagrant-triggers/action/trigger.rb:17:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/action/runner.rb:66:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/machine.rb:214:in `action_raw'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/machine.rb:191:in `block in action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/machine.rb:174:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/machine.rb:174:in `block in action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/machine.rb:178:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/machine.rb:178:in `action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/commands/ssh/command.rb:59:in `block in execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/plugin/v2/command.rb:226:in `block in with_target_vms'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/plugin/v2/command.rb:220:in `each'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/plugin/v2/command.rb:220:in `with_target_vms'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/plugins/commands/ssh/command.rb:41:in `execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/cli.rb:42:in `execute'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/lib/vagrant/environment.rb:301:in `cli'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.4/bin/vagrant:174:in `<main>'
ggiamarchi commented 8 years ago

@visibilityspots Can you please rerun the command with debug enabled and provide the full log ?

export VAGRANT_OPENSTACK_LOG=debug

Can you also copy/paste your Vagrantfile ?

visibilityspots commented 8 years ago

I added the log to pastebin (will expire in one month) => http://pastebin.com/e3tcFfn6

the vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

require 'vagrant-openstack-provider'

VAGRANTFILE_API_VERSION = "2" 
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  unless Vagrant.has_plugin?("vagrant-hostmanager")
    raise 'vagrant-hostmanager plugin is not installed!'
  end 

  if Vagrant.has_plugin?("vagrant-hostmanager")
    config.hostmanager.enabled = true
    config.hostmanager.manage_host = true
  end 

  if Vagrant.has_plugin?("vagrant-cachier")
    config.cache.scope = :box
  end 

  config.vm.provider :openstack do|os, override|
    override.ssh.pty              = true
    override.vm.box               = "openstack"
    override.ssh.username         = "centos"
    override.vm.provision "shell", inline: "true"
    os.flavor                     = "2" 
    os.image                      = "centos"
    os.security_groups            = ['default']
    os.openstack_auth_url         = "http://192.168.91.11:5000/v2.0/tokens"
  end 

  config.vm.define :cpe do |cpe|
    cpe.vm.host_name = "cpe"

    cpe.vm.provider :openstack do |os, override|
      os.tenant_name                = "XX"
      os.keypair_name               = "XX"
      os.username                   = "XX"
      os.password                   = "XX"
      override.ssh.private_key_path = "XX"
      os.networks                   = [
        {   
          id: '016481cf-ef9f-4334-854d-564569024b29'
        }   
      ]   
    end 
    cpe.vm.synced_folder "hieradata", "/etc/hiera"
    cpe.vm.synced_folder "../../tooling/", "/opt/rpms"
    ext_env = ENV['VAGRANT_PUPPET_ENV']
    env = ext_env ? ext_env : config_env
    cpe.vm.synced_folder "puppet/environments/#{env}/modules", "/etc/puppet/environments/#{env}/modules"

    cpe.vm.provision :puppet do |puppet|
      puppet.options = "--environment #{env}"
      puppet.hiera_config_path = "hieradata/hiera.yaml"
      puppet.manifests_path = "puppet/environments/#{env}/manifests"
      puppet.manifest_file = ""
      puppet.module_path = "puppet/environments/production/modules"
    end 
  end 

end      
visibilityspots commented 8 years ago

I had this network configuration in my Vagrantfile:

os.networks                   = [
        {   
          id: '016481cf-ef9f-4334-854d-564569024b29'
        }   
      ]   

after some investigation and rereading the documentation I changed it to

os.networks                   = [
          '016481cf-ef9f-4334-854d-564569024b29'  
      ]   

this did solved the issue and I'm now able to use vagrant ssh to login into my vagrant instance.