From 52f7c53707cab700dd04502d59c8d9d7fea752e1 Mon Sep 17 00:00:00 2001 From: Tawan Sierek Date: Sun, 12 May 2013 16:32:15 +0300 Subject: [PATCH 01/21] Fix typo. --- lib/vagrant/machine_state.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant/machine_state.rb b/lib/vagrant/machine_state.rb index 9dcfffa3d..6da2996e9 100644 --- a/lib/vagrant/machine_state.rb +++ b/lib/vagrant/machine_state.rb @@ -3,7 +3,7 @@ module Vagrant # class that simply stores a short and long description of the state # of a machine. # - # The state also stores a state "id" which ca be used as a unique + # The state also stores a state "id" which can be used as a unique # identifier for a state. This should be a symbol. This allows internal # code to compare state such as ":not_created" instead of using # string comparison. From 579e591dfbf6234c765e5d5b9f09458a017b10ea Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Mon, 24 Jun 2013 11:56:43 -0400 Subject: [PATCH 02/21] Remove JSON gem dependency --- vagrant.gemspec | 1 - 1 file changed, 1 deletion(-) diff --git a/vagrant.gemspec b/vagrant.gemspec index bcf427004..7a900c0b2 100644 --- a/vagrant.gemspec +++ b/vagrant.gemspec @@ -17,7 +17,6 @@ Gem::Specification.new do |s| s.add_dependency "childprocess", "~> 0.3.7" s.add_dependency "erubis", "~> 2.7.0" s.add_dependency "i18n", "~> 0.6.0" - s.add_dependency "json", ">= 1.5.1", "< 1.8.0" s.add_dependency "log4r", "~> 1.1.9" s.add_dependency "net-ssh", "~> 2.6.6" s.add_dependency "net-scp", "~> 1.1.0" From d95b202346e947ce36614596b184f48369173c47 Mon Sep 17 00:00:00 2001 From: Thomas Linkin Date: Mon, 24 Jun 2013 13:00:03 -0400 Subject: [PATCH 03/21] Vagrant::Action::Builder RDoc correction The RDoc comments for `Vagrant::Action::Builder#to_app` reference an instance of `Vagrant::Action::Environment` as the passed paramter. There is no class `Vagrant::Action::Environment` available. The param being passed is actually a `Hash` that represents the "action environment". This commit corrects the RDoc lines for `Vagrant::Action::Builder#to_app` to correctly reference the passed `Hash`. --- lib/vagrant/action/builder.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant/action/builder.rb b/lib/vagrant/action/builder.rb index aaf94d7ce..5adc635f8 100644 --- a/lib/vagrant/action/builder.rb +++ b/lib/vagrant/action/builder.rb @@ -131,7 +131,7 @@ module Vagrant # Converts the builder stack to a runnable action sequence. # - # @param [Vagrant::Action::Environment] env The action environment + # @param [Hash] env The action environment hash # @return [Object] A callable object def to_app(env) app_stack = nil From b0b18c64ddb5648d78cf34f814f296463f258725 Mon Sep 17 00:00:00 2001 From: Emiliano Ticci Date: Tue, 9 Jul 2013 14:35:07 +0200 Subject: [PATCH 04/21] Raise a proper SSH error on EHOSTUNREACH --- lib/vagrant/errors.rb | 4 ++++ plugins/communicators/ssh/communicator.rb | 3 +++ templates/locales/en.yml | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index dc24536d3..7f1ce463c 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -455,6 +455,10 @@ module Vagrant error_key(:ssh_key_type_not_supported) end + class SSHNoRoute < VagrantError + error_key(:ssh_no_route) + end + class SSHNotReady < VagrantError error_key(:ssh_not_ready) end diff --git a/plugins/communicators/ssh/communicator.rb b/plugins/communicators/ssh/communicator.rb index 00c058155..2dea21e33 100644 --- a/plugins/communicators/ssh/communicator.rb +++ b/plugins/communicators/ssh/communicator.rb @@ -235,6 +235,9 @@ module VagrantPlugins rescue Errno::EHOSTDOWN # This is raised if we get an ICMP DestinationUnknown error. raise Vagrant::Errors::SSHHostDown + rescue Errno::EHOSTUNREACH + # This is raised if we can't work out how to route traffic. + raise Vagrant::Errors::SSHNoRoute rescue NotImplementedError # This is raised if a private key type that Net-SSH doesn't support # is used. Show a nicer error. diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 070e2a05f..3f7aa97b2 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -426,6 +426,10 @@ en: usually indicates that SSH within the guest machine was unable to properly start up. Please boot the VM in GUI mode to check whether it is booting properly. + ssh_no_route: |- + While attempting to connect with SSH, a "no route to host" (EHOSTUNREACH) + error was received. Please verify your network settings are correct + and try again. ssh_host_down: |- While attempting to connect with SSH, a "host is down" (EHOSTDOWN) error was received. Please verify your SSH settings are correct From 6b5f386d18792605eb7c7f8ee190ec5d50997bfd Mon Sep 17 00:00:00 2001 From: emyl Date: Tue, 9 Jul 2013 17:32:37 +0200 Subject: [PATCH 05/21] Remove duplicate entry in en.yml Key vagrant.config.vm.network_ip_required appears twice. Remove the unused entry. --- templates/locales/en.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 070e2a05f..83e4112ae 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -605,8 +605,6 @@ en: network_invalid: |- The network type '%{type}' is not valid. Please use 'hostonly' or 'bridged'. - network_ip_required: |- - Host only networks require an IP as an argument. network_ip_invalid: |- The host only network IP '%{ip}' is invalid. network_ip_ends_one: |- From 442300794ec0f43b77f2d4ea7b8864a0189f968a Mon Sep 17 00:00:00 2001 From: Brett Stauner Date: Tue, 9 Jul 2013 15:47:49 -0500 Subject: [PATCH 06/21] Support Fedora when it was "Fedora Core" The version_number regex was causing an error because my /etc/redhat-release looks like this: Fedora Core release 6 (Zod) This fix allowed initialize to run just fine on my ridiculously old release. --- plugins/hosts/fedora/host.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hosts/fedora/host.rb b/plugins/hosts/fedora/host.rb index a61298877..40b1ca33d 100644 --- a/plugins/hosts/fedora/host.rb +++ b/plugins/hosts/fedora/host.rb @@ -34,7 +34,7 @@ module VagrantPlugins release_file = Pathname.new("/etc/redhat-release") begin release_file.open("r") do |f| - version_number = /Fedora release ([0-9]+)/.match(f.gets)[1].to_i + version_number = /Fedora.*release ([0-9]+)/.match(f.gets)[1].to_i if version_number >= 16 # "service nfs-server" will redirect properly to systemctl # when "service nfs-server restart" is called. From 5cbfbdf2d286c9a8e6ced794885ecde0adf91c7b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 9 Jul 2013 16:45:46 -0700 Subject: [PATCH 07/21] Update CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06c06bd6c..576110d24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,8 @@ IMPROVEMENTS: - Default SSH forwarded port now binds to 127.0.0.1 so only local connections are allowed. [GH-1785] - Use `netctl` for Arch Linux network configuration. [GH-1760] + - Improve fedora host detection regular expression. [GH-1913] + - SSH shows a proper error on EHOSTUNREACH. [GH-1911] BUG FIXES: From 95d308caaecd139b8f62e41e7add0ec3f8ae3bd1 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 9 Jul 2013 17:01:01 -0700 Subject: [PATCH 08/21] v1.2.3 --- CHANGELOG.md | 2 +- lib/vagrant/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 576110d24..1230350c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.2.3 (unreleased) +## 1.2.3 (July 9, 2013) FEATURES: diff --git a/lib/vagrant/version.rb b/lib/vagrant/version.rb index 142f9d08d..21043d288 100644 --- a/lib/vagrant/version.rb +++ b/lib/vagrant/version.rb @@ -2,5 +2,5 @@ module Vagrant # This will always be up to date with the current version of Vagrant, # since it is used to generate the gemspec and is also the source of # the version for `vagrant -v` - VERSION = "1.2.3.dev" + VERSION = "1.2.3" end From abd22dfe72eedc74f1e41a1d0d6095e25bd87c72 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 9 Jul 2013 19:10:56 -0700 Subject: [PATCH 09/21] Up version for development --- CHANGELOG.md | 4 ++++ lib/vagrant/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1230350c6..d38bdba0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.2.4 (unreleased) + + + ## 1.2.3 (July 9, 2013) FEATURES: diff --git a/lib/vagrant/version.rb b/lib/vagrant/version.rb index 21043d288..8d7a911e8 100644 --- a/lib/vagrant/version.rb +++ b/lib/vagrant/version.rb @@ -2,5 +2,5 @@ module Vagrant # This will always be up to date with the current version of Vagrant, # since it is used to generate the gemspec and is also the source of # the version for `vagrant -v` - VERSION = "1.2.3" + VERSION = "1.2.4.dev" end From 2657364921e17233d590651fefa1648ca787cba9 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 10 Jul 2013 14:19:57 -0700 Subject: [PATCH 10/21] Exported sub-directories of exported NFS dirs works on BSD [GH-785] --- CHANGELOG.md | 3 ++ plugins/hosts/bsd/host.rb | 47 ++++++++++++++++++++++++++++++- templates/nfs/exports.erb | 4 +-- templates/nfs/exports_freebsd.erb | 4 +-- 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d38bdba0f..212c3527e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ ## 1.2.4 (unreleased) +BUG FIXES: + - core/nfs: Exporting sub-directories of other exported folders now + works properly. [GH-785] ## 1.2.3 (July 9, 2013) diff --git a/plugins/hosts/bsd/host.rb b/plugins/hosts/bsd/host.rb index 0aee78f48..e51878ade 100644 --- a/plugins/hosts/bsd/host.rb +++ b/plugins/hosts/bsd/host.rb @@ -35,10 +35,55 @@ module VagrantPlugins end def nfs_export(id, ip, folders) + # We need to build up mapping of directories that are enclosed + # within each other because the exports file has to have subdirectories + # of an exported directory on the same line. e.g.: + # + # "/foo" "/foo/bar" ... + # "/bar" + # + # We build up this mapping within the following hash. + @logger.debug("Compiling map of sub-directories for NFS exports...") + dirmap = {} + folders.each do |_, opts| + hostpath = opts[:hostpath] + + found = false + dirmap.each do |dirs, diropts| + dirs.each do |dir| + if dir.start_with?(hostpath) || hostpath.start_with?(dir) + # TODO: verify opts and diropts are _identical_, raise an error + # if not. NFS mandates subdirectories have identical options. + dirs << hostpath + found = true + break + end + end + + break if found + end + + if !found + dirmap[[hostpath]] = opts.dup + end + end + + # Sort all the keys by length so that the directory closest to + # the root is exported first. + dirmap.each do |dirs, _| + dirs.sort_by! { |d| d.length } + end + + @logger.info("Exporting the following for NFS...") + dirmap.each do |dirs, opts| + @logger.info("NFS DIR: #{dirs.inspect}") + @logger.info("NFS OPTS: #{opts.inspect}") + end + output = TemplateRenderer.render(@nfs_exports_template, :uuid => id, :ip => ip, - :folders => folders) + :folders => dirmap) # The sleep ensures that the output is truly flushed before any `sudo` # commands are issued. diff --git a/templates/nfs/exports.erb b/templates/nfs/exports.erb index 5bc241f5b..5b437cbfd 100644 --- a/templates/nfs/exports.erb +++ b/templates/nfs/exports.erb @@ -1,5 +1,5 @@ # VAGRANT-BEGIN: <%= uuid %> -<% folders.each do |name, opts| %> -"<%= opts[:hostpath] %>" <%= ip %><% if opts[:map_uid] -%> -mapall=<%= [opts[:map_uid],opts[:map_gid]].compact.join(":") %><% end -%> +<% folders.each do |dirs, opts| %> +<%= dirs.map { |d| "\"#{d}\"" }.join(" ") %> <%= ip %><% if opts[:map_uid] -%> -mapall=<%= [opts[:map_uid],opts[:map_gid]].compact.join(":") %><% end -%> <% end %> # VAGRANT-END: <%= uuid %> diff --git a/templates/nfs/exports_freebsd.erb b/templates/nfs/exports_freebsd.erb index 59dbd83be..e421ab394 100644 --- a/templates/nfs/exports_freebsd.erb +++ b/templates/nfs/exports_freebsd.erb @@ -1,5 +1,5 @@ # VAGRANT-BEGIN: <%= uuid %> -<% folders.each do |name, opts| %> -<%= opts[:hostpath] %> <%= ip %><% if opts[:map_uid] -%> -alldirs -mapall=<%= [opts[:map_uid],opts[:map_gid]].compact.join(":") %><% end -%> +<% folders.each do |dirs, opts| %> +<%= dirs.map { |d| "\"#{d}\"" }.join(" ") %> <%= ip %><% if opts[:map_uid] -%> -alldirs -mapall=<%= [opts[:map_uid],opts[:map_gid]].compact.join(":") %><% end -%> <% end %> # VAGRANT-END: <%= uuid %> From 56adfec96e11f2972d72d806036e17eebf22ef22 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 10 Jul 2013 19:31:52 -0700 Subject: [PATCH 11/21] Chef can have a custom configuration file set. [GH-876] --- CHANGELOG.md | 6 ++++++ plugins/provisioners/chef/config/base.rb | 19 +++++++++++++++++++ .../provisioners/chef/config/chef_client.rb | 1 + plugins/provisioners/chef/config/chef_solo.rb | 1 + plugins/provisioners/chef/provisioner/base.rb | 14 +++++++++++++- templates/locales/en.yml | 2 ++ templates/provisioners/chef_client/client.erb | 4 ++++ templates/provisioners/chef_solo/solo.erb | 4 ++++ 8 files changed, 50 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 212c3527e..f532dcaf9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## 1.2.4 (unreleased) +FEATURES: + + - Chef solo and client provisioning now support a `custom_config_path` + setting that accepts a path to a Ruby file to load as part of Chef + configuration, allowing you to override any setting available. [GH-876] + BUG FIXES: - core/nfs: Exporting sub-directories of other exported folders now diff --git a/plugins/provisioners/chef/config/base.rb b/plugins/provisioners/chef/config/base.rb index 9334b6dd5..463755692 100644 --- a/plugins/provisioners/chef/config/base.rb +++ b/plugins/provisioners/chef/config/base.rb @@ -6,6 +6,7 @@ module VagrantPlugins attr_accessor :attempts attr_accessor :binary_path attr_accessor :binary_env + attr_accessor :custom_config_path attr_accessor :http_proxy attr_accessor :http_proxy_user attr_accessor :http_proxy_pass @@ -26,6 +27,7 @@ module VagrantPlugins @attempts = UNSET_VALUE @binary_path = UNSET_VALUE @binary_env = UNSET_VALUE + @custom_config_path = UNSET_VALUE @http_proxy = UNSET_VALUE @http_proxy_user = UNSET_VALUE @http_proxy_pass = UNSET_VALUE @@ -46,6 +48,7 @@ module VagrantPlugins @attempts = 1 if @attempts == UNSET_VALUE @binary_path = nil if @binary_path == UNSET_VALUE @binary_env = nil if @binary_env == UNSET_VALUE + @custom_config_path = nil if @custom_config_path == UNSET_VALUE @http_proxy = nil if @http_proxy == UNSET_VALUE @http_proxy_user = nil if @http_proxy_user == UNSET_VALUE @http_proxy_pass = nil if @http_proxy_pass == UNSET_VALUE @@ -68,6 +71,22 @@ module VagrantPlugins end end + # Just like the normal configuration "validate" method except that + # it returns an array of errors that should be merged into some + # other error accumulator. + def validate_base(machine) + errors = [] + + if @custom_config_path + expanded = File.expand_path(@custom_config_path, machine.env.root_path) + if !File.file?(expanded) + errors << I18n.t("vagrant.config.chef.custom_config_path_missing") + end + end + + errors + end + # Adds a recipe to the run list def add_recipe(name) name = "recipe[#{name}]" unless name =~ /^recipe\[(.+?)\]$/ diff --git a/plugins/provisioners/chef/config/chef_client.rb b/plugins/provisioners/chef/config/chef_client.rb index ad536067d..899927213 100644 --- a/plugins/provisioners/chef/config/chef_client.rb +++ b/plugins/provisioners/chef/config/chef_client.rb @@ -44,6 +44,7 @@ module VagrantPlugins def validate(machine) errors = _detected_errors + errors.concat(validate_base(machine)) errors << I18n.t("vagrant.config.chef.server_url_empty") if \ !chef_server_url || chef_server_url.strip == "" errors << I18n.t("vagrant.config.chef.validation_key_path") if \ diff --git a/plugins/provisioners/chef/config/chef_solo.rb b/plugins/provisioners/chef/config/chef_solo.rb index 2268dccb5..f3054627d 100644 --- a/plugins/provisioners/chef/config/chef_solo.rb +++ b/plugins/provisioners/chef/config/chef_solo.rb @@ -59,6 +59,7 @@ module VagrantPlugins def validate(machine) errors = _detected_errors + errors.concat(validate_base(machine)) errors << I18n.t("vagrant.config.chef.cookbooks_path_empty") if \ !cookbooks_path || [cookbooks_path].flatten.empty? diff --git a/plugins/provisioners/chef/provisioner/base.rb b/plugins/provisioners/chef/provisioner/base.rb index f201234c2..180ce6e1b 100644 --- a/plugins/provisioners/chef/provisioner/base.rb +++ b/plugins/provisioners/chef/provisioner/base.rb @@ -47,14 +47,26 @@ module VagrantPlugins end def setup_config(template, filename, template_vars) + # If we have custom configuration, upload it + remote_custom_config_path = nil + if @config.custom_config_path + expanded = File.expand_path( + @config.custom_config_path, @machine.env.root_path) + remote_custom_config_path = File.join( + config.provisioning_path, "custom-config.rb") + + @machine.communicate.upload(expanded, remote_custom_config_path) + end + config_file = Vagrant::Util::TemplateRenderer.render(template, { - :log_level => @config.log_level.to_sym, + :custom_configuration => remote_custom_config_path, :http_proxy => @config.http_proxy, :http_proxy_user => @config.http_proxy_user, :http_proxy_pass => @config.http_proxy_pass, :https_proxy => @config.https_proxy, :https_proxy_user => @config.https_proxy_user, :https_proxy_pass => @config.https_proxy_pass, + :log_level => @config.log_level.to_sym, :no_proxy => @config.no_proxy }.merge(template_vars)) diff --git a/templates/locales/en.yml b/templates/locales/en.yml index d7d1fb39b..b0c252e7b 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -588,6 +588,8 @@ en: cookbooks_path_empty: "Must specify a cookbooks path for chef solo." cookbooks_path_missing: |- Cookbook path doesn't exist: %{path} + custom_config_path_missing: |- + Path specified for "custom_config_path" does not exist. server_url_empty: "Chef server URL must be populated." validation_key_path: "Validation key path must be valid path to your chef server validation key." loader: diff --git a/templates/provisioners/chef_client/client.erb b/templates/provisioners/chef_client/client.erb index 44c24fe26..23c3f68de 100644 --- a/templates/provisioners/chef_client/client.erb +++ b/templates/provisioners/chef_client/client.erb @@ -30,3 +30,7 @@ no_proxy <%= no_proxy.inspect %> pid_file "/var/run/chef/chef-client.pid" Mixlib::Log::Formatter.show_time = true + +<% if custom_configuration -%> +load "<%= custom_configuration %>" +<% end -%> diff --git a/templates/provisioners/chef_solo/solo.erb b/templates/provisioners/chef_solo/solo.erb index 10a108437..c969ba77e 100644 --- a/templates/provisioners/chef_solo/solo.erb +++ b/templates/provisioners/chef_solo/solo.erb @@ -25,3 +25,7 @@ https_proxy <%= https_proxy.inspect %> https_proxy_user <%= https_proxy_user.inspect %> https_proxy_pass <%= https_proxy_pass.inspect %> no_proxy <%= no_proxy.inspect %> + +<% if custom_configuration -%> +load "<%= custom_configuration %>" +<% end -%> From f38b6801f9b5521bd5923a638de05cc3f0f93adc Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 10 Jul 2013 19:39:20 -0700 Subject: [PATCH 12/21] vagrant destroy exits with 1 if any confirmation are declined [GH-923] --- CHANGELOG.md | 5 +++++ lib/vagrant/action/builtin/confirm.rb | 1 + plugins/commands/destroy/command.rb | 11 ++++++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f532dcaf9..5bf66230d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ FEATURES: setting that accepts a path to a Ruby file to load as part of Chef configuration, allowing you to override any setting available. [GH-876] +IMPROVEMENTS: + + - `vagrant destroy` returns exit status 1 if any of the confirmations + are declined. [GH-923] + BUG FIXES: - core/nfs: Exporting sub-directories of other exported folders now diff --git a/lib/vagrant/action/builtin/confirm.rb b/lib/vagrant/action/builtin/confirm.rb index 8f490e050..7fc6aabbf 100644 --- a/lib/vagrant/action/builtin/confirm.rb +++ b/lib/vagrant/action/builtin/confirm.rb @@ -29,6 +29,7 @@ module Vagrant # The result is only true if the user said "Y" env[:result] = choice && choice.upcase == "Y" + env["#{@force_key}_result".to_sym] = env[:result] @app.call(env) end diff --git a/plugins/commands/destroy/command.rb b/plugins/commands/destroy/command.rb index 3b245f035..e4ac0d6a1 100644 --- a/plugins/commands/destroy/command.rb +++ b/plugins/commands/destroy/command.rb @@ -19,12 +19,17 @@ module VagrantPlugins return if !argv @logger.debug("'Destroy' each target VM...") + declined = false with_target_vms(argv, :reverse => true) do |vm| - vm.action(:destroy, :force_confirm_destroy => options[:force]) + action_env = vm.action( + :destroy, :force_confirm_destroy => options[:force]) + + declined = true if action_env.has_key?(:force_confirm_destroy_result) && + action_env[:force_confirm_destroy_result] == false end - # Success, exit status 0 - 0 + # Success if no confirms were declined + declined ? 1 : 0 end end end From 3840e07adbfc621a908a118809419271d7d7d65a Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 10 Jul 2013 19:57:53 -0700 Subject: [PATCH 13/21] vagrant box remove doesn't need provider if box only has one [GH-1032] --- CHANGELOG.md | 2 ++ plugins/commands/box/command/remove.rb | 22 +++++++++++++++++++++- templates/locales/en.yml | 11 +++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bf66230d..dea7b712c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ FEATURES: IMPROVEMENTS: + - `vagrant box remove` works with only the name of the box if that + box exists only backed by one provider. [GH-1032] - `vagrant destroy` returns exit status 1 if any of the confirmations are declined. [GH-923] diff --git a/plugins/commands/box/command/remove.rb b/plugins/commands/box/command/remove.rb index 43a7bc77e..cc45a32c9 100644 --- a/plugins/commands/box/command/remove.rb +++ b/plugins/commands/box/command/remove.rb @@ -12,7 +12,27 @@ module VagrantPlugins # Parse the options argv = parse_options(opts) return if !argv - raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length < 2 + raise Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length < 1 + + if !argv[1] + # Try to automatically determine the provider. + providers = [] + @env.boxes.all.each do |name, provider| + if name == argv[0] + providers << provider + end + end + + if providers.length > 1 + @env.ui.error( + I18n.t("vagrant.commands.box.remove_must_specify_provider", + name: args[0], + providers: providers.join(", "))) + return 1 + end + + argv[1] = providers[0] || "" + end b = nil begin diff --git a/templates/locales/en.yml b/templates/locales/en.yml index b0c252e7b..122230202 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -656,6 +656,17 @@ en: vm_not_created: "VM not created. Moving on..." vm_not_running: "VM is not currently running. Please bring it up to run this command." box: + remove_must_specify_provider: |- + Multiple providers were found for the box '%{name}'. Please specify + the specific provider for the box you want to remove. The list of + providers backing this box is: + + '%{providers}' + + To remove the box for a specific provider, run the following command, + filling in PROVIDER with one of the providers above: + + vagrant box remove '%{name}' PROVIDER no_installed_boxes: "There are no installed boxes! Use `vagrant box add` to add some." removing: |- Removing box '%{name}' with provider '%{provider}'... From e941c549f23e744e5e11ad3a0732c03e6db5b0fe Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 10 Jul 2013 20:10:33 -0700 Subject: [PATCH 14/21] box_url downloading happens before config validation [GH-1061] --- CHANGELOG.md | 5 ++++- lib/vagrant/action/builtin/handle_box_url.rb | 9 +++++++++ plugins/providers/virtualbox/action.rb | 11 ++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dea7b712c..1da8dca7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,10 @@ IMPROVEMENTS: BUG FIXES: - - core/nfs: Exporting sub-directories of other exported folders now + - Boxes downloaded as part of `vagrant up` are now done so _prior_ to + config validation. This allows Vagrantfiles to references files that + may be in the box itself. [GH-1061] + - NFS synced folders exporting sub-directories of other exported folders now works properly. [GH-785] ## 1.2.3 (July 9, 2013) diff --git a/lib/vagrant/action/builtin/handle_box_url.rb b/lib/vagrant/action/builtin/handle_box_url.rb index 7cbac6570..5dbbf65fa 100644 --- a/lib/vagrant/action/builtin/handle_box_url.rb +++ b/lib/vagrant/action/builtin/handle_box_url.rb @@ -1,5 +1,7 @@ require "thread" +require "log4r" + module Vagrant module Action module Builtin @@ -13,9 +15,16 @@ module Vagrant def initialize(app, env) @app = app + @logger = Log4r::Logger.new("vagrant::action::builtin::handle_box_url") end def call(env) + if !env[:machine].config.vm.box || !env[:machine].config.vm.box_url + @logger.info("Skipping HandleBoxUrl because box or box_url not set.") + @app.call(env) + return + end + if !env[:machine].box # Get a "big lock" to make sure that our more fine grained # lock access is thread safe. diff --git a/plugins/providers/virtualbox/action.rb b/plugins/providers/virtualbox/action.rb index 513583d4e..972c5c8c4 100644 --- a/plugins/providers/virtualbox/action.rb +++ b/plugins/providers/virtualbox/action.rb @@ -293,12 +293,21 @@ module VagrantPlugins def self.action_up Vagrant::Action::Builder.new.tap do |b| b.use CheckVirtualbox + + # Handle box_url downloading early so that if the Vagrantfile + # references any files in the box or something it all just + # works fine. + b.use Call, Created do |env, b2| + if !env[:result] + b2.use HandleBoxUrl + end + end + b.use ConfigValidate b.use Call, Created do |env, b2| # If the VM is NOT created yet, then do the setup steps if !env[:result] b2.use CheckAccessible - b2.use HandleBoxUrl b2.use Import b2.use MatchMACAddress end From 78ef3ded2b9c846458046b943470abba30cbed75 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 10 Jul 2013 20:21:13 -0700 Subject: [PATCH 15/21] Expand symlinks for NFS host path [GH-1101] --- CHANGELOG.md | 2 ++ lib/vagrant/action/builtin/nfs.rb | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1da8dca7e..aa98b7d21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ BUG FIXES: may be in the box itself. [GH-1061] - NFS synced folders exporting sub-directories of other exported folders now works properly. [GH-785] + - NFS shared folders properly dereference symlinks so that the real path + is used, avoiding mount errors [GH-1101] ## 1.2.3 (July 9, 2013) diff --git a/lib/vagrant/action/builtin/nfs.rb b/lib/vagrant/action/builtin/nfs.rb index 17db963b2..eaaf2899a 100644 --- a/lib/vagrant/action/builtin/nfs.rb +++ b/lib/vagrant/action/builtin/nfs.rb @@ -37,7 +37,9 @@ module Vagrant # Expand the host path, create it if we have to and # store away the folder. - hostpath = Pathname.new(opts[:hostpath]).expand_path(env[:root_path]) + hostpath = Pathname.new(opts[:hostpath]). + expand_path(env[:root_path]). + realpath if !hostpath.directory? && opts[:create] # Host path doesn't exist, so let's create it. From dd6dd4929e54ca14415516d2844a2ccf8a5fcf67 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 10 Jul 2013 20:26:53 -0700 Subject: [PATCH 16/21] Remove dna and data bag secret prior to upload in Chef [GH-1111] --- CHANGELOG.md | 2 ++ plugins/provisioners/chef/provisioner/base.rb | 6 +++++- plugins/provisioners/chef/provisioner/chef_solo.rb | 7 +++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa98b7d21..868b1fa28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ BUG FIXES: - Boxes downloaded as part of `vagrant up` are now done so _prior_ to config validation. This allows Vagrantfiles to references files that may be in the box itself. [GH-1061] + - Chef removes dna.json and encrypted data bag secret file prior to + uploading. [GH-1111] - NFS synced folders exporting sub-directories of other exported folders now works properly. [GH-785] - NFS shared folders properly dereference symlinks so that the real path diff --git a/plugins/provisioners/chef/provisioner/base.rb b/plugins/provisioners/chef/provisioner/base.rb index 180ce6e1b..5370ded4d 100644 --- a/plugins/provisioners/chef/provisioner/base.rb +++ b/plugins/provisioners/chef/provisioner/base.rb @@ -97,7 +97,11 @@ module VagrantPlugins temp.write(json) temp.close - @machine.communicate.upload(temp.path, File.join(@config.provisioning_path, "dna.json")) + remote_file = File.join(@config.provisioning_path, "dna.json") + @machine.communicate.tap do |comm| + comm.sudo("rm #{remote_file}", :error_check => false) + comm.upload(temp.path, remote_file) + end end end end diff --git a/plugins/provisioners/chef/provisioner/chef_solo.rb b/plugins/provisioners/chef/provisioner/chef_solo.rb index c0ce268a0..cc661a100 100644 --- a/plugins/provisioners/chef/provisioner/chef_solo.rb +++ b/plugins/provisioners/chef/provisioner/chef_solo.rb @@ -114,8 +114,11 @@ module VagrantPlugins def upload_encrypted_data_bag_secret @machine.env.ui.info I18n.t("vagrant.provisioners.chef.upload_encrypted_data_bag_secret_key") - @machine.communicate.upload(encrypted_data_bag_secret_key_path, - @config.encrypted_data_bag_secret) + @machine.communicate.tap do |comm| + comm.sudo("rm #{@config.encrypted_data_bag_secret}", :error_check => false) + comm.upload(encrypted_data_bag_secret_key_path, + @config.encrypted_data_bag_secret) + end end def setup_solo_config From fd644c5105f1741eb96f0761ffee8f8211a68b4d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 10 Jul 2013 20:30:15 -0700 Subject: [PATCH 17/21] Forward ports can specify host/guest IP to bind to [GH-1121] --- CHANGELOG.md | 1 + plugins/providers/virtualbox/driver/version_4_0.rb | 4 ++-- plugins/providers/virtualbox/driver/version_4_1.rb | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 868b1fa28..895b4e32e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ IMPROVEMENTS: box exists only backed by one provider. [GH-1032] - `vagrant destroy` returns exit status 1 if any of the confirmations are declined. [GH-923] + - Forwarded ports can specify a host IP and guest IP to bind to. [GH-1121] BUG FIXES: diff --git a/plugins/providers/virtualbox/driver/version_4_0.rb b/plugins/providers/virtualbox/driver/version_4_0.rb index 828d0e1b4..9341a0362 100644 --- a/plugins/providers/virtualbox/driver/version_4_0.rb +++ b/plugins/providers/virtualbox/driver/version_4_0.rb @@ -142,9 +142,9 @@ module VagrantPlugins ports.each do |options| pf_builder = [options[:name], options[:protocol] || "tcp", - "", + options[:hostip] || "", options[:hostport], - "", + options[:guestip] || "", options[:guestport]] args.concat(["--natpf#{options[:adapter] || 1}", diff --git a/plugins/providers/virtualbox/driver/version_4_1.rb b/plugins/providers/virtualbox/driver/version_4_1.rb index c6cb3a6f2..7a648d303 100644 --- a/plugins/providers/virtualbox/driver/version_4_1.rb +++ b/plugins/providers/virtualbox/driver/version_4_1.rb @@ -142,9 +142,9 @@ module VagrantPlugins ports.each do |options| pf_builder = [options[:name], options[:protocol] || "tcp", - "", + options[:hostip] || "", options[:hostport], - "", + options[:guestip] || "", options[:guestport]] args.concat(["--natpf#{options[:adapter] || 1}", From 3d63fa94a5d25fb6738747def861cf4ec358ed77 Mon Sep 17 00:00:00 2001 From: Jim Gay Date: Thu, 11 Jul 2013 10:41:14 -0400 Subject: [PATCH 18/21] set error to specify which command to use to bring vagrant up This provides the suggested command to run in order to proceed with a failed command. --- templates/locales/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 122230202..0bb841986 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -654,7 +654,7 @@ en: vm_already_running: |- VirtualBox VM is already running. vm_not_created: "VM not created. Moving on..." - vm_not_running: "VM is not currently running. Please bring it up to run this command." + vm_not_running: "VM is not currently running. Please, first bring it up with `vagrant up` then run this command." box: remove_must_specify_provider: |- Multiple providers were found for the box '%{name}'. Please specify From 81550392b0659954e00822da02cabd1b303f643d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 12 Jul 2013 06:40:03 +0900 Subject: [PATCH 19/21] Close SSH channel after exit status received [GH-603] --- CHANGELOG.md | 2 ++ plugins/communicators/ssh/communicator.rb | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 895b4e32e..f3f1b12ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ BUG FIXES: works properly. [GH-785] - NFS shared folders properly dereference symlinks so that the real path is used, avoiding mount errors [GH-1101] + - SSH channel is closed after the exit status is received, potentially + eliminating any SSH hangs. [GH-603] ## 1.2.3 (July 9, 2013) diff --git a/plugins/communicators/ssh/communicator.rb b/plugins/communicators/ssh/communicator.rb index 2dea21e33..db7111137 100644 --- a/plugins/communicators/ssh/communicator.rb +++ b/plugins/communicators/ssh/communicator.rb @@ -282,6 +282,10 @@ module VagrantPlugins ch2.on_request("exit-status") do |ch3, data| exit_status = data.read_long @logger.debug("Exit status: #{exit_status}") + + # Close the channel, since after the exit status we're + # probably done. This fixes up issues with hanging. + channel.close end # Set the terminal From 5f5203559fecaf5bede5410ba9b109c72d14156a Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 12 Jul 2013 16:05:56 +0900 Subject: [PATCH 20/21] style nitpick --- lib/vagrant/util/subprocess.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant/util/subprocess.rb b/lib/vagrant/util/subprocess.rb index f733ed3ce..9ee04376c 100644 --- a/lib/vagrant/util/subprocess.rb +++ b/lib/vagrant/util/subprocess.rb @@ -27,7 +27,7 @@ module Vagrant def initialize(*command) @options = command.last.is_a?(Hash) ? command.pop : {} @command = command - @command[0] = Which.which(@command[0]) if !File.file? @command[0] + @command[0] = Which.which(@command[0]) if !File.file?(@command[0]) if !@command[0] raise Errors::CommandUnavailableWindows, file: command[0] if Platform.windows? raise Errors::CommandUnavailable, file: command[0] From 6d26c86c4c3f65e2e59f4dda6bca9cd9235de704 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 12 Jul 2013 17:13:10 +0900 Subject: [PATCH 21/21] Properly detect missing VirtualBox [GH-1918] --- CHANGELOG.md | 1 + plugins/providers/virtualbox/driver/meta.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3f1b12ac..7bc7a5ba1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ BUG FIXES: is used, avoiding mount errors [GH-1101] - SSH channel is closed after the exit status is received, potentially eliminating any SSH hangs. [GH-603] + - Fix regression where VirtualBox detection wasn't working anymore. [GH-1918] ## 1.2.3 (July 9, 2013) diff --git a/plugins/providers/virtualbox/driver/meta.rb b/plugins/providers/virtualbox/driver/meta.rb index 8c8bc234c..ed53357bc 100644 --- a/plugins/providers/virtualbox/driver/meta.rb +++ b/plugins/providers/virtualbox/driver/meta.rb @@ -32,7 +32,8 @@ module VagrantPlugins # specific driver to instantiate. begin @version = read_version || "" - rescue Vagrant::Util::Subprocess::LaunchError + rescue Vagrant::Errors::CommandUnavailable, + Vagrant::Errors::CommandUnavailableWindows # This means that VirtualBox was not found, so we raise this # error here. raise Vagrant::Errors::VirtualBoxNotDetected