mitchellh / vagrant-aws

Use Vagrant to manage your EC2 and VPC instances.
MIT License
2.61k stars 572 forks source link

Can't provision aws boxes #331

Open jayjanssen opened 9 years ago

jayjanssen commented 9 years ago

Any time I try to provision aws boxes on the latest vagrant-aws + vagrant, I get this error:

jayj@~/tmp/vagrant-test [553]$ vagrant up --provider=aws
Bringing machine 'default' up with 'aws' provider...
==> default: Warning! The AWS provider doesn't support any of the Vagrant
==> default: high-level network configurations (`config.vm.network`). They
==> default: will be silently ignored.
==> default: Launching an instance with the following settings...
==> default:  -- Type: m3.medium
==> default:  -- AMI: ami-e6ad348e
==> default:  -- Region: us-east-1
==> default:  -- Keypair: jay
==> default:  -- Block Device Mapping: []
==> default:  -- Terminate On Shutdown: false
==> default:  -- Monitoring: false
==> default:  -- EBS optimized: false
==> default:  -- Assigning a public IP address in a VPC: false
==> default: Waiting for instance to become "ready"...
==> default: Waiting for SSH to become available...
==> default: Machine is booted and ready for use!
No host IP was given to the Vagrant core NFS helper. This is
an internal error that should be reported as a bug.
jayj@~/tmp/vagrant-test [554]$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://atlas.hashicorp.com/search.
  config.vm.box = "perconajayj/centos-x86_64"

  config.vm.provider :aws do |aws, override|
    aws.access_key_id = "OMITTED"
    aws.secret_access_key = "OMITTED"
    aws.keypair_name = "jay"
        override.ssh.username = "root"
    override.ssh.private_key_path = "/Users/jayj/.ssh/jay-us-east-1.pem"
  end
end

I am able to ssh, just not provision.

jayj@~/tmp/vagrant-test [555]$ vagrant ssh
[root@ip-10-140-155-175 ~]# logout
Connection to 54.234.61.70 closed.
jayj@~/tmp/vagrant-test [556]$ vagrant --version
Vagrant 1.7.1
jayj@~/tmp/vagrant-test [557]$ vagrant plugin list
vagrant-aws (0.6.0)
vagrant-hostmanager (1.5.0)
  - Version Constraint: 1.5.0
vagrant-share (1.1.4, system)
vagrant-vmware-fusion (3.1.2)

This was working fine until my vagrant-aws upgrade from 0.5.0

kmizumar commented 9 years ago

I'm facing exactly the same problem with vagrant 1.7.1 + vagrant-aws 0.6.0

Does anyone know any workarounds?

On Thu, Dec 18, 2014 at 9:38 PM, Jay Janssen notifications@github.com wrote:

Any time I try to provision aws boxes on the latest vagrant-aws + vagrant, I get this error:

jayj@~/tmp/vagrant-test [553]$ vagrant up --provider=aws Bringing machine 'default' up with 'aws' provider... ==> default: Warning! The AWS provider doesn't support any of the Vagrant ==> default: high-level network configurations (config.vm.network). They ==> default: will be silently ignored. ==> default: Launching an instance with the following settings... ==> default: -- Type: m3.medium ==> default: -- AMI: ami-e6ad348e ==> default: -- Region: us-east-1 ==> default: -- Keypair: jay ==> default: -- Block Device Mapping: [] ==> default: -- Terminate On Shutdown: false ==> default: -- Monitoring: false ==> default: -- EBS optimized: false ==> default: -- Assigning a public IP address in a VPC: false ==> default: Waiting for instance to become "ready"... ==> default: Waiting for SSH to become available... ==> default: Machine is booted and ready for use! No host IP was given to the Vagrant core NFS helper. This is an internal error that should be reported as a bug. jayj@~/tmp/vagrant-test [554]$ cat Vagrantfile

-- mode: ruby --

vi: set ft=ruby :

All Vagrant configuration is done below. The "2" in Vagrant.configure

configures the configuration version (we support older styles for

backwards compatibility). Please don't change it unless you know what

you're doing.

Vagrant.configure(2) do |config|

The most common configuration options are documented and commented below.

For a complete reference, please see the online documentation at

https://docs.vagrantup.com.

Every Vagrant development environment requires a box. You can search for

boxes at https://atlas.hashicorp.com/search.

config.vm.box = "perconajayj/centos-x86_64"

config.vm.provider :aws do |aws, override| aws.access_key_id = "OMITTED" aws.secret_access_key = "OMITTED" aws.keypair_name = "jay" override.ssh.username = "root" override.ssh.private_key_path = "/Users/jayj/.ssh/jay-us-east-1.pem" end end

I am able to ssh, just not provision.

jayj@~/tmp/vagrant-test [555]$ vagrant ssh [root@ip-10-140-155-175 ~]# logout Connection to 54.234.61.70 closed. jayj@~/tmp/vagrant-test [556]$ vagrant --version Vagrant 1.7.1 jayj@~/tmp/vagrant-test [557]$ vagrant plugin list vagrant-aws (0.6.0) vagrant-hostmanager (1.5.0)

  • Version Constraint: 1.5.0 vagrant-share (1.1.4, system) vagrant-vmware-fusion (3.1.2)

This was working fine until my vagrant-aws upgrade from 0.5.0

— Reply to this email directly or view it on GitHub https://github.com/mitchellh/vagrant-aws/issues/331.

jayjanssen commented 9 years ago

Downgrading vagrant-aws back to 0.5.0 worked for me in the interim.

On Dec 19, 2014, at 1:36 AM, Kiyoshi Mizumaru notifications@github.com wrote:

Does anyone know any workarounds?

Jay Janssen, Managing Consultant, Percona http://about.me/jay.janssen

kmizumar commented 9 years ago

Yeah, I know. But 0.5.0 cannot assign existing elastic_ip to ec2 instance, it always allocate a new elastic_ip. I'm now trying to build vagrant and aws plugin from Github and see how I can avoid this problem.

2014年12月19日金曜日、Jay Janssennotifications@github.comさんは書きました:

Downgrading vagrant-aws back to 0.5.0 worked for me in the interim.

On Dec 19, 2014, at 1:36 AM, Kiyoshi Mizumaru <notifications@github.com javascript:_e(%7B%7D,'cvml','notifications@github.com');> wrote:

Does anyone know any workarounds?

Jay Janssen, Managing Consultant, Percona http://about.me/jay.janssen

— Reply to this email directly or view it on GitHub https://github.com/mitchellh/vagrant-aws/issues/331#issuecomment-67633344 .

zquestz commented 9 years ago

I am also having this issue. I specifically use rsync and it still complains. If anyone has suggestions please share!

nvtkaszpir commented 9 years ago

Had similiar issue (also hit that bug https://github.com/mitchellh/vagrant-aws/issues/327#issuecomment-67313102 but replaced certs and it works) : Ubuntu 13.10 vagrant 1.7.1

vagrant-aws (0.6.0) vagrant-cachier (1.1.0) vagrant-hostsupdater (0.0.11) vagrant-kvm (0.1.9) vagrant-libvirt (0.0.24) vagrant-mutate (0.3.1) vagrant-share (1.1.4) vagrant-vbguest (0.10.0) vagrant-windows (1.6.0)

Downgrading to 0.5.0 fixes that error message. vagrant plugin install vagrant-aws --plugin-version 0.5.0

kmizumar commented 9 years ago

Vagrant 1.7.1's SyncedFolders won't work with Vagrant AWS plugin.

So I made a patch to revive previous custom SyncedFolders and this works for me.

[ https://github.com/kmizumar/vagrant-aws branch: modified ]

% git diff v0.6.0 HEAD

diff --git a/CHANGELOG.md b/CHANGELOG.md

index 4600e19..5cd9e92 100644

--- a/CHANGELOG.md

+++ b/CHANGELOG.md

@@ -1,6 +1,11 @@

-# 0.5.1

+# 0.6.1 (January 6, 2015)

+

+* Quick and Dirty Hack to avoid Vagrant SyncedFolders problem.

+

+# 0.6.0 (December 13, 2014)

+* Support for creating AMIs with the vagrant package

0.5.0 (June 22, 2014)

@@ -12,6 +17,8 @@

+* Simple ELB support (GH #88,

diff --git a/README.md b/README.md

index a9a476e..fc853b7 100644

--- a/README.md

+++ b/README.md

@@ -137,6 +137,7 @@ This provider exposes quite a few provider-specific configuration options:

+* elb - The ELB name to attach to the instance.

These can be set like typical provider-specific configuration:

@@ -195,7 +196,8 @@ There is minimal support for synced folders. Upon vagrant up,

rsync (if available) to uni-directionally sync the folder to

the remote machine over SSH.

-See Vagrant Synced folders: rsync

+This is good enough for all built-in Vagrant provisioners (shell,

+chef, and puppet) to work!

Other Examples

@@ -249,7 +251,7 @@ Vagrant.configure("2") do |config|

end


-### Elastic Load Balancers

+### ELB (Elastic Load Balancers)

 You can automatically attach an instance to an ELB during boot and detach
on destroy.

diff --git a/lib/vagrant-aws/action.rb b/lib/vagrant-aws/action.rb

index 2e7d3d5..8def51d 100644

--- a/lib/vagrant-aws/action.rb

+++ b/lib/vagrant-aws/action.rb

@@ -73,7 +73,7 @@ module VagrantPlugins

             end

             b2.use Provision

-            b2.use SyncedFolders

+            b2.use SyncFolders

           end

         end

       end

@@ -132,7 +132,7 @@ module VagrantPlugins

       def self.action_prepare_boot

         Vagrant::Action::Builder.new.tap do |b|

           b.use Provision

-          b.use SyncedFolders

+          b.use SyncFolders

           b.use WarnNetworks

           b.use ElbRegisterInstance

         end

@@ -143,6 +143,7 @@ module VagrantPlugins

         Vagrant::Action::Builder.new.tap do |b|

           b.use HandleBox

           b.use ConfigValidate

+          b.use BoxCheckOutdated

           b.use ConnectAWS

           b.use Call, IsCreated do |env1, b1|

             if env1[:result]

@@ -198,6 +199,7 @@ module VagrantPlugins

       autoload :RunInstance, action_root.join("run_instance")

       autoload :StartInstance, action_root.join("start_instance")

       autoload :StopInstance, action_root.join("stop_instance")

+      autoload :SyncFolders, action_root.join("sync_folders")

       autoload :TerminateInstance, action_root.join("terminate_instance")

       autoload :TimedProvision, action_root.join("timed_provision") # some
plugins now expect this action to exist

       autoload :WaitForState, action_root.join("wait_for_state")

diff --git a/lib/vagrant-aws/action/sync_folders.rb
b/lib/vagrant-aws/action/sync_folders.rb

new file mode 100644

index 0000000..2680798

--- /dev/null

+++ b/lib/vagrant-aws/action/sync_folders.rb

@@ -0,0 +1,130 @@

+require "log4r"

+

+require "vagrant/util/subprocess"

+

+require "vagrant/util/scoped_hash_override"

+

+require "vagrant/util/which"

+

+module VagrantPlugins

+  module AWS

+    module Action

+      # This middleware uses `rsync` to sync the folders over to the

+      # AWS instance.

+      class SyncFolders

+        include Vagrant::Util::ScopedHashOverride

+

+        def initialize(app, env)

+          @app    = app

+          @logger = Log4r::Logger.new("vagrant_aws::action::sync_folders")

+        end

+

+        def call(env)

+          @app.call(env)

+

+          ssh_info = env[:machine].ssh_info

+

+          unless Vagrant::Util::Which.which('rsync')

+            env[:ui].warn(I18n.t('vagrant_aws.rsync_not_found_warning',
:side => "host"))

+            return

+          end

+

+          if env[:machine].communicate.execute('which rsync', :error_check
=> false) != 0

+            env[:ui].warn(I18n.t('vagrant_aws.rsync_not_found_warning',
:side => "guest"))

+            return

+          end

+

+          env[:machine].config.vm.synced_folders.each do |id, data|

+            data = scoped_hash_override(data, :aws)

+

+            # Ignore disabled shared folders

+            next if data[:disabled]

+

+            hostpath  = File.expand_path(data[:hostpath], env[:root_path])

+            guestpath = data[:guestpath]

+

+            # Make sure there is a trailing slash on the host path to

+            # avoid creating an additional directory with rsync

+            hostpath = "#{hostpath}/" if hostpath !~ /\/$/

+

+            # on windows rsync.exe requires cygdrive-style paths

+            if Vagrant::Util::Platform.windows?

+              hostpath = hostpath.gsub(/^(\w):/) { "/cygdrive/#{$1}" }

+            end

+

+            env[:ui].info(I18n.t("vagrant_aws.rsync_folder",

+                                :hostpath => hostpath,

+                                :guestpath => guestpath))

+

+            # Create the host path if it doesn't exist and option flag is
set

+            if data[:create]

+              begin

+                FileUtils::mkdir_p(hostpath)

+              rescue => err

+                raise Errors::MkdirError,

+                  :hostpath => hostpath,

+                  :err => err

+              end

+            end

+

+            # Create the guest path

+            env[:machine].communicate.sudo("mkdir -p '#{guestpath}'")

+            env[:machine].communicate.sudo(

+              "chown -R #{ssh_info[:username]} '#{guestpath}'")

+

+            #collect rsync excludes specified
:rsync_excludes=>['path1',...] in synced_folder options

+            excludes = ['.vagrant/', 'Vagrantfile',
*Array(data[:rsync_excludes])].uniq

+

+            ssh_options = ["StrictHostKeyChecking=no"]

+     # Use proxy command if it's set

+            if ssh_info[:proxy_command]

+              ssh_options.push("ProxyCommand #{ssh_info[:proxy_command]}")

+            end

+

+            # Rsync over to the guest path using the SSH info

+            command = [

+              "rsync", "--verbose", "--archive", "-z", "--delete",

+              *excludes.map{|e|['--exclude', e]}.flatten,

+              "-e", "ssh -p #{ssh_info[:port]}
#{ssh_key_options(ssh_info)} " +

+              ssh_options_to_args(ssh_options).join(' '),

+              hostpath,

+              "#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"]

+

+            # we need to fix permissions when using rsync.exe on windows,
see

+            #
http://stackoverflow.com/questions/5798807/rsync-permission-denied-created-directories-have-no-permissions

+            if Vagrant::Util::Platform.windows?

+              command.insert(1, "--chmod", "ugo=rwX")

+            end

+

+            r = Vagrant::Util::Subprocess.execute(*command)

+            if r.exit_code != 0

+              raise Errors::RsyncError,

+                :guestpath => guestpath,

+                :hostpath => hostpath,

+                :stderr => r.stderr

+            end

+          end

+        end

+

+        # Generate a ssh(1) command line list of options

+        #

+        # @param [Array] options An array of ssh options. E.g.

+        #   `StrictHostKeyChecking=no` see ssh_config(5) for more

+        # @return [Array] Computed list of command line arguments

+        def ssh_options_to_args(options)

+          # Bail early if we get something that is not an array of options

+          return [] unless options

+

+          return options.map { |o| "-o '#{o}'" }

+        end

+

+        private

+

+        def ssh_key_options(ssh_info)

+          # Ensure that `private_key_path` is an Array (for Vagrant < 1.4)

+          Array(ssh_info[:private_key_path]).map { |path| "-i '#{path}' "
}.join

+        end

+      end

+    end

+  end

+end

diff --git a/lib/vagrant-aws/version.rb b/lib/vagrant-aws/version.rb

index db63150..2a770d6 100644

--- a/lib/vagrant-aws/version.rb

+++ b/lib/vagrant-aws/version.rb

@@ -1,5 +1,5 @@

 module VagrantPlugins

   module AWS

-    VERSION = '0.6.0'

+    VERSION = '0.6.1'

   end

 end

diff --git a/spec/vagrant-aws/actions/syncfolders_spec.rb
b/spec/vagrant-aws/actions/syncfolders_spec.rb

new file mode 100644

index 0000000..c80c52a

--- /dev/null

+++ b/spec/vagrant-aws/actions/syncfolders_spec.rb

@@ -0,0 +1,28 @@

+require 'spec_helper'

+require 'vagrant-aws/action/sync_folders'

+

+describe VagrantPlugins::AWS::Action::SyncFolders do

+  let(:app) { nil }

+  let(:env) { {} }

+  subject(:action) { described_class.new(app, env) }

+

+  describe '#ssh_options_to_args' do

+    subject(:args) { action.ssh_options_to_args(options) }

+

+    context 'with no ssh options' do

+      let(:options) { [] }

+

+      it { should eql [] }

+    end

+

+    context 'with one option' do

+      let(:options) { ['StrictHostKeyChecking=no'] }

+      it { should eql ["-o 'StrictHostKeyChecking=no'"] }

+    end

+

+    context 'with multiple options' do

+      let(:options) { ['SHKC=no', 'Port=222'] }

+      it { should eql ["-o 'SHKC=no'", "-o 'Port=222'"] }

+    end

+  end

+end

On Wed, Dec 31, 2014 at 8:54 PM, Michał Sochoń <notifications@github.com>
wrote:

> Had similiar issue (also hit that bug #327 (comment)
> <https://github.com/mitchellh/vagrant-aws/issues/327#issuecomment-67313102>
> but replacet certs and it works) :
> Ubuntu 13.10
> vagrant 1.7.1
>
> vagrant-aws (0.5.0)
>
>    - Version Constraint: 0.5.0 vagrant-cachier (1.1.0)
>    vagrant-hostsupdater (0.0.11) vagrant-kvm (0.1.9) vagrant-libvirt (0.0.24)
>    vagrant-mutate (0.3.1) vagrant-share (1.1.4) vagrant-vbguest (0.10.0)
>    vagrant-windows (1.6.0)
>
> Downgrading to 0.5.0 fixes that error message.
> ```vagrant plugin install vagrant-aws --plugin-version 0.5.0
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/mitchellh/vagrant-aws/issues/331#issuecomment-68437892>
> .
>
woodcoder commented 9 years ago

I also had this problem and worked around it successfully by either disabling the default /vagrant file sync (my ansible provisioner doesn't need it) by using:

    config.vm.synced_folder ".", "/vagrant", disabled: true

Or if you need it, by switching from the default NFS to use rsync using:

    config.vm.synced_folder ".", "/vagrant", type: "rsync"

It'd be nice for it to work out of the box though!

ghost commented 9 years ago

Would be nice to see this addressed. For some reason, Vagrant 1.7.2 + vagrant-aws 0.6.0 works fine for me on Mac, but the exact same versions and configuration fails on Linux with this error.

I already had /vagrant disabled, but to work around this, I had to manually specify type: "rsync" for all my other synced_folders.

jhoblitt commented 9 years ago

There is a work around suggested in this blog post: http://blog.damore.it/2015/01/aws-vagrant-no-host-ip-was-given-to.html that worked for me.

 config.vm.provider :aws do |aws, override|
    ...
    override.nfs.functional = false
  end