From 5a7e00c5b1deffa3329c43c9c22186cd6d49991e Mon Sep 17 00:00:00 2001 From: Ray Ruvinskiy Date: Sun, 7 Sep 2014 23:45:32 -0400 Subject: [PATCH 001/354] Add HTTPS download options to `box update` and `box outdated` Vagrant::Box.load_metadata did not provide a way to specify the HTTPS download options that could be specified when downloading boxes (ca cert, ca path, client cert, insecure). As a result, while it was possible to add a box whose metadata file needed to be downloaded with one of those options specified, it was impossible to check for updates. The following changes have been made to address the situation: 1. Create a DownloadMixins module to provide the --insecure, --cacert, --capth, and --cert command line options to all of `vagrant box add`, `vagrant box update`, and `vagrant box outdated`. 2. Extend `Vagrant::Box.has_update?` and `Vagrant::Box.load_metadata` to accept said download options. 3. Extend `box outdated` and `box update` commands to pass download options down. 4. Extend `Vagrant::Builtin::Action::BoxCheckOutdated` to honour download options. 5. Options specified on the command line take precedence over options specified in the machine configuration, if any. 6. Fix bug in `vagrant box add` where client cert was being passed down using the wrong environment key. 7. Unit test coverage in update_test and box_check_outdated_test. Resolves #4420 --- .../action/builtin/box_check_outdated.rb | 12 +- lib/vagrant/box.rb | 9 +- plugins/commands/box/command/add.rb | 23 +-- .../commands/box/command/download_mixins.rb | 29 +++ plugins/commands/box/command/outdated.rb | 15 +- plugins/commands/box/command/update.rb | 35 +++- .../commands/box/command/update_test.rb | 184 ++++++++++++++---- .../action/builtin/box_check_outdated_test.rb | 37 +++- 8 files changed, 275 insertions(+), 69 deletions(-) create mode 100644 plugins/commands/box/command/download_mixins.rb diff --git a/lib/vagrant/action/builtin/box_check_outdated.rb b/lib/vagrant/action/builtin/box_check_outdated.rb index cee8c6877..d39afd272 100644 --- a/lib/vagrant/action/builtin/box_check_outdated.rb +++ b/lib/vagrant/action/builtin/box_check_outdated.rb @@ -37,13 +37,23 @@ module Vagrant end constraints = machine.config.vm.box_version + # Have download options specified in the environment override + # options specified for the machine. + download_options = { + ca_cert: env[:ca_cert] || machine.config.vm.box_download_ca_cert, + ca_path: env[:ca_path] || machine.config.vm.box_download_ca_path, + client_cert: env[:client_cert] || + machine.config.vm.box_download_client_cert, + insecure: !env[:insecure].nil? ? + env[:insecure] : machine.config.vm.box_download_insecure + } env[:ui].output(I18n.t( "vagrant.box_outdated_checking_with_refresh", name: box.name)) update = nil begin - update = box.has_update?(constraints) + update = box.has_update?(constraints, download_options: download_options) rescue Errors::BoxMetadataDownloadError => e env[:ui].warn(I18n.t( "vagrant.box_outdated_metadata_download_error", diff --git a/lib/vagrant/box.rb b/lib/vagrant/box.rb index 537c94e2a..045b22fd3 100644 --- a/lib/vagrant/box.rb +++ b/lib/vagrant/box.rb @@ -115,8 +115,9 @@ module Vagrant # Loads the metadata URL and returns the latest metadata associated # with this box. # + # @param [Hash] download_options Options to pass to the downloader. # @return [BoxMetadata] - def load_metadata + def load_metadata(**download_options) tf = Tempfile.new("vagrant") tf.close @@ -127,7 +128,7 @@ module Vagrant url = "file:#{url}" end - opts = { headers: ["Accept: application/json"] } + opts = { headers: ["Accept: application/json"] }.merge(download_options) Util::Downloader.new(url, tf.path, **opts).download! BoxMetadata.new(File.open(tf.path, "r")) rescue Errors::DownloaderError => e @@ -148,7 +149,7 @@ module Vagrant # satisfy. If nil, the version constrain defaults to being a # larger version than this box. # @return [Array] - def has_update?(version=nil) + def has_update?(version=nil, download_options: {}) if !@metadata_url raise Errors::BoxUpdateNoMetadata, name: @name end @@ -156,7 +157,7 @@ module Vagrant version += ", " if version version ||= "" version += "> #{@version}" - md = self.load_metadata + md = self.load_metadata(download_options) newer = md.version(version, provider: @provider) return nil if !newer diff --git a/plugins/commands/box/command/add.rb b/plugins/commands/box/command/add.rb index 0356ee298..e9d429433 100644 --- a/plugins/commands/box/command/add.rb +++ b/plugins/commands/box/command/add.rb @@ -1,9 +1,13 @@ require 'optparse' +require_relative 'download_mixins' + module VagrantPlugins module CommandBox module Command class Add < Vagrant.plugin("2", :command) + include DownloadMixins + def execute options = {} @@ -21,22 +25,7 @@ module VagrantPlugins options[:force] = f end - o.on("--insecure", "Do not validate SSL certificates") do |i| - options[:insecure] = i - end - - o.on("--cacert FILE", String, "CA certificate for SSL download") do |c| - options[:ca_cert] = c - end - - o.on("--capath DIR", String, "CA certificate directory for SSL download") do |c| - options[:ca_path] = c - end - - o.on("--cert FILE", String, - "A client SSL cert, if needed") do |c| - options[:client_cert] = c - end + build_download_options(o, options) o.on("--provider PROVIDER", String, "Provider the box should satisfy") do |p| options[:provider] = p @@ -93,7 +82,7 @@ module VagrantPlugins box_force: options[:force], box_download_ca_cert: options[:ca_cert], box_download_ca_path: options[:ca_path], - box_download_client_cert: options[:client_cert], + box_client_cert: options[:client_cert], box_download_insecure: options[:insecure], ui: Vagrant::UI::Prefixed.new(@env.ui, "box"), }) diff --git a/plugins/commands/box/command/download_mixins.rb b/plugins/commands/box/command/download_mixins.rb new file mode 100644 index 000000000..eda31b6bf --- /dev/null +++ b/plugins/commands/box/command/download_mixins.rb @@ -0,0 +1,29 @@ +module VagrantPlugins + module CommandBox + module DownloadMixins + # This adds common download command line flags to the given + # OptionParser, storing the result in the `options` dictionary. + # + # @param [OptionParser] parser + # @param [Hash] options + def build_download_options(parser, options) + # Add the options + parser.on("--insecure", "Do not validate SSL certificates") do |i| + options[:insecure] = i + end + + parser.on("--cacert FILE", String, "CA certificate for SSL download") do |c| + options[:ca_cert] = c + end + + parser.on("--capath DIR", String, "CA certificate directory for SSL download") do |c| + options[:ca_path] = c + end + + parser.on("--cert FILE", String, "A client SSL cert, if needed") do |c| + options[:client_cert] = c + end + end + end + end +end diff --git a/plugins/commands/box/command/outdated.rb b/plugins/commands/box/command/outdated.rb index a686fa496..cde932e1a 100644 --- a/plugins/commands/box/command/outdated.rb +++ b/plugins/commands/box/command/outdated.rb @@ -1,11 +1,16 @@ require 'optparse' +require_relative 'download_mixins' + module VagrantPlugins module CommandBox module Command class Outdated < Vagrant.plugin("2", :command) + include DownloadMixins + def execute options = {} + download_options = {} opts = OptionParser.new do |o| o.banner = "Usage: vagrant box outdated [options]" @@ -20,6 +25,8 @@ module VagrantPlugins o.on("--global", "Check all boxes installed") do |g| options[:global] = g end + + build_download_options(o, download_options) end argv = parse_options(opts) @@ -27,7 +34,7 @@ module VagrantPlugins # If we're checking the boxes globally, then do that. if options[:global] - outdated_global + outdated_global(download_options) return 0 end @@ -37,11 +44,11 @@ module VagrantPlugins box_outdated_refresh: true, box_outdated_success_ui: true, machine: machine, - }) + }.merge(download_options)) end end - def outdated_global + def outdated_global(download_options) boxes = {} @env.boxes.all.reverse.each do |name, version, provider| next if boxes[name] @@ -58,7 +65,7 @@ module VagrantPlugins md = nil begin - md = box.load_metadata + md = box.load_metadata(download_options) rescue Vagrant::Errors::DownloaderError => e @env.ui.error(I18n.t( "vagrant.box_outdated_metadata_error", diff --git a/plugins/commands/box/command/update.rb b/plugins/commands/box/command/update.rb index 5633b0aaf..67d07bcc0 100644 --- a/plugins/commands/box/command/update.rb +++ b/plugins/commands/box/command/update.rb @@ -1,11 +1,16 @@ require 'optparse' +require_relative 'download_mixins' + module VagrantPlugins module CommandBox module Command class Update < Vagrant.plugin("2", :command) + include DownloadMixins + def execute options = {} + download_options = {} opts = OptionParser.new do |o| o.banner = "Usage: vagrant box update [options]" @@ -27,21 +32,23 @@ module VagrantPlugins o.on("--provider PROVIDER", String, "Update box with specific provider") do |p| options[:provider] = p.to_sym end + + build_download_options(o, download_options) end argv = parse_options(opts) return if !argv if options[:box] - update_specific(options[:box], options[:provider]) + update_specific(options[:box], options[:provider], download_options) else - update_vms(argv, options[:provider]) + update_vms(argv, options[:provider], download_options) end 0 end - def update_specific(name, provider) + def update_specific(name, provider, download_options) boxes = {} @env.boxes.all.each do |n, v, p| boxes[n] ||= {} @@ -74,11 +81,11 @@ module VagrantPlugins to_update.each do |n, p, v| box = @env.boxes.find(n, p, v) - box_update(box, "> #{v}", @env.ui) + box_update(box, "> #{v}", @env.ui, download_options) end end - def update_vms(argv, provider) + def update_vms(argv, provider, download_options) with_target_vms(argv, provider: provider) do |machine| if !machine.config.vm.box machine.ui.output(I18n.t( @@ -95,17 +102,25 @@ module VagrantPlugins box = machine.box version = machine.config.vm.box_version - box_update(box, version, machine.ui) + # Get download options from machine configuration if not specified + # on the command line. + download_options[:ca_cert] ||= machine.config.vm.box_download_ca_cert + download_options[:ca_path] ||= machine.config.vm.box_download_ca_path + download_options[:client_cert] ||= machine.config.vm.box_download_client_cert + if download_options[:insecure].nil? + download_options[:insecure] = machine.config.vm.box_download_insecure + end + box_update(box, version, machine.ui, download_options) end end - def box_update(box, version, ui) + def box_update(box, version, ui, download_options) ui.output(I18n.t("vagrant.box_update_checking", name: box.name)) ui.detail("Latest installed version: #{box.version}") ui.detail("Version constraints: #{version}") ui.detail("Provider: #{box.provider}") - update = box.has_update?(version) + update = box.has_update?(version, download_options: download_options) if !update ui.success(I18n.t( "vagrant.box_up_to_date_single", @@ -124,6 +139,10 @@ module VagrantPlugins box_provider: update[2].name, box_version: update[1].version, ui: ui, + box_client_cert: download_options[:client_cert], + box_download_ca_cert: download_options[:ca_cert], + box_download_ca_path: download_options[:ca_path], + box_download_insecure: download_options[:insecure] }) end end diff --git a/test/unit/plugins/commands/box/command/update_test.rb b/test/unit/plugins/commands/box/command/update_test.rb index 4477d0aa5..067d0dd35 100644 --- a/test/unit/plugins/commands/box/command/update_test.rb +++ b/test/unit/plugins/commands/box/command/update_test.rb @@ -19,6 +19,11 @@ describe VagrantPlugins::CommandBox::Command::Update do let(:action_runner) { double("action_runner") } let(:machine) { iso_env.machine(iso_env.machine_names[0], :dummy) } + let(:download_options) { ["--insecure", + "--cacert", "foo", + "--capath", "bar", + "--cert", "baz"] } + subject { described_class.new(argv, iso_env) } before do @@ -86,6 +91,10 @@ describe VagrantPlugins::CommandBox::Command::Update do expect(opts[:box_url]).to eq(metadata_url.to_s) expect(opts[:box_provider]).to eq("virtualbox") expect(opts[:box_version]).to eq("1.1") + expect(opts[:box_download_ca_path]).to be_nil + expect(opts[:box_download_ca_cert]).to be_nil + expect(opts[:box_client_cert]).to be_nil + expect(opts[:box_download_insecure]).to be_nil end opts @@ -158,6 +167,50 @@ describe VagrantPlugins::CommandBox::Command::Update do end end + context "download options are specified" do + let(:argv) { ["--box", "foo" ].concat(download_options) } + + it "passes down download options" do + metadata_url.open("w") do |f| + f.write(<<-RAW) + { + "name": "foo", + "versions": [ + { + "version": "1.0" + }, + { + "version": "1.1", + "providers": [ + { + "name": "virtualbox", + "url": "bar" + } + ] + } + ] + } + RAW + end + + action_called = false + allow(action_runner).to receive(:run) do |action, opts| + if opts[:box_provider] + action_called = true + expect(opts[:box_download_ca_cert]).to eq("foo") + expect(opts[:box_download_ca_path]).to eq("bar") + expect(opts[:box_client_cert]).to eq("baz") + expect(opts[:box_download_insecure]).to be_true + end + + opts + end + + subject.execute + expect(action_called).to be_true + end + end + context "with a box that doesn't exist" do let(:argv) { ["--box", "nope"] } @@ -192,7 +245,10 @@ describe VagrantPlugins::CommandBox::Command::Update do it "doesn't update boxes if they're up-to-date" do machine.stub(box: box) expect(box).to receive(:has_update?). - with(machine.config.vm.box_version). + with(machine.config.vm.box_version, + {download_options: + {ca_cert: nil, ca_path: nil, client_cert: nil, + insecure: false}}). and_return(nil) expect(action_runner).to receive(:run).never @@ -200,41 +256,101 @@ describe VagrantPlugins::CommandBox::Command::Update do subject.execute end - it "updates boxes if they have an update" do - md = Vagrant::BoxMetadata.new(StringIO.new(<<-RAW)) - { - "name": "foo", - "versions": [ - { - "version": "1.0" - }, - { - "version": "1.1", - "providers": [ - { - "name": "virtualbox", - "url": "bar" - } - ] - } - ] - } - RAW - - machine.stub(box: box) - expect(box).to receive(:has_update?). - with(machine.config.vm.box_version). - and_return([md, md.version("1.1"), md.version("1.1").provider("virtualbox")]) - - expect(action_runner).to receive(:run).with { |action, opts| - expect(opts[:box_url]).to eq(box.metadata_url) - expect(opts[:box_provider]).to eq("virtualbox") - expect(opts[:box_version]).to eq("1.1") - expect(opts[:ui]).to equal(machine.ui) - true + context "boxes have an update" do + let(:md) { + md = Vagrant::BoxMetadata.new(StringIO.new(<<-RAW)) + { + "name": "foo", + "versions": [ + { + "version": "1.0" + }, + { + "version": "1.1", + "providers": [ + { + "name": "virtualbox", + "url": "bar" + } + ] + } + ] + } + RAW } - subject.execute + before { machine.stub(box: box) } + + it "updates boxes" do + expect(box).to receive(:has_update?). + with(machine.config.vm.box_version, + {download_options: + {ca_cert: nil, ca_path: nil, client_cert: nil, + insecure: false}}). + and_return([md, md.version("1.1"), md.version("1.1").provider("virtualbox")]) + + expect(action_runner).to receive(:run).with { |action, opts| + expect(opts[:box_url]).to eq(box.metadata_url) + expect(opts[:box_provider]).to eq("virtualbox") + expect(opts[:box_version]).to eq("1.1") + expect(opts[:ui]).to equal(machine.ui) + true + } + + subject.execute + end + + context "machine has download options" do + before do + machine.config.vm.box_download_ca_cert = "oof" + machine.config.vm.box_download_ca_path = "rab" + machine.config.vm.box_download_client_cert = "zab" + machine.config.vm.box_download_insecure = false + end + + it "uses download options from machine" do + expect(box).to receive(:has_update?). + with(machine.config.vm.box_version, + {download_options: + {ca_cert: "oof", ca_path: "rab", client_cert: "zab", + insecure: false}}). + and_return([md, md.version("1.1"), md.version("1.1").provider("virtualbox")]) + + expect(action_runner).to receive(:run).with { |action, opts| + expect(opts[:box_download_ca_cert]).to eq("oof") + expect(opts[:box_download_ca_path]).to eq("rab") + expect(opts[:box_client_cert]).to eq("zab") + expect(opts[:box_download_insecure]).to be_false + true + } + + subject.execute + end + + context "download options are specified on the command line" do + let(:argv) { download_options } + + it "overrides download options from machine with options from CLI" do + expect(box).to receive(:has_update?). + with(machine.config.vm.box_version, + {download_options: + {ca_cert: "foo", ca_path: "bar", client_cert: "baz", + insecure: true}}). + and_return([md, md.version("1.1"), + md.version("1.1").provider("virtualbox")]) + + expect(action_runner).to receive(:run).with { |action, opts| + expect(opts[:box_download_ca_cert]).to eq("foo") + expect(opts[:box_download_ca_path]).to eq("bar") + expect(opts[:box_client_cert]).to eq("baz") + expect(opts[:box_download_insecure]).to be_true + true + } + + subject.execute + end + end + end end end end diff --git a/test/unit/vagrant/action/builtin/box_check_outdated_test.rb b/test/unit/vagrant/action/builtin/box_check_outdated_test.rb index bcb313d1c..0bb175c59 100644 --- a/test/unit/vagrant/action/builtin/box_check_outdated_test.rb +++ b/test/unit/vagrant/action/builtin/box_check_outdated_test.rb @@ -117,7 +117,9 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do } RAW - expect(box).to receive(:has_update?).with(machine.config.vm.box_version). + expect(box).to receive(:has_update?).with(machine.config.vm.box_version, + {download_options: + {ca_cert: nil, ca_path: nil, client_cert: nil, insecure: false}}). and_return([md, md.version("1.1"), md.version("1.1").provider("virtualbox")]) expect(app).to receive(:call).with(env).once @@ -180,5 +182,38 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do expect { subject.call(env) }.to_not raise_error end + + context "when machine download options are specified" do + before do + machine.config.vm.box_download_ca_cert = "foo" + machine.config.vm.box_download_ca_path = "bar" + machine.config.vm.box_download_client_cert = "baz" + machine.config.vm.box_download_insecure = true + end + + it "uses download options from machine" do + expect(box).to receive(:has_update?).with(machine.config.vm.box_version, + {download_options: + {ca_cert: "foo", ca_path: "bar", client_cert: "baz", insecure: true}}) + + expect(app).to receive(:call).with(env).once + + subject.call(env) + end + + it "overrides download options from machine with options from env" do + expect(box).to receive(:has_update?).with(machine.config.vm.box_version, + {download_options: + {ca_cert: "oof", ca_path: "rab", client_cert: "zab", insecure: false}}) + + env[:ca_cert] = "oof" + env[:ca_path] = "rab" + env[:client_cert] = "zab" + env[:insecure] = false + expect(app).to receive(:call).with(env).once + + subject.call(env) + end + end end end From 14b84a4a76dc3bc3e7693b2388b37072370169b6 Mon Sep 17 00:00:00 2001 From: Rob Kinyon Date: Tue, 28 Oct 2014 21:53:41 -0400 Subject: [PATCH 002/354] Added a --plugin-clean-sources parameter that will allow for only those sources that are defined by the user to be used. --- .gitignore | 4 ++++ lib/vagrant/bundler.rb | 5 ----- plugins/commands/plugin/command/mixin_install_opts.rb | 11 ++++++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 47b95a67e..8fe665031 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,10 @@ # OS-specific .DS_Store +# Editor swapfiles +.*.sw? +*~ + # Vagrant stuff acceptance_config.yml boxes/* diff --git a/lib/vagrant/bundler.rb b/lib/vagrant/bundler.rb index 05867da15..e12b89174 100644 --- a/lib/vagrant/bundler.rb +++ b/lib/vagrant/bundler.rb @@ -178,11 +178,6 @@ module Vagrant f = File.open(Tempfile.new("vagrant").path + "2", "w+") f.tap do |gemfile| - if !sources.include?("http://rubygems.org") - gemfile.puts(%Q[source "https://rubygems.org"]) - end - - gemfile.puts(%Q[source "http://gems.hashicorp.com"]) sources.each do |source| next if source == "" gemfile.puts(%Q[source "#{source}"]) diff --git a/plugins/commands/plugin/command/mixin_install_opts.rb b/plugins/commands/plugin/command/mixin_install_opts.rb index 0b1b0973a..ffee55cde 100644 --- a/plugins/commands/plugin/command/mixin_install_opts.rb +++ b/plugins/commands/plugin/command/mixin_install_opts.rb @@ -3,6 +3,11 @@ module VagrantPlugins module Command module MixinInstallOpts def build_install_opts(o, options) + options[:plugin_sources] = [ + "https://rubygems.org", + "http://gems.hashicorp.com", + ] + o.on("--entry-point NAME", String, "The name of the entry point file for loading the plugin.") do |entry_point| options[:entry_point] = entry_point @@ -17,9 +22,13 @@ module VagrantPlugins puts end + o.on("--plugin-clean-sources", String, + "Remove all plugin sources defined so far (including defaults)") do + options[:plugin_sources] = [] + end + o.on("--plugin-source PLUGIN_SOURCE", String, "Add a RubyGems repository source") do |plugin_source| - options[:plugin_sources] ||= [] options[:plugin_sources] << plugin_source end From c60a020096e576243e703517511d886fd461a925 Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Wed, 27 Aug 2014 12:17:30 -0700 Subject: [PATCH 003/354] adds a ps command to vagrant that drops the user into a remote powershell shell --- plugins/commands/ps/command.rb | 116 ++++++++++++++++++ plugins/commands/ps/errors.rb | 18 +++ plugins/commands/ps/plugin.rb | 31 +++++ .../commands/ps/scripts/enable_psremoting.ps1 | 60 +++++++++ .../ps/scripts/reset_trustedhosts.ps1 | 12 ++ plugins/hosts/windows/cap/ps.rb | 50 ++++++++ plugins/hosts/windows/plugin.rb | 5 + templates/locales/command_ps.yml | 16 +++ 8 files changed, 308 insertions(+) create mode 100644 plugins/commands/ps/command.rb create mode 100644 plugins/commands/ps/errors.rb create mode 100644 plugins/commands/ps/plugin.rb create mode 100644 plugins/commands/ps/scripts/enable_psremoting.ps1 create mode 100644 plugins/commands/ps/scripts/reset_trustedhosts.ps1 create mode 100644 plugins/hosts/windows/cap/ps.rb create mode 100644 templates/locales/command_ps.yml diff --git a/plugins/commands/ps/command.rb b/plugins/commands/ps/command.rb new file mode 100644 index 000000000..33eeec253 --- /dev/null +++ b/plugins/commands/ps/command.rb @@ -0,0 +1,116 @@ +require "optparse" + +require_relative "../../communicators/winrm/helper" + +module VagrantPlugins + module CommandPS + class Command < Vagrant.plugin("2", :command) + def self.synopsis + "connects to machine via powershell remoting" + end + + def execute + options = {} + + opts = OptionParser.new do |o| + o.banner = "Usage: vagrant ps [-- extra ps args]" + + o.separator "" + o.separator "Options:" + o.separator "" + + o.on("-c", "--command COMMAND", "Execute a powershell command directly") do |c| + options[:command] = c + end + end + + # Parse out the extra args to send to the ps session, which + # is everything after the "--" + split_index = @argv.index("--") + if split_index + options[:extra_args] = @argv.drop(split_index + 1) + @argv = @argv.take(split_index) + end + + # Parse the options and return if we don't have any target. + argv = parse_options(opts) + return if !argv + + # Check if the host even supports ps remoting + raise Errors::HostUnsupported if !@env.host.capability?(:ps_client) + + # Execute ps session if we can + with_target_vms(argv, single_target: true) do |machine| + if !machine.communicate.ready? + raise Vagrant::Errors::VMNotCreatedError + end + + if machine.config.vm.communicator != :winrm #|| !machine.provider.capability?(:winrm_info) + raise VagrantPlugins::CommunicatorWinRM::Errors::WinRMNotReady + end + + if !options[:command].nil? + out_code = machine.communicate.execute options[:command] + if out_code == 0 + machine.ui.detail("Command: #{options[:command]} executed succesfully with output code #{out_code}.") + end + break + end + + ps_info = VagrantPlugins::CommunicatorWinRM::Helper.winrm_info(machine) + ps_info[:username] = machine.config.winrm.username + ps_info[:password] = machine.config.winrm.password + # Extra arguments if we have any + ps_info[:extra_args] = options[:extra_args] + + result = ready_ps_remoting_for machine, ps_info + + machine.ui.detail( + "Creating powershell session to #{ps_info[:host]}:#{ps_info[:port]}") + machine.ui.detail("Username: #{ps_info[:username]}") + + begin + @env.host.capability(:ps_client, ps_info) + ensure + if !result["PreviousTrustedHosts"].nil? + reset_ps_remoting_for machine, ps_info + end + end + end + end + + def ready_ps_remoting_for(machine, ps_info) + machine.ui.output(I18n.t("vagrant_ps.detecting")) + script_path = File.expand_path("../scripts/enable_psremoting.ps1", __FILE__) + args = [] + args << "-hostname" << ps_info[:host] + args << "-port" << ps_info[:port].to_s + args << "-username" << ps_info[:username] + args << "-password" << ps_info[:password] + result = Vagrant::Util::PowerShell.execute(script_path, *args) + if result.exit_code != 0 + raise Errors::PowershellError, + script: script_path, + stderr: result.stderr + end + + result_output = JSON.parse(result.stdout) + raise Errors::PSRemotingUndetected if !result_output["Success"] + result_output + end + + def reset_ps_remoting_for(machine, ps_info) + machine.ui.output(I18n.t("vagrant_ps.reseting")) + script_path = File.expand_path("../scripts/reset_trustedhosts.ps1", __FILE__) + args = [] + args << "-hostname" << ps_info[:host] + result = Vagrant::Util::PowerShell.execute(script_path, *args) + if result.exit_code != 0 + raise Errors::PowershellError, + script: script_path, + stderr: result.stderr + end + end + end + end +end diff --git a/plugins/commands/ps/errors.rb b/plugins/commands/ps/errors.rb new file mode 100644 index 000000000..c614fb87a --- /dev/null +++ b/plugins/commands/ps/errors.rb @@ -0,0 +1,18 @@ +module VagrantPlugins + module CommandPS + module Errors + # A convenient superclass for all our errors. + class PSError < Vagrant::Errors::VagrantError + error_namespace("vagrant_ps.errors") + end + + class HostUnsupported < PSError + error_key(:host_unsupported) + end + + class PSRemotingUndetected < PSError + error_key(:ps_remoting_undetected) + end + end + end +end diff --git a/plugins/commands/ps/plugin.rb b/plugins/commands/ps/plugin.rb new file mode 100644 index 000000000..56b84b3c5 --- /dev/null +++ b/plugins/commands/ps/plugin.rb @@ -0,0 +1,31 @@ +require "vagrant" + +module VagrantPlugins + module CommandPS + autoload :Errors, File.expand_path("../errors", __FILE__) + + class Plugin < Vagrant.plugin("2") + name "ps command" + description <<-DESC + The ps command opens a remote powershell session to the + machine if it supports powershell remoting. + DESC + + command("ps") do + require File.expand_path("../command", __FILE__) + init! + Command + end + + protected + + def self.init! + return if defined?(@_init) + I18n.load_path << File.expand_path( + "templates/locales/command_ps.yml", Vagrant.source_root) + I18n.reload! + @_init = true + end + end + end +end diff --git a/plugins/commands/ps/scripts/enable_psremoting.ps1 b/plugins/commands/ps/scripts/enable_psremoting.ps1 new file mode 100644 index 000000000..4d7ded704 --- /dev/null +++ b/plugins/commands/ps/scripts/enable_psremoting.ps1 @@ -0,0 +1,60 @@ +Param( + [string]$hostname, + [string]$port, + [string]$username, + [string]$password +) +# If we are in this script, we know basic winrm is working +# If the user is not using a domain acount and chances are +# they are not, PS Remoting will not work if the guest is not +# listed in the trusted hosts. + +$encrypted_password = ConvertTo-SecureString $password -asplaintext -force +$creds = New-Object System.Management.Automation.PSCredential ( + "$hostname\\$username", $encrypted_password) + +$result = @{ + Success = $false + PreviousTrustedHosts = $null +} +try { + invoke-command -computername $hostname ` + -Credential $creds ` + -Port $port ` + -ScriptBlock {} ` + -ErrorAction Stop + $result.Success = $true +} catch{} + +if(!$result.Success) { + $newHosts = @() + $result.PreviousTrustedHosts=( + Get-Item "wsman:\localhost\client\trustedhosts").Value + $hostArray=$result.PreviousTrustedHosts.Split(",").Trim() + if($hostArray -contains "*") { + $result.PreviousTrustedHosts = $null + } + elseif(!($hostArray -contains $hostname)) { + $strNewHosts = $hostname + if($result.PreviousTrustedHosts.Length -gt 0){ + $strNewHosts = $result.PreviousTrustedHosts + "," + $strNewHosts + } + Set-Item -Path "wsman:\localhost\client\trustedhosts" ` + -Value $strNewHosts -Force + + try { + invoke-command -computername $hostname ` + -Credential $creds ` + -Port $port ` + -ScriptBlock {} ` + -ErrorAction Stop + $result.Success = $true + } catch{ + Set-Item -Path "wsman:\localhost\client\trustedhosts" ` + -Value $result.PreviousTrustedHosts -Force + $result.PreviousTrustedHosts = $null + } + } +} + +Write-Output $(ConvertTo-Json $result) diff --git a/plugins/commands/ps/scripts/reset_trustedhosts.ps1 b/plugins/commands/ps/scripts/reset_trustedhosts.ps1 new file mode 100644 index 000000000..5865a4e77 --- /dev/null +++ b/plugins/commands/ps/scripts/reset_trustedhosts.ps1 @@ -0,0 +1,12 @@ +Param( + [string]$hostname +) + +$trustedHosts = ( + Get-Item "wsman:\localhost\client\trustedhosts").Value.Replace( + $hostname, '') +$trustedHosts = $trustedHosts.Replace(",,","") +if($trustedHosts.EndsWith(",")){ + $trustedHosts = $trustedHosts.Substring(0,$trustedHosts.length-1) +} +Set-Item "wsman:\localhost\client\trustedhosts" -Value $trustedHosts -Force \ No newline at end of file diff --git a/plugins/hosts/windows/cap/ps.rb b/plugins/hosts/windows/cap/ps.rb new file mode 100644 index 000000000..939235915 --- /dev/null +++ b/plugins/hosts/windows/cap/ps.rb @@ -0,0 +1,50 @@ +require "pathname" +require "tmpdir" + +require "vagrant/util/subprocess" + +module VagrantPlugins + module HostWindows + module Cap + class PS + def self.ps_client(env, ps_info) + logger = Log4r::Logger.new("vagrant::hosts::windows") + + command = <<-EOS + $plain_password = "#{ps_info[:password]}" + $username = "#{ps_info[:username]}" + $port = "#{ps_info[:port]}" + $hostname = "#{ps_info[:host]}" + $password = ConvertTo-SecureString $plain_password -asplaintext -force + $creds = New-Object System.Management.Automation.PSCredential ("$hostname\\$username", $password) + function prompt { kill $PID } + Enter-PSSession -ComputerName $hostname -Credential $creds -Port $port + EOS + + logger.debug("Starting remote powershell with command:\n#{command}") + command = command.chars.to_a.join("\x00").chomp + command << "\x00" unless command[-1].eql? "\x00" + if(defined?(command.encode)) + command = command.encode('ASCII-8BIT') + command = Base64.strict_encode64(command) + else + command = Base64.encode64(command).chomp + end + + args = ["-NoProfile"] + args << "-ExecutionPolicy" + args << "Bypass" + args << "-NoExit" + args << "-EncodedCommand" + args << command + if ps_info[:extra_args] + args << ps_info[:extra_args] + end + + # Launch it + Vagrant::Util::Subprocess.execute("powershell", *args) + end + end + end + end +end diff --git a/plugins/hosts/windows/plugin.rb b/plugins/hosts/windows/plugin.rb index fe3b28923..97e8ad134 100644 --- a/plugins/hosts/windows/plugin.rb +++ b/plugins/hosts/windows/plugin.rb @@ -20,6 +20,11 @@ module VagrantPlugins require_relative "cap/rdp" Cap::RDP end + + host_capability("windows", "ps_client") do + require_relative "cap/ps" + Cap::PS + end end end end diff --git a/templates/locales/command_ps.yml b/templates/locales/command_ps.yml new file mode 100644 index 000000000..e30e5246c --- /dev/null +++ b/templates/locales/command_ps.yml @@ -0,0 +1,16 @@ +en: + vagrant_ps: + detecting: |- + Detecting if a remote powershell connection can be made with the guest... + reseting: |- + Reseting WinRM TrustedHosts to their original value. + + errors: + host_unsupported: |- + Your host does not support powershell. A remote powershell connection + can only be made from a windows host. + + ps_remoting_undetected: |- + Unable to establish a remote powershell connection with the guest. + Check if the firewall rules on the guest allow connections to the + windows remote management service. From 1cd10330933fce64608ce2d47bbb72ad0756533f Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Fri, 5 Jun 2015 00:11:06 -0700 Subject: [PATCH 004/354] fixes from @sethvargo comments. --- plugins/commands/ps/command.rb | 10 +++++----- plugins/commands/ps/plugin.rb | 7 +++---- plugins/communicators/winrm/shell.rb | 2 +- templates/locales/command_ps.yml | 8 ++++---- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/plugins/commands/ps/command.rb b/plugins/commands/ps/command.rb index 33eeec253..3bcc41ba8 100644 --- a/plugins/commands/ps/command.rb +++ b/plugins/commands/ps/command.rb @@ -45,16 +45,16 @@ module VagrantPlugins raise Vagrant::Errors::VMNotCreatedError end - if machine.config.vm.communicator != :winrm #|| !machine.provider.capability?(:winrm_info) + if machine.config.vm.communicator != :winrm raise VagrantPlugins::CommunicatorWinRM::Errors::WinRMNotReady end if !options[:command].nil? - out_code = machine.communicate.execute options[:command] + out_code = machine.communicate.execute(options[:command]) if out_code == 0 machine.ui.detail("Command: #{options[:command]} executed succesfully with output code #{out_code}.") end - break + next end ps_info = VagrantPlugins::CommunicatorWinRM::Helper.winrm_info(machine) @@ -63,7 +63,7 @@ module VagrantPlugins # Extra arguments if we have any ps_info[:extra_args] = options[:extra_args] - result = ready_ps_remoting_for machine, ps_info + result = ready_ps_remoting_for(machine, ps_info) machine.ui.detail( "Creating powershell session to #{ps_info[:host]}:#{ps_info[:port]}") @@ -73,7 +73,7 @@ module VagrantPlugins @env.host.capability(:ps_client, ps_info) ensure if !result["PreviousTrustedHosts"].nil? - reset_ps_remoting_for machine, ps_info + reset_ps_remoting_for(machine, ps_info) end end end diff --git a/plugins/commands/ps/plugin.rb b/plugins/commands/ps/plugin.rb index 56b84b3c5..847b82c47 100644 --- a/plugins/commands/ps/plugin.rb +++ b/plugins/commands/ps/plugin.rb @@ -7,12 +7,12 @@ module VagrantPlugins class Plugin < Vagrant.plugin("2") name "ps command" description <<-DESC - The ps command opens a remote powershell session to the + The ps command opens a remote PowerShell session to the machine if it supports powershell remoting. DESC command("ps") do - require File.expand_path("../command", __FILE__) + require_relative "../command" init! Command end @@ -21,8 +21,7 @@ module VagrantPlugins def self.init! return if defined?(@_init) - I18n.load_path << File.expand_path( - "templates/locales/command_ps.yml", Vagrant.source_root) + I18n.load_path << File.expand_path("templates/locales/command_ps.yml", Vagrant.source_root) I18n.reload! @_init = true end diff --git a/plugins/communicators/winrm/shell.rb b/plugins/communicators/winrm/shell.rb index d9d5f28ce..784660b5e 100644 --- a/plugins/communicators/winrm/shell.rb +++ b/plugins/communicators/winrm/shell.rb @@ -9,7 +9,7 @@ Vagrant::Util::SilenceWarnings.silence! do require "winrm" end -require "winrm-fs/file_manager" +require "winrm-fs" module VagrantPlugins module CommunicatorWinRM diff --git a/templates/locales/command_ps.yml b/templates/locales/command_ps.yml index e30e5246c..51bf666cc 100644 --- a/templates/locales/command_ps.yml +++ b/templates/locales/command_ps.yml @@ -1,16 +1,16 @@ en: vagrant_ps: detecting: |- - Detecting if a remote powershell connection can be made with the guest... + Detecting if a remote PowerShell connection can be made with the guest... reseting: |- Reseting WinRM TrustedHosts to their original value. errors: host_unsupported: |- - Your host does not support powershell. A remote powershell connection + Your host does not support PowerShell. A remote PowerShell connection can only be made from a windows host. ps_remoting_undetected: |- - Unable to establish a remote powershell connection with the guest. + Unable to establish a remote PowerShell connection with the guest. Check if the firewall rules on the guest allow connections to the - windows remote management service. + Windows remote management service. From 47e57a7cd941c1a2f24e287ab175b9728d5e042b Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Fri, 5 Jun 2015 04:17:56 -0700 Subject: [PATCH 005/354] fix relative path --- plugins/commands/ps/plugin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/commands/ps/plugin.rb b/plugins/commands/ps/plugin.rb index 847b82c47..b108658bc 100644 --- a/plugins/commands/ps/plugin.rb +++ b/plugins/commands/ps/plugin.rb @@ -12,7 +12,7 @@ module VagrantPlugins DESC command("ps") do - require_relative "../command" + require_relative "command" init! Command end From cf6d4ef5a1943ec656695440d452b160aa74f676 Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Fri, 5 Jun 2015 04:18:23 -0700 Subject: [PATCH 006/354] clean up command encoding --- plugins/hosts/windows/cap/ps.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/plugins/hosts/windows/cap/ps.rb b/plugins/hosts/windows/cap/ps.rb index 939235915..9960f689e 100644 --- a/plugins/hosts/windows/cap/ps.rb +++ b/plugins/hosts/windows/cap/ps.rb @@ -22,21 +22,13 @@ module VagrantPlugins EOS logger.debug("Starting remote powershell with command:\n#{command}") - command = command.chars.to_a.join("\x00").chomp - command << "\x00" unless command[-1].eql? "\x00" - if(defined?(command.encode)) - command = command.encode('ASCII-8BIT') - command = Base64.strict_encode64(command) - else - command = Base64.encode64(command).chomp - end args = ["-NoProfile"] args << "-ExecutionPolicy" args << "Bypass" args << "-NoExit" args << "-EncodedCommand" - args << command + args << ::WinRM::PowershellScript.new(command).encoded if ps_info[:extra_args] args << ps_info[:extra_args] end From 740877065a8fc0b777cc7aa51b4fb074307affbd Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Fri, 5 Jun 2015 05:03:29 -0700 Subject: [PATCH 007/354] marshall back command output when passing a command to ps --- plugins/commands/ps/command.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/commands/ps/command.rb b/plugins/commands/ps/command.rb index 3bcc41ba8..ee021d0ed 100644 --- a/plugins/commands/ps/command.rb +++ b/plugins/commands/ps/command.rb @@ -50,9 +50,11 @@ module VagrantPlugins end if !options[:command].nil? - out_code = machine.communicate.execute(options[:command]) + out_code = machine.communicate.execute(options[:command].dup) do |type,data| + machine.ui.detail(data) if type == :stdout + end if out_code == 0 - machine.ui.detail("Command: #{options[:command]} executed succesfully with output code #{out_code}.") + machine.ui.success("Command: #{options[:command]} executed succesfully with output code #{out_code}.") end next end From e6daf2f17279c7ec1452cec1123ad13dccf52890 Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Fri, 5 Jun 2015 22:24:05 -0700 Subject: [PATCH 008/354] fix pscommand error messaging --- plugins/commands/ps/command.rb | 4 ++-- plugins/commands/ps/errors.rb | 10 +++++++--- templates/locales/command_ps.yml | 13 ++++++++++++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/plugins/commands/ps/command.rb b/plugins/commands/ps/command.rb index ee021d0ed..63963491a 100644 --- a/plugins/commands/ps/command.rb +++ b/plugins/commands/ps/command.rb @@ -91,7 +91,7 @@ module VagrantPlugins args << "-password" << ps_info[:password] result = Vagrant::Util::PowerShell.execute(script_path, *args) if result.exit_code != 0 - raise Errors::PowershellError, + raise Errors::PowerShellError, script: script_path, stderr: result.stderr end @@ -108,7 +108,7 @@ module VagrantPlugins args << "-hostname" << ps_info[:host] result = Vagrant::Util::PowerShell.execute(script_path, *args) if result.exit_code != 0 - raise Errors::PowershellError, + raise Errors::PowerShellError, script: script_path, stderr: result.stderr end diff --git a/plugins/commands/ps/errors.rb b/plugins/commands/ps/errors.rb index c614fb87a..4be70551a 100644 --- a/plugins/commands/ps/errors.rb +++ b/plugins/commands/ps/errors.rb @@ -2,17 +2,21 @@ module VagrantPlugins module CommandPS module Errors # A convenient superclass for all our errors. - class PSError < Vagrant::Errors::VagrantError + class PSCommandError < Vagrant::Errors::VagrantError error_namespace("vagrant_ps.errors") end - class HostUnsupported < PSError + class HostUnsupported < PSCommandError error_key(:host_unsupported) end - class PSRemotingUndetected < PSError + class PSRemotingUndetected < PSCommandError error_key(:ps_remoting_undetected) end + + class PowerShellError < PSCommandError + error_key(:powershell_error) + end end end end diff --git a/templates/locales/command_ps.yml b/templates/locales/command_ps.yml index 51bf666cc..179aae842 100644 --- a/templates/locales/command_ps.yml +++ b/templates/locales/command_ps.yml @@ -3,7 +3,7 @@ en: detecting: |- Detecting if a remote PowerShell connection can be made with the guest... reseting: |- - Reseting WinRM TrustedHosts to their original value. + Resetting WinRM TrustedHosts to their original value. errors: host_unsupported: |- @@ -14,3 +14,14 @@ en: Unable to establish a remote PowerShell connection with the guest. Check if the firewall rules on the guest allow connections to the Windows remote management service. + + powershell_error: |- + An error occurred while executing a PowerShell script. This error + is shown below. Please read the error message and see if this is + a configuration error with your system. If it is not, then please + report a bug. + + Script: %{script} + Error: + + %{stderr} From 209556c3cdd426cbcca51a186e0b10be52aa7dd7 Mon Sep 17 00:00:00 2001 From: Jon Burgess Date: Fri, 17 Jul 2015 14:26:13 +1000 Subject: [PATCH 009/354] Allow provisioner instance names to be specified for `up` and `reload` commands and option `--provision-with` Ref: https://github.com/mitchellh/vagrant/issues/5139 --- plugins/commands/reload/command.rb | 2 +- plugins/commands/up/command.rb | 2 +- plugins/commands/up/start_mixins.rb | 23 ++++++++++++++++------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/plugins/commands/reload/command.rb b/plugins/commands/reload/command.rb index 33a6f8e5e..1d43d13b7 100644 --- a/plugins/commands/reload/command.rb +++ b/plugins/commands/reload/command.rb @@ -30,7 +30,7 @@ module VagrantPlugins return if !argv # Validate the provisioners - validate_provisioner_flags!(options) + validate_provisioner_flags!(options, argv) @logger.debug("'reload' each target VM...") machines = [] diff --git a/plugins/commands/up/command.rb b/plugins/commands/up/command.rb index 826bea0ae..e340dad96 100644 --- a/plugins/commands/up/command.rb +++ b/plugins/commands/up/command.rb @@ -48,7 +48,7 @@ module VagrantPlugins return if !argv # Validate the provisioners - validate_provisioner_flags!(options) + validate_provisioner_flags!(options, argv) # Go over each VM and bring it up @logger.debug("'Up' each target VM...") diff --git a/plugins/commands/up/start_mixins.rb b/plugins/commands/up/start_mixins.rb index 548d889ca..8be96c68a 100644 --- a/plugins/commands/up/start_mixins.rb +++ b/plugins/commands/up/start_mixins.rb @@ -26,13 +26,22 @@ module VagrantPlugins # This validates the provisioner flags and raises an exception # if there are invalid ones. - def validate_provisioner_flags!(options) - (options[:provision_types] || []).each do |type| - klass = Vagrant.plugin("2").manager.provisioners[type] - if !klass - raise Vagrant::Errors::ProvisionerFlagInvalid, - name: type.to_s - end + def validate_provisioner_flags!(options, argv) + provisioner_instance_names = [] + with_target_vms(argv) do |machine| + provisioner_instance_names << machine.config.vm.provisioners.map(&:name) + end + + provisioner_instance_names.flatten!.uniq! + + if (provisioner_instance_names & options[:provision_types]).empty? + (options[:provision_types] || []).each do |type| + klass = Vagrant.plugin("2").manager.provisioners[type] + if !klass + raise Vagrant::Errors::ProvisionerFlagInvalid, + name: type.to_s + end + end end end end From d2b0df0a7d3f63eaeca81585edb81f9d9be7f83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Br=C3=A6khus?= Date: Fri, 17 Jul 2015 21:44:58 +0200 Subject: [PATCH 010/354] Specify time and don't do -h -H which is not really a valid usage. --- plugins/guests/debian8/cap/halt.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/guests/debian8/cap/halt.rb b/plugins/guests/debian8/cap/halt.rb index 932281347..b2e5a141b 100644 --- a/plugins/guests/debian8/cap/halt.rb +++ b/plugins/guests/debian8/cap/halt.rb @@ -4,7 +4,7 @@ module VagrantPlugins class Halt def self.halt(machine) begin - machine.communicate.sudo("shutdown -h -H") + machine.communicate.sudo("shutdown -h now") rescue IOError # Do nothing, because it probably means the machine shut down # and SSH connection was lost. From f349a58a1e32ba68deedeca57eae1b67a8266ec3 Mon Sep 17 00:00:00 2001 From: Mattias Appelgren Date: Sat, 18 Jul 2015 13:54:58 +0200 Subject: [PATCH 011/354] provisioners/puppet: Fix Puppet environment default manifest Also parse the puppet variables $codedir and $environment when resolving a manifest path from environment.conf --- plugins/provisioners/puppet/provisioner/puppet.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb index f1987dbd5..d1e124e85 100644 --- a/plugins/provisioners/puppet/provisioner/puppet.rb +++ b/plugins/provisioners/puppet/provisioner/puppet.rb @@ -62,12 +62,16 @@ module VagrantPlugins # Parse out the environment manifest path since puppet apply doesnt do that for us. environment_conf = File.join(environments_guest_path, @config.environment, "environment.conf") if @machine.communicate.test("test -e #{environment_conf}", sudo: true) - conf = @machine.communicate.sudo("cat #{environment_conf}") do | type, data| + @machine.communicate.sudo("cat #{environment_conf}") do | type, data| if type == :stdout data.each_line do |line| if line =~ /^\s*manifest\s+=\s+([^\s]+)/ @manifest_file = $1 - @manifest_file.gsub! '$basemodulepath:', "#{environments_guest_path}/#{@config.environment}/" + @manifest_file.gsub! "$codedir", File.dirname(environments_guest_path) + @manifest_file.gsub! "$environment", @config.environment + if !@manifest_file.start_with? "/" + @manifest_file = File.join(environments_guest_path, @config.environment, @manifest_file) + end @logger.debug("Using manifest from environment.conf: #{@manifest_file}") end end @@ -85,7 +89,7 @@ module VagrantPlugins # In environment mode we still need to specify a manifest file, if its not, use the one from env config if specified. if !@manifest_file - @manifest_file = "#{environments_guest_path}/#{@config.environment}/manifests/site.pp" + @manifest_file = "#{environments_guest_path}/#{@config.environment}/manifests" parse_environment_metadata end # Check that the shared folders are properly shared From 27b948f53ccd3e5743fc223f2e70617ecf663c83 Mon Sep 17 00:00:00 2001 From: Mattias Appelgren Date: Sat, 18 Jul 2015 14:20:57 +0200 Subject: [PATCH 012/354] website/docs: Add more information regarding Puppet environments --- .../docs/source/v2/provisioning/puppet_apply.html.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/website/docs/source/v2/provisioning/puppet_apply.html.md b/website/docs/source/v2/provisioning/puppet_apply.html.md index 89fe90195..b8f0a5f02 100644 --- a/website/docs/source/v2/provisioning/puppet_apply.html.md +++ b/website/docs/source/v2/provisioning/puppet_apply.html.md @@ -140,8 +140,9 @@ that the path is located in the "vm" at "/path/to/manifests". ## Environments -If you are using Puppet 4 or higher, you can also specify the name of the -Puppet environment and the path on the local disk to the environment files: +If you are using Puppet 4 or higher, you can proivision using +[Puppet Environments](https://docs.puppetlabs.com/puppet/latest/reference/environments.html) by specifying the name of the environment and the path on the +local disk to the environment files: ```ruby Vagrant.configure("2") do |config| @@ -152,6 +153,13 @@ Vagrant.configure("2") do |config| end ``` +The default manifest is the environment's `manifests` directory. +If the environment has an `environment.conf` the manifest path is parsed +from there. Relative paths are assumed to be relative to the directory of +the environment. If the manifest setting in `environment.conf` use +the Puppet variables `$codedir` or `$environment` they are resoled to +the parent directory of `environment_path` and `environment` respectively. + ## Modules Vagrant also supports provisioning with [Puppet modules](http://docs.puppetlabs.com/guides/modules.html). From 19b7bbc369b1d6dd27491a3e8da78e3e93466daa Mon Sep 17 00:00:00 2001 From: Pat O'Shea Date: Sat, 18 Jul 2015 08:39:00 -0600 Subject: [PATCH 013/354] Corrected masterless example The basic Vagrantfile file example for a masterless setup doesn't set the masterless value. That property defaults to false. https://github.com/mitchellh/vagrant/blob/master/plugins/provisioners/salt/provisioner.rb --- website/docs/source/v2/provisioning/salt.html.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/docs/source/v2/provisioning/salt.html.md b/website/docs/source/v2/provisioning/salt.html.md index 8169ec28e..1799a09dd 100644 --- a/website/docs/source/v2/provisioning/salt.html.md +++ b/website/docs/source/v2/provisioning/salt.html.md @@ -30,7 +30,8 @@ on a single minion, without a master: ## Use all the defaults: config.vm.provision :salt do |salt| - + + salt.masterless = true salt.minion_config = "salt/minion" salt.run_highstate = true From d34bc38bf39ce9a045dcc4c96c8f2693ef1280a3 Mon Sep 17 00:00:00 2001 From: Pat O'Shea Date: Sat, 18 Jul 2015 20:53:46 -0600 Subject: [PATCH 014/354] Updated salt-minion and call ext on windows guest Salt-minion and salt-call are batch files on a windows guest, not executables. --- plugins/provisioners/salt/provisioner.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/provisioners/salt/provisioner.rb b/plugins/provisioners/salt/provisioner.rb index d74c4fa11..b5f65f1ae 100644 --- a/plugins/provisioners/salt/provisioner.rb +++ b/plugins/provisioners/salt/provisioner.rb @@ -35,8 +35,8 @@ module VagrantPlugins desired_binaries = [] if !@config.no_minion if @machine.config.vm.communicator == :winrm - desired_binaries.push('C:\\salt\\salt-minion.exe') - desired_binaries.push('C:\\salt\\salt-call.exe') + desired_binaries.push('C:\\salt\\salt-minion.bat') + desired_binaries.push('C:\\salt\\salt-call.bat') else desired_binaries.push('salt-minion') desired_binaries.push('salt-call') @@ -361,8 +361,8 @@ module VagrantPlugins else if @machine.config.vm.communicator == :winrm opts = { elevated: true } - @machine.communicate.execute("C:\\salt\\salt-call.exe saltutil.sync_all", opts) - @machine.communicate.execute("C:\\salt\\salt-call.exe state.highstate --retcode-passthrough #{get_loglevel}#{get_colorize}#{get_pillar}", opts) do |type, data| + @machine.communicate.execute("C:\\salt\\salt-call.bat saltutil.sync_all", opts) + @machine.communicate.execute("C:\\salt\\salt-call.bat state.highstate --retcode-passthrough #{get_loglevel}#{get_colorize}#{get_pillar}", opts) do |type, data| if @config.verbose @machine.env.ui.info(data.rstrip) end From 562ed26533a072b4a255ba7d9fe31b1260c367e6 Mon Sep 17 00:00:00 2001 From: Ievgen Prokhorenko Date: Sun, 19 Jul 2015 16:38:52 +0300 Subject: [PATCH 015/354] Fix #3570 'Box data left in ~/.vagrant.d/boxes after removal' --- lib/vagrant/action/builtin/box_remove.rb | 1 + lib/vagrant/box_collection.rb | 28 ++++++++++++++++--- .../vagrant/action/builtin/box_remove_test.rb | 26 +++++++++++++++++ 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/lib/vagrant/action/builtin/box_remove.rb b/lib/vagrant/action/builtin/box_remove.rb index 1d0cea7fd..4c242aa97 100644 --- a/lib/vagrant/action/builtin/box_remove.rb +++ b/lib/vagrant/action/builtin/box_remove.rb @@ -106,6 +106,7 @@ module Vagrant provider: box.provider, version: box.version)) box.destroy! + env[:box_collection].clean_up(box) # Passes on the removed box to the rest of the middleware chain env[:box_removed] = box diff --git a/lib/vagrant/box_collection.rb b/lib/vagrant/box_collection.rb index a7599f7c2..17c2f3927 100644 --- a/lib/vagrant/box_collection.rb +++ b/lib/vagrant/box_collection.rb @@ -13,6 +13,8 @@ module Vagrant # boxes. class BoxCollection TEMP_PREFIX = "vagrant-box-add-temp-" + VAGRANT_SLASH = "-VAGRANTSLASH-" + VAGRANT_COLON = "-VAGRANTCOLON-" # The directory where the boxes in this collection are stored. # @@ -346,6 +348,19 @@ module Vagrant end end + # Removes the whole directory of a given box if there are no + # other versions nor providers of the box exist. + def clean_up(box) + return false if exists?(box.name) + + box_directory = box.name + .gsub('/', VAGRANT_SLASH) + .gsub(':', VAGRANT_COLON) + + path = File.join(directory, box_directory) + FileUtils.rm_r(path) + end + protected # Returns the directory name for the box of the given name. @@ -354,16 +369,16 @@ module Vagrant # @return [String] def dir_name(name) name = name.dup - name.gsub!(":", "-VAGRANTCOLON-") if Util::Platform.windows? - name.gsub!("/", "-VAGRANTSLASH-") + name.gsub!(":", VAGRANT_COLON) if Util::Platform.windows? + name.gsub!("/", VAGRANT_SLASH) name end # Returns the directory name for the box cleaned up def undir_name(name) name = name.dup - name.gsub!("-VAGRANTCOLON-", ":") - name.gsub!("-VAGRANTSLASH-", "/") + name.gsub!(VAGRANT_COLON, ":") + name.gsub!(VAGRANT_SLASH, "/") name end @@ -440,5 +455,10 @@ module Vagrant ensure dir.rmtree if dir.exist? end + + # Checks if a box with a given name exists. + def exists?(box_name) + all.any? { |box| box.first.eql?(box_name) } + end end end diff --git a/test/unit/vagrant/action/builtin/box_remove_test.rb b/test/unit/vagrant/action/builtin/box_remove_test.rb index 9de3e467b..016fec243 100644 --- a/test/unit/vagrant/action/builtin/box_remove_test.rb +++ b/test/unit/vagrant/action/builtin/box_remove_test.rb @@ -30,6 +30,8 @@ describe Vagrant::Action::Builtin::BoxRemove do expect(box_collection).to receive(:find).with( "foo", :virtualbox, "1.0").and_return(box) + expect(box_collection).to receive(:clean_up).with(box) + .and_return(true) expect(box).to receive(:destroy!).once expect(app).to receive(:call).with(env).once @@ -50,6 +52,8 @@ describe Vagrant::Action::Builtin::BoxRemove do expect(box_collection).to receive(:find).with( "foo", :virtualbox, "1.0").and_return(box) + expect(box_collection).to receive(:clean_up).with(box) + .and_return(false) expect(box).to receive(:destroy!).once expect(app).to receive(:call).with(env).once @@ -70,6 +74,8 @@ describe Vagrant::Action::Builtin::BoxRemove do expect(box_collection).to receive(:find).with( "foo", :virtualbox, "1.0").and_return(box) + expect(box_collection).to receive(:clean_up).with(box) + .and_return(false) expect(box).to receive(:destroy!).once expect(app).to receive(:call).with(env).once @@ -78,6 +84,22 @@ describe Vagrant::Action::Builtin::BoxRemove do expect(env[:box_removed]).to equal(box) end + it "deletes the whole directory of the box if it's the last box on the system" do + box_collection.stub( + all: [ + ["foo", "1.0", :virtualbox], + ]) + + env[:box_name] = "foo" + + expect(box_collection).to receive(:find).with( + "foo", :virtualbox, "1.0").and_return(box) + expect(box_collection).to receive(:clean_up).with(box) + .and_return(true) + + subject.call(env) + end + context "checking if a box is in use" do def new_entry(name, provider, version, valid=true) Vagrant::MachineIndex::Entry.new.tap do |entry| @@ -110,6 +132,8 @@ describe Vagrant::Action::Builtin::BoxRemove do expect(box_collection).to receive(:find).with( "foo", :virtualbox, "1.0").and_return(box) expect(box).to receive(:destroy!).once + expect(box_collection).to receive(:clean_up).with(box) + .and_return(true) subject.call(env) end @@ -123,6 +147,8 @@ describe Vagrant::Action::Builtin::BoxRemove do expect(box_collection).to receive(:find).with( "foo", :virtualbox, "1.0").and_return(box) + expect(box_collection).to receive(:clean_up).with(box) + .and_return(true) expect(box).to receive(:destroy!).once subject.call(env) From e4cdb473bd1a7ad666ddc9f398c661f62a9cfb2c Mon Sep 17 00:00:00 2001 From: Brian Dwyer Date: Tue, 28 Jul 2015 12:41:51 -0400 Subject: [PATCH 016/354] Bring back `nodes_path` support for the Chef Zero provisioner --- plugins/provisioners/chef/config/chef_zero.rb | 7 +++++++ plugins/provisioners/chef/provisioner/chef_solo.rb | 2 ++ plugins/provisioners/chef/provisioner/chef_zero.rb | 1 + templates/provisioners/chef_zero/zero.erb | 4 ++-- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/provisioners/chef/config/chef_zero.rb b/plugins/provisioners/chef/config/chef_zero.rb index d28de3dc9..9b1daf1a5 100644 --- a/plugins/provisioners/chef/config/chef_zero.rb +++ b/plugins/provisioners/chef/config/chef_zero.rb @@ -17,6 +17,10 @@ module VagrantPlugins # @return [String] attr_accessor :environments_path + # The path where nodes are stored on disk. + # @return [String] + attr_accessor :nodes_path + # The path where roles are stored on disk. # @return [String] attr_accessor :roles_path @@ -31,6 +35,7 @@ module VagrantPlugins @cookbooks_path = UNSET_VALUE @data_bags_path = UNSET_VALUE @environments_path = UNSET_VALUE + @nodes_path = UNSET_VALUE @roles_path = UNSET_VALUE @synced_folder_type = UNSET_VALUE end @@ -47,6 +52,7 @@ module VagrantPlugins end @data_bags_path = [] if @data_bags_path == UNSET_VALUE + @nodes_path = [] if @nodes_path == UNSET_VALUE @roles_path = [] if @roles_path == UNSET_VALUE @environments_path = [] if @environments_path == UNSET_VALUE @environments_path = [@environments_path].flatten @@ -54,6 +60,7 @@ module VagrantPlugins # Make sure the path is an array. @cookbooks_path = prepare_folders_config(@cookbooks_path) @data_bags_path = prepare_folders_config(@data_bags_path) + @nodes_path = prepare_folders_config(@nodes_path) @roles_path = prepare_folders_config(@roles_path) @environments_path = prepare_folders_config(@environments_path) diff --git a/plugins/provisioners/chef/provisioner/chef_solo.rb b/plugins/provisioners/chef/provisioner/chef_solo.rb index f3b52f178..14ee5747c 100644 --- a/plugins/provisioners/chef/provisioner/chef_solo.rb +++ b/plugins/provisioners/chef/provisioner/chef_solo.rb @@ -33,12 +33,14 @@ module VagrantPlugins @role_folders = expanded_folders(@config.roles_path, "roles") @data_bags_folders = expanded_folders(@config.data_bags_path, "data_bags") @environments_folders = expanded_folders(@config.environments_path, "environments") + @node_folders = expanded_folders(@config.nodes_path, "nodes") existing = synced_folders(@machine, cached: true) share_folders(root_config, "csc", @cookbook_folders, existing) share_folders(root_config, "csr", @role_folders, existing) share_folders(root_config, "csdb", @data_bags_folders, existing) share_folders(root_config, "cse", @environments_folders, existing) + share_folders(root_config, "csn", @node_folders, existing) end def provision diff --git a/plugins/provisioners/chef/provisioner/chef_zero.rb b/plugins/provisioners/chef/provisioner/chef_zero.rb index 48078a09f..70fff6854 100644 --- a/plugins/provisioners/chef/provisioner/chef_zero.rb +++ b/plugins/provisioners/chef/provisioner/chef_zero.rb @@ -44,6 +44,7 @@ module VagrantPlugins local_mode: true, enable_reporting: false, cookbooks_path: guest_paths(@cookbook_folders), + nodes_path: guest_paths(@node_folders), roles_path: guest_paths(@role_folders), data_bags_path: guest_paths(@data_bags_folders).first, environments_path: guest_paths(@environments_folders).first, diff --git a/templates/provisioners/chef_zero/zero.erb b/templates/provisioners/chef_zero/zero.erb index 29de30d23..8c4b76407 100644 --- a/templates/provisioners/chef_zero/zero.erb +++ b/templates/provisioners/chef_zero/zero.erb @@ -31,8 +31,8 @@ environment "<%= environment %>" chef_zero.enabled true local_mode true <% end -%> -<% if node_path -%> -node_path <%= node_path.inspect %> +<% if nodes_path -%> +node_path <%= nodes_path.inspect %> <% end -%> <% if formatter %> From 15ec95328ad962ee4326e3cdcaca376af7cea8e0 Mon Sep 17 00:00:00 2001 From: Brian Dwyer Date: Tue, 28 Jul 2015 13:24:39 -0400 Subject: [PATCH 017/354] Update test --- .../plugins/provisioners/chef/config/chef_zero_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/unit/plugins/provisioners/chef/config/chef_zero_test.rb b/test/unit/plugins/provisioners/chef/config/chef_zero_test.rb index 2f9cd82aa..9a1f98cd6 100644 --- a/test/unit/plugins/provisioners/chef/config/chef_zero_test.rb +++ b/test/unit/plugins/provisioners/chef/config/chef_zero_test.rb @@ -50,6 +50,14 @@ describe VagrantPlugins::Chef::Config::ChefZero do end end + describe "#nodes_path" do + it "defaults to an empty array" do + subject.finalize! + expect(subject.nodes_path).to be_a(Array) + expect(subject.nodes_path).to be_empty + end + end + describe "#synced_folder_type" do it "defaults to nil" do subject.finalize! From 01f0dccbdc3f26842ed74a018f7cf828e9e19234 Mon Sep 17 00:00:00 2001 From: Brian Dwyer Date: Tue, 28 Jul 2015 13:25:25 -0400 Subject: [PATCH 018/354] Update documentation for Chef Zero `nodes_path` --- website/docs/source/v2/provisioning/chef_zero.html.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/website/docs/source/v2/provisioning/chef_zero.html.md b/website/docs/source/v2/provisioning/chef_zero.html.md index 4f35f362a..bd2527fc9 100644 --- a/website/docs/source/v2/provisioning/chef_zero.html.md +++ b/website/docs/source/v2/provisioning/chef_zero.html.md @@ -41,6 +41,9 @@ available below this section. * `environments_path` (string) - A path where environment definitions are located. By default, no environments folder is set. +* `nodes_path` (string or array) - A list of paths where node objects (in JSON format) are stored. By default, no + nodes path is set. + * `environment` (string) - The environment you want the Chef run to be a part of. This requires Chef 11.6.0 or later, and that `environments_path` is set. From 3f29be0de2e64498fa7b6d4bfcbe6414e1a5604b Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Tue, 28 Jul 2015 11:16:20 -0700 Subject: [PATCH 019/354] Fix string parse error in the environment path missing error message. --- plugins/provisioners/puppet/config/puppet.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/provisioners/puppet/config/puppet.rb b/plugins/provisioners/puppet/config/puppet.rb index 9910c6e05..0761294ca 100644 --- a/plugins/provisioners/puppet/config/puppet.rb +++ b/plugins/provisioners/puppet/config/puppet.rb @@ -143,7 +143,7 @@ module VagrantPlugins if !expanded_environment_file.file? && !expanded_environment_file.directory? errors << I18n.t("vagrant.provisioners.puppet.environment_missing", environment: environment.to_s, - environment_path: expanded_path.to_s) + environmentpath: expanded_path.to_s) end end end From f13220cd748d67430f4236eefff9dfa69ef68237 Mon Sep 17 00:00:00 2001 From: Casey Lang Date: Fri, 31 Jul 2015 14:10:57 -0400 Subject: [PATCH 020/354] Clarify config.ssh.insert_key docs Modified the description of `config.ssh.insert_key` a bit to improve readability. --- website/docs/source/v2/vagrantfile/ssh_settings.html.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/source/v2/vagrantfile/ssh_settings.html.md b/website/docs/source/v2/vagrantfile/ssh_settings.html.md index b07835b75..cadeca060 100644 --- a/website/docs/source/v2/vagrantfile/ssh_settings.html.md +++ b/website/docs/source/v2/vagrantfile/ssh_settings.html.md @@ -68,12 +68,12 @@ is enabled. Defaults to false.
`config.ssh.insert_key` - If `true`, Vagrant will automatically insert -an keypair to use for SSH, replacing the default Vagrant's insecure key +a keypair to use for SSH, replacing Vagrant's default insecure key inside the machine if detected. By default, this is true. This only has an effect if you don't already use private keys for authentication or if you are relying on the default insecure key. -If you don't have to take care about security in your project and want to +If you don't have to care about security in your project and want to keep using the default insecure key, set this to `false`.
From ea7b277f411da996fd911fe24e1219fe13800ff0 Mon Sep 17 00:00:00 2001 From: John Syrinek Date: Fri, 31 Jul 2015 16:05:55 -0500 Subject: [PATCH 021/354] Prevent fatal error caused by attempting to upload minion config to privileged directory --- plugins/provisioners/salt/config.rb | 18 ------------------ plugins/provisioners/salt/provisioner.rb | 5 ----- 2 files changed, 23 deletions(-) diff --git a/plugins/provisioners/salt/config.rb b/plugins/provisioners/salt/config.rb index 9c564179e..38aaec8de 100644 --- a/plugins/provisioners/salt/config.rb +++ b/plugins/provisioners/salt/config.rb @@ -20,7 +20,6 @@ module VagrantPlugins attr_accessor :bootstrap_script attr_accessor :verbose attr_accessor :seed_master - attr_accessor :config_dir attr_reader :pillar_data attr_accessor :colorize attr_accessor :log_level @@ -65,7 +64,6 @@ module VagrantPlugins @install_command = UNSET_VALUE @no_minion = UNSET_VALUE @bootstrap_options = UNSET_VALUE - @config_dir = UNSET_VALUE @masterless = UNSET_VALUE @minion_id = UNSET_VALUE @version = UNSET_VALUE @@ -98,7 +96,6 @@ module VagrantPlugins @install_command = nil if @install_command == UNSET_VALUE @no_minion = nil if @no_minion == UNSET_VALUE @bootstrap_options = nil if @bootstrap_options == UNSET_VALUE - @config_dir = nil if @config_dir == UNSET_VALUE @masterless = false if @masterless == UNSET_VALUE @minion_id = nil if @minion_id == UNSET_VALUE @version = nil if @version == UNSET_VALUE @@ -111,17 +108,6 @@ module VagrantPlugins @pillar_data = Vagrant::Util::DeepMerge.deep_merge(@pillar_data, data) end - def default_config_dir(machine) - guest_type = machine.config.vm.guest || :linux - - # FIXME: there should be a way to do that a bit smarter - if guest_type == :windows - return "C:\\salt\\conf" - else - return "/etc/salt" - end - end - def validate(machine) errors = _detected_errors if @minion_config @@ -161,10 +147,6 @@ module VagrantPlugins errors << I18n.t("vagrant.provisioners.salt.must_accept_keys") end - if @config_dir.nil? - @config_dir = default_config_dir(machine) - end - return {"salt provisioner" => errors} end end diff --git a/plugins/provisioners/salt/provisioner.rb b/plugins/provisioners/salt/provisioner.rb index d74c4fa11..5b217da4b 100644 --- a/plugins/provisioners/salt/provisioner.rb +++ b/plugins/provisioners/salt/provisioner.rb @@ -342,11 +342,6 @@ module VagrantPlugins end def call_highstate - if @config.minion_config - @machine.env.ui.info "Copying salt minion config to #{@config.config_dir}" - @machine.communicate.upload(expanded_path(@config.minion_config).to_s, @config.config_dir + "/minion") - end - if @config.masterless call_masterless elsif @config.run_highstate From 587c88e65ae294c4f2939937c2079c545efd17cb Mon Sep 17 00:00:00 2001 From: Mike Averto Date: Sun, 9 Aug 2015 12:44:49 -0400 Subject: [PATCH 022/354] Fix Win 10 Enterprise Vagrant Error This fixes error for Win 10 Enterprise: An error occurred while executing a PowerShell script. This error is shown below. Please read the error message and see if this is a configuration error with your system. If it is not, then please report a bug. Script: get_vm_status.ps1 Error: C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.4\plugins\providers\hyperv\scripts\get_vm_status.ps1 : Unable to find type [Microsoft.HyperV.PowerShell.VirtualizationOperationFailedException]. At line:1 char:1 + &('C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.4\plugins\prov ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (Microsoft.Hyper...FailedException:TypeName) [get_vm_status.ps1], Ru ntimeException + FullyQualifiedErrorId : TypeNotFound,get_vm_status.ps1 --- plugins/providers/hyperv/scripts/get_vm_status.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/providers/hyperv/scripts/get_vm_status.ps1 b/plugins/providers/hyperv/scripts/get_vm_status.ps1 index 739560190..5c1e1aa73 100644 --- a/plugins/providers/hyperv/scripts/get_vm_status.ps1 +++ b/plugins/providers/hyperv/scripts/get_vm_status.ps1 @@ -12,7 +12,7 @@ try { $VM = Get-VM -Id $VmId -ErrorAction "Stop" $State = $VM.state $Status = $VM.status -} catch [Microsoft.HyperV.PowerShell.VirtualizationOperationFailedException] { +} catch [Microsoft.HyperV.PowerShell.VirtualizationException] { $State = "not_created" $Status = $State } From 6f59c8bb548c70053c23c80ca7fb62429fa99496 Mon Sep 17 00:00:00 2001 From: Victor Costan Date: Sat, 15 Aug 2015 06:19:51 -0400 Subject: [PATCH 023/354] The docs typo'd the nic_type parameter The parameter name in the VirtualBox provider source is nic_type, not nictype. The typo is probably caused by the fact that the parameter maps to nictype args in the VirtualBox CLI. --- website/docs/source/v2/virtualbox/networking.html.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/docs/source/v2/virtualbox/networking.html.md b/website/docs/source/v2/virtualbox/networking.html.md index 55e7d4c4c..5811373de 100644 --- a/website/docs/source/v2/virtualbox/networking.html.md +++ b/website/docs/source/v2/virtualbox/networking.html.md @@ -36,8 +36,8 @@ end ## VirtualBox NIC Type -You can specify a specific nictype for the created network interface -by using the `nictype` parameter. This isn't prefixed by `virtualbox__` +You can specify a specific NIC type for the created network interface +by using the `nic_type` parameter. This isn't prefixed by `virtualbox__` for legacy reasons, but is VirtualBox-specific. This is an advanced option and should only be used if you know what @@ -48,6 +48,6 @@ Example: ```ruby Vagrant.configure("2") do |config| config.vm.network "private_network", ip: "192.168.50.4", - nictype: "virtio" + nic_type: "virtio" end ``` From 4425d91d863b3b36347ebc53550b13d8e6e5bc37 Mon Sep 17 00:00:00 2001 From: Victor Costan Date: Sat, 15 Aug 2015 06:53:01 -0400 Subject: [PATCH 024/354] Don't warn about an .1 IP for DHCP networks When the network's type is :dhcp, the :ip option is used to derive the DHCP server configuration, and it doesn't actually indicate the IP that will be received by the VM(s). --- plugins/kernel_v2/config/vm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 2de1b343f..5f2486179 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -688,7 +688,7 @@ module VagrantPlugins end end - if options[:ip] && options[:ip].end_with?(".1") + if options[:ip] && options[:ip].end_with?(".1") && options[:type].to_sym != :dhcp machine.ui.warn(I18n.t( "vagrant.config.vm.network_ip_ends_in_one")) end From 0f8a88f4975a68c13057d7bcb6b55d04081a0766 Mon Sep 17 00:00:00 2001 From: Justin Campbell Date: Mon, 17 Aug 2015 11:22:24 -0400 Subject: [PATCH 025/354] website/www: Fix logos/copyright alignment Before: ![](http://cl.ly/image/2g2h0v1Z371r/Screen%20Shot%202015-08-17%20at%2011.22.48%20AM.png) After: ![](http://cl.ly/image/0s1e2a272o2q/Screen%20Shot%202015-08-17%20at%2011.21.31%20AM.png) --- website/www/source/layouts/layout.erb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/website/www/source/layouts/layout.erb b/website/www/source/layouts/layout.erb index 4e6736743..a510d31bf 100644 --- a/website/www/source/layouts/layout.erb +++ b/website/www/source/layouts/layout.erb @@ -78,9 +78,11 @@
- +
+ +
From c58c9a1ffccd576c6c08fb2edc721258808b9d6d Mon Sep 17 00:00:00 2001 From: Justin Campbell Date: Mon, 17 Aug 2015 11:29:46 -0400 Subject: [PATCH 026/354] website/www: Add Atlas box search to nav --- website/www/source/layouts/layout.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/website/www/source/layouts/layout.erb b/website/www/source/layouts/layout.erb index 4e6736743..cbf2b8c88 100644 --- a/website/www/source/layouts/layout.erb +++ b/website/www/source/layouts/layout.erb @@ -41,6 +41,7 @@