From 7da9648089cb866bf0ebd8cca62ba9cb0b4a8fb4 Mon Sep 17 00:00:00 2001 From: Takekazu Omi Date: Thu, 8 May 2014 17:59:45 +0900 Subject: [PATCH 001/615] fix subprocess external encode issue. https://github.com/mitchellh/vagrant/issues/3706 in io.rb subprocess resuts convert external encoding to utf-8 in subprocess.rb command line argument convert utf-8 to external encoding --- lib/vagrant/util/io.rb | 2 +- lib/vagrant/util/subprocess.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/util/io.rb b/lib/vagrant/util/io.rb index b38bc3eef..692ece4f9 100644 --- a/lib/vagrant/util/io.rb +++ b/lib/vagrant/util/io.rb @@ -29,7 +29,7 @@ module Vagrant break if !results || results[0].empty? # Read! - data << io.readpartial(READ_CHUNK_SIZE) + data << io.readpartial(READ_CHUNK_SIZE).encode("UTF-8", Encoding.default_external) else # Do a simple non-blocking read on the IO object data << io.read_nonblock(READ_CHUNK_SIZE) diff --git a/lib/vagrant/util/subprocess.rb b/lib/vagrant/util/subprocess.rb index 37490452f..be13679c4 100644 --- a/lib/vagrant/util/subprocess.rb +++ b/lib/vagrant/util/subprocess.rb @@ -25,6 +25,7 @@ module Vagrant def initialize(*command) @options = command.last.is_a?(Hash) ? command.pop : {} @command = command.dup + @command.each { |s| s.encode!(Encoding.default_external) } @command[0] = Which.which(@command[0]) if !File.file?(@command[0]) if !@command[0] raise Errors::CommandUnavailableWindows, file: command[0] if Platform.windows? From e64f84491ef10cddef7cd6958b184a517b1a72d2 Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Thu, 17 Jul 2014 03:13:50 -0700 Subject: [PATCH 002/615] adding smb sync folder implementation for windows guests addressing #3699 --- .../windows/cap/choose_addressable_ip_addr.rb | 17 ++++++++++++++ .../guests/windows/cap/mount_shared_folder.rb | 5 ++++ plugins/guests/windows/plugin.rb | 10 ++++++++ plugins/synced_folders/smb/synced_folder.rb | 23 ------------------- .../windows/cap/mount_shared_folder_test.rb | 19 +++++++++++++++ 5 files changed, 51 insertions(+), 23 deletions(-) create mode 100644 plugins/guests/windows/cap/choose_addressable_ip_addr.rb diff --git a/plugins/guests/windows/cap/choose_addressable_ip_addr.rb b/plugins/guests/windows/cap/choose_addressable_ip_addr.rb new file mode 100644 index 000000000..0403fc86c --- /dev/null +++ b/plugins/guests/windows/cap/choose_addressable_ip_addr.rb @@ -0,0 +1,17 @@ +module VagrantPlugins + module GuestWindows + module Cap + module ChooseAddressableIPAddr + def self.choose_addressable_ip_addr(machine, possible) + machine.communicate.tap do |comm| + possible.each do |ip| + return ip + end + end + + nil + end + end + end + end +end diff --git a/plugins/guests/windows/cap/mount_shared_folder.rb b/plugins/guests/windows/cap/mount_shared_folder.rb index 8f7866a1a..4329025f6 100644 --- a/plugins/guests/windows/cap/mount_shared_folder.rb +++ b/plugins/guests/windows/cap/mount_shared_folder.rb @@ -16,6 +16,11 @@ module VagrantPlugins mount_shared_folder(machine, name, guestpath, "\\\\psf\\") end + def self.mount_smb_shared_folder(machine, name, guestpath, options) + machine.communicate.execute("cmdkey /add:#{options[:smb_host]} /user:#{options[:smb_username]} /pass:#{options[:smb_password]}", {shell: :powershell, elevated: true}) + mount_shared_folder(machine, name, guestpath, "\\\\#{options[:smb_host]}\\") + end + protected def self.mount_shared_folder(machine, name, guestpath, vm_provider_unc_base) diff --git a/plugins/guests/windows/plugin.rb b/plugins/guests/windows/plugin.rb index fa1408314..fd70ae4a6 100644 --- a/plugins/guests/windows/plugin.rb +++ b/plugins/guests/windows/plugin.rb @@ -54,6 +54,16 @@ module VagrantPlugins Cap::Reboot end + guest_capability(:windows, :choose_addressable_ip_addr) do + require_relative "cap/choose_addressable_ip_addr" + Cap::ChooseAddressableIPAddr + end + + guest_capability(:windows, :mount_smb_shared_folder) do + require_relative "cap/mount_shared_folder" + Cap::MountSharedFolder + end + protected def self.init! diff --git a/plugins/synced_folders/smb/synced_folder.rb b/plugins/synced_folders/smb/synced_folder.rb index 2080efefc..8e700a183 100644 --- a/plugins/synced_folders/smb/synced_folder.rb +++ b/plugins/synced_folders/smb/synced_folder.rb @@ -150,29 +150,6 @@ module VagrantPlugins JSON.parse(r.stdout)["ip_addresses"] end - -=begin - def mount_shared_folders_to_windows - result = @env[:machine].provider.driver.execute('host_info.ps1', {}) - @smb_shared_folders.each do |id, data| - begin - options = { share_name: data[:share_name], - guest_path: data[:guestpath].gsub("/", "\\"), - guest_ip: ssh_info[:host], - username: ssh_info[:username], - host_ip: result["host_ip"], - password: @env[:machine].provider_config.guest.password, - host_share_username: @env[:machine].provider_config.host_share.username, - host_share_password: @env[:machine].provider_config.host_share.password} - @env[:ui].info("Linking #{data[:share_name]} to Guest at #{data[:guestpath]} ...") - @env[:machine].provider.driver.execute('mount_share.ps1', options) - rescue Error::SubprocessError => e - @env[:ui].info "Failed to link #{data[:share_name]} to Guest" - @env[:ui].info e.message - end - end - end -=end end end end diff --git a/test/unit/plugins/guests/windows/cap/mount_shared_folder_test.rb b/test/unit/plugins/guests/windows/cap/mount_shared_folder_test.rb index 93fe41799..bd443142b 100644 --- a/test/unit/plugins/guests/windows/cap/mount_shared_folder_test.rb +++ b/test/unit/plugins/guests/windows/cap/mount_shared_folder_test.rb @@ -79,4 +79,23 @@ describe "VagrantPlugins::GuestWindows::Cap::MountSharedFolder" do end end + describe "smb" do + + let(:described_class) do + VagrantPlugins::GuestWindows::Plugin.components.guest_capabilities[:windows].get(:mount_smb_shared_folder) + end + + describe ".mount_shared_folder" do + it "should call mount_volume script with correct args" do + expect(Vagrant::Util::TemplateRenderer).to receive(:render).with( + /.+scripts\/mount_volume.ps1/, options: { + mount_point: "guestpath", + share_name: "name", + vm_provider_unc_path: "\\\\host\\name", + }) + described_class.mount_smb_shared_folder(machine, 'name', 'guestpath', {:smb_username => "user", :smb_password => "pass", :smb_host => "host"}) + end + end + end + end From d820bef6f43d8a958c38362a5e5e29693b91251b Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Fri, 8 Aug 2014 21:18:16 -0700 Subject: [PATCH 003/615] filter host IPs to those that resolve on guest when finding addresable IPs on a windows guest --- plugins/guests/windows/cap/choose_addressable_ip_addr.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/guests/windows/cap/choose_addressable_ip_addr.rb b/plugins/guests/windows/cap/choose_addressable_ip_addr.rb index 0403fc86c..2304246ce 100644 --- a/plugins/guests/windows/cap/choose_addressable_ip_addr.rb +++ b/plugins/guests/windows/cap/choose_addressable_ip_addr.rb @@ -5,7 +5,10 @@ module VagrantPlugins def self.choose_addressable_ip_addr(machine, possible) machine.communicate.tap do |comm| possible.each do |ip| - return ip + command = "ping -n 1 -w 1 #{ip}" + if comm.test(command) + return ip + end end end From 10090bf4dcd6fd45cb24fb27c6a94128f5920537 Mon Sep 17 00:00:00 2001 From: SilverWyrda Date: Sat, 6 Sep 2014 04:56:01 +0200 Subject: [PATCH 004/615] Add support for predictable network interfaces names --- plugins/guests/arch/cap/configure_networks.rb | 46 ++++++++++--------- templates/guests/arch/network_dhcp.erb | 2 +- templates/guests/arch/network_static.erb | 2 +- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/plugins/guests/arch/cap/configure_networks.rb b/plugins/guests/arch/cap/configure_networks.rb index 5d2bc2aa6..b45d0b6d9 100644 --- a/plugins/guests/arch/cap/configure_networks.rb +++ b/plugins/guests/arch/cap/configure_networks.rb @@ -10,8 +10,28 @@ module VagrantPlugins include Vagrant::Util def self.configure_networks(machine, networks) + interfaces = Array.new + machine.communicate.sudo("ip -o -0 addr | grep -v LOOPBACK | awk + '{print $2}' | sed 's/://'") do |_, result| + interfaces = result.split("\n") + end + + # Cleaning of some dirty hacks documented here : + # (http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/) + machine.communicate.sudo("rm -f + /etc/udev/rules.d/*-net-name-slot.rules") + machine.communicate.sudo("rm -f + /etc/udev/rules.d/*-persistent-net.rules") + machine.communicate.sudo("udevadm control --reload") + networks.each do |network| - entry = TemplateRenderer.render("guests/arch/network_#{network[:type]}", + # We use :device in the template instead of + # eth#{network[:interface]} in order to support Predictable + # Network Interfaces + network[:device] = interfaces[network[:interface]] + + entry = + TemplateRenderer.render("guests/arch/network_#{network[:type]}", options: network) temp = Tempfile.new("vagrant") @@ -20,26 +40,10 @@ module VagrantPlugins temp.close machine.communicate.upload(temp.path, "/tmp/vagrant_network") - machine.communicate.sudo("ln -sf /dev/null /etc/udev/rules.d/80-net-name-slot.rules") - machine.communicate.sudo("udevadm control --reload") - machine.communicate.sudo("mv /tmp/vagrant_network /etc/netctl/eth#{network[:interface]}") - - # Only consider nth line of sed's output below. There's always an - # offset of two lines in the below sed command given the current - # interface number -> 1: lo, 2: nat device, - snth = network[:interface] + 2 - - # A hack not to rely on udev rule 80-net-name-slot.rules masking - # (ln -sf /dev/null /etc/udev/80-net-name-slot.rules). - # I assume this to be the most portable solution because - # otherwise we would need to rely on the Virtual Machine implementation - # to provide details on the configured interfaces, e.g mac address - # to write a custom udev rule. Templating the netcfg files and - # replacing the correct interface name within ruby seems more - # complicted too (I'm far from being a ruby expert though). - machine.communicate.sudo("sed -i \"s/eth#{network[:interface]}/`ip link | sed -n 's/.*:\\s\\(.*\\): <.*/\\1/p' | sed -n #{snth}p`/g\" /etc/netctl/eth#{network[:interface]}") - machine.communicate.sudo("ip link set eth#{network[:interface]} down") - machine.communicate.sudo("netctl start eth#{network[:interface]}") + machine.communicate.sudo("mv /tmp/vagrant_network + /etc/netctl/#{network[:device]}") + machine.communicate.sudo("ip link set #{network[:device]} down && + netctl start #{network[:device]}") end end end diff --git a/templates/guests/arch/network_dhcp.erb b/templates/guests/arch/network_dhcp.erb index cea4e8587..377784574 100644 --- a/templates/guests/arch/network_dhcp.erb +++ b/templates/guests/arch/network_dhcp.erb @@ -1,4 +1,4 @@ Description='A basic dhcp ethernet connection' -Interface=eth<%= options[:interface] %> +Interface=<%= options[:device] %> Connection=ethernet IP=dhcp diff --git a/templates/guests/arch/network_static.erb b/templates/guests/arch/network_static.erb index 6cf2b9a62..ee58ee75a 100644 --- a/templates/guests/arch/network_static.erb +++ b/templates/guests/arch/network_static.erb @@ -1,5 +1,5 @@ Connection=ethernet Description='A basic static ethernet connection' -Interface=eth<%= options[:interface] %> +Interface=<%= options[:device] %> IP=static Address=('<%= options[:ip]%>/24') From 384fd3ba9868fae34d5589437ff8f6fc29c0bae1 Mon Sep 17 00:00:00 2001 From: SilverWyrda Date: Sat, 6 Sep 2014 06:44:24 +0200 Subject: [PATCH 005/615] Delegate cleaning to arch box packagers --- plugins/guests/arch/cap/configure_networks.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/plugins/guests/arch/cap/configure_networks.rb b/plugins/guests/arch/cap/configure_networks.rb index b45d0b6d9..3d69fee7c 100644 --- a/plugins/guests/arch/cap/configure_networks.rb +++ b/plugins/guests/arch/cap/configure_networks.rb @@ -16,14 +16,6 @@ module VagrantPlugins interfaces = result.split("\n") end - # Cleaning of some dirty hacks documented here : - # (http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/) - machine.communicate.sudo("rm -f - /etc/udev/rules.d/*-net-name-slot.rules") - machine.communicate.sudo("rm -f - /etc/udev/rules.d/*-persistent-net.rules") - machine.communicate.sudo("udevadm control --reload") - networks.each do |network| # We use :device in the template instead of # eth#{network[:interface]} in order to support Predictable From fd25cbefe175cbe15034f8ed2d7ecd12bf176fa3 Mon Sep 17 00:00:00 2001 From: Gurpartap Singh Date: Sun, 7 Sep 2014 02:05:41 +0530 Subject: [PATCH 006/615] change_host_name cap for TinyCore Linux --- plugins/guests/tinycore/cap/change_host_name.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 plugins/guests/tinycore/cap/change_host_name.rb diff --git a/plugins/guests/tinycore/cap/change_host_name.rb b/plugins/guests/tinycore/cap/change_host_name.rb new file mode 100644 index 000000000..2c16af362 --- /dev/null +++ b/plugins/guests/tinycore/cap/change_host_name.rb @@ -0,0 +1,14 @@ +module VagrantPlugins + module GuestTinyCore + module Cap + class ChangeHostName + def self.change_host_name(machine, name) + if !machine.communicate.test("hostname | grep '^#{name}$'") + machine.communicate.sudo("sh -c 'echo \"#{name}\" > /etc/hostname'") + machine.communicate.sudo("/usr/bin/sethostname #{name}") + end + end + end + end + end +end From fe16352267833a59069cde5bfa6b13c67086d8c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=81nis=20=C4=80bele?= Date: Sun, 7 Sep 2014 20:03:17 +0300 Subject: [PATCH 007/615] Fix state.highstate run when using salt master retcode-passthrough option is available only for masterless salt-call. --- plugins/provisioners/salt/provisioner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/provisioners/salt/provisioner.rb b/plugins/provisioners/salt/provisioner.rb index 6225fd339..c5f5a518e 100644 --- a/plugins/provisioners/salt/provisioner.rb +++ b/plugins/provisioners/salt/provisioner.rb @@ -302,7 +302,7 @@ module VagrantPlugins @machine.env.ui.info "Calling state.highstate... (this may take a while)" if @config.install_master @machine.communicate.sudo("salt '*' saltutil.sync_all") - @machine.communicate.sudo("salt '*' state.highstate --retcode-passthrough --verbose#{get_loglevel}#{get_colorize}#{get_pillar}") do |type, data| + @machine.communicate.sudo("salt '*' state.highstate --verbose#{get_loglevel}#{get_colorize}#{get_pillar}") do |type, data| if @config.verbose @machine.env.ui.info(data) end From 6fa0fe09ab997198a234a845efcc518638d47e2f Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 11 Sep 2014 10:47:13 +0200 Subject: [PATCH 008/615] Renamed host capabilities from opensuse to suse --- plugins/hosts/{opensuse => suse}/cap/nfs.rb | 0 plugins/hosts/{opensuse => suse}/host.rb | 0 plugins/hosts/{opensuse => suse}/plugin.rb | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename plugins/hosts/{opensuse => suse}/cap/nfs.rb (100%) rename plugins/hosts/{opensuse => suse}/host.rb (100%) rename plugins/hosts/{opensuse => suse}/plugin.rb (100%) diff --git a/plugins/hosts/opensuse/cap/nfs.rb b/plugins/hosts/suse/cap/nfs.rb similarity index 100% rename from plugins/hosts/opensuse/cap/nfs.rb rename to plugins/hosts/suse/cap/nfs.rb diff --git a/plugins/hosts/opensuse/host.rb b/plugins/hosts/suse/host.rb similarity index 100% rename from plugins/hosts/opensuse/host.rb rename to plugins/hosts/suse/host.rb diff --git a/plugins/hosts/opensuse/plugin.rb b/plugins/hosts/suse/plugin.rb similarity index 100% rename from plugins/hosts/opensuse/plugin.rb rename to plugins/hosts/suse/plugin.rb From f1b62ae03a6ba9c309627fcde894ed8164d6e900 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 11 Sep 2014 10:48:58 +0200 Subject: [PATCH 009/615] Fixed class naming and detection for suse hosts --- plugins/hosts/suse/cap/nfs.rb | 2 +- plugins/hosts/suse/host.rb | 18 +++++++++++++----- plugins/hosts/suse/plugin.rb | 14 ++++++-------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/plugins/hosts/suse/cap/nfs.rb b/plugins/hosts/suse/cap/nfs.rb index d16bc9327..6bb17b172 100644 --- a/plugins/hosts/suse/cap/nfs.rb +++ b/plugins/hosts/suse/cap/nfs.rb @@ -1,5 +1,5 @@ module VagrantPlugins - module HostOpenSUSE + module HostSUSE module Cap class NFS def self.nfs_check_command(env) diff --git a/plugins/hosts/suse/host.rb b/plugins/hosts/suse/host.rb index 5e0240d27..2cc5c24c7 100644 --- a/plugins/hosts/suse/host.rb +++ b/plugins/hosts/suse/host.rb @@ -3,14 +3,22 @@ require "pathname" require "vagrant" module VagrantPlugins - module HostOpenSUSE + module HostSUSE class Host < Vagrant.plugin("2", :host) def detect?(env) - release_file = Pathname.new("/etc/SuSE-release") + old_release_file = Pathname.new("/etc/SuSE-release") - if release_file.exist? - release_file.open("r") do |f| - return true if f.gets =~ /^openSUSE/ + if old_release_file.exist? + old_release_file.open("r") do |f| + return true if f.gets =~ /^(openSUSE|SUSE Linux Enterprise)/ + end + end + + new_release_file = Pathname.new("/etc/os-release") + + if new_release_file.exist? + new_release_file.open("r") do |f| + return true if f.gets =~ /(openSUSE|SLES)/ end end diff --git a/plugins/hosts/suse/plugin.rb b/plugins/hosts/suse/plugin.rb index 6ed81f8da..a2d692536 100644 --- a/plugins/hosts/suse/plugin.rb +++ b/plugins/hosts/suse/plugin.rb @@ -1,24 +1,22 @@ require "vagrant" module VagrantPlugins - module HostOpenSUSE + module HostSUSE class Plugin < Vagrant.plugin("2") - name "OpenSUSE host" - description "OpenSUSE host support." + name "SUSE host" + description "SUSE host support." - host("opensuse", "linux") do + host("suse", "linux") do require_relative "host" Host end - # Linux-specific helpers we need to determine paths that can - # be overriden. - host_capability("opensuse", "nfs_check_command") do + host_capability("suse", "nfs_check_command") do require_relative "cap/nfs" Cap::NFS end - host_capability("opensuse", "nfs_start_command") do + host_capability("suse", "nfs_start_command") do require_relative "cap/nfs" Cap::NFS end From 31b6d69127f7eb1a6ccdc5cc475f6547480f3cf0 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 11 Sep 2014 10:51:34 +0200 Subject: [PATCH 010/615] Fixed suse naming for fcengine cap and refined install command --- plugins/provisioners/cfengine/cap/suse/cfengine_install.rb | 7 ++++--- plugins/provisioners/cfengine/plugin.rb | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/provisioners/cfengine/cap/suse/cfengine_install.rb b/plugins/provisioners/cfengine/cap/suse/cfengine_install.rb index 278fe49a8..fd5ef1b30 100644 --- a/plugins/provisioners/cfengine/cap/suse/cfengine_install.rb +++ b/plugins/provisioners/cfengine/cap/suse/cfengine_install.rb @@ -1,12 +1,13 @@ module VagrantPlugins module CFEngine module Cap - module SuSE + module SUSE module CFEngineInstall def self.cfengine_install(machine, config) machine.communicate.tap do |comm| - comm.sudo("GPGFILE=$(mktemp) && wget -O $GPGFILE #{config.repo_gpg_key_url} && rpm --import $GPGFILE; rm -f $GPGFILE") - comm.sudo("zypper addrepo -t YUM #{config.yum_repo_url} cfengine-repository") + comm.sudo("rpm --import #{config.repo_gpg_key_url}") + + comm.sudo("zypper addrepo -t YUM #{config.yum_repo_url} CFEngine") comm.sudo("zypper se #{config.package_name} && zypper -n install #{config.package_name}") end end diff --git a/plugins/provisioners/cfengine/plugin.rb b/plugins/provisioners/cfengine/plugin.rb index 4e1a7f093..ee5d75768 100644 --- a/plugins/provisioners/cfengine/plugin.rb +++ b/plugins/provisioners/cfengine/plugin.rb @@ -35,7 +35,7 @@ module VagrantPlugins guest_capability("suse", "cfengine_install") do require_relative "cap/suse/cfengine_install" - Cap::SuSE::CFEngineInstall + Cap::SUSE::CFEngineInstall end provisioner(:cfengine) do From 6c20b6cd34eaa7602994b20b6264b8727e33b95f Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 11 Sep 2014 10:52:15 +0200 Subject: [PATCH 011/615] Fixed suse spelling in fedora capability --- plugins/guests/fedora/cap/network_scripts_dir.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/guests/fedora/cap/network_scripts_dir.rb b/plugins/guests/fedora/cap/network_scripts_dir.rb index 3ce0e43c3..82a4abad7 100644 --- a/plugins/guests/fedora/cap/network_scripts_dir.rb +++ b/plugins/guests/fedora/cap/network_scripts_dir.rb @@ -4,7 +4,7 @@ module VagrantPlugins class NetworkScriptsDir # The path to the directory with the network configuration scripts. # This is pulled out into its own directory since there are other - # operating systems (SuSE) which behave similarly but with a different + # operating systems (SUSE) which behave similarly but with a different # path to the network scripts. def self.network_scripts_dir(machine) "/etc/sysconfig/network-scripts" From 063a903bdb2cde1a28da6f35e3db3be118807fdf Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 11 Sep 2014 10:52:58 +0200 Subject: [PATCH 012/615] Fixed and extended suse guest capabilities In order to get a SUSE guest running and installing fine i have added a correct capability for installing rsync and nfs-client. I have included SUSE naming fixes as well because SUSe doesnt get spelled SuSE anymore :). --- plugins/guests/suse/cap/change_host_name.rb | 5 ++-- plugins/guests/suse/cap/configure_networks.rb | 2 +- plugins/guests/suse/cap/halt.rb | 2 +- .../guests/suse/cap/network_scripts_dir.rb | 4 +-- plugins/guests/suse/cap/nfs_client.rb | 16 ++++++++++ plugins/guests/suse/cap/rsync.rb | 17 +++++++++++ plugins/guests/suse/guest.rb | 4 +-- plugins/guests/suse/plugin.rb | 29 ++++++++++++++----- 8 files changed, 64 insertions(+), 15 deletions(-) create mode 100644 plugins/guests/suse/cap/nfs_client.rb create mode 100644 plugins/guests/suse/cap/rsync.rb diff --git a/plugins/guests/suse/cap/change_host_name.rb b/plugins/guests/suse/cap/change_host_name.rb index a8ba242d7..e4b9cee56 100644 --- a/plugins/guests/suse/cap/change_host_name.rb +++ b/plugins/guests/suse/cap/change_host_name.rb @@ -1,13 +1,14 @@ module VagrantPlugins - module GuestSuse + module GuestSUSE module Cap class ChangeHostName def self.change_host_name(machine, name) machine.communicate.tap do |comm| # Only do this if the hostname is not already set - if !comm.test("sudo hostname | grep '#{name}'") + unless comm.test("sudo hostname | grep '#{name}'") comm.sudo("echo #{name} > /etc/HOSTNAME") comm.sudo("hostname #{name}") + comm.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts") end end diff --git a/plugins/guests/suse/cap/configure_networks.rb b/plugins/guests/suse/cap/configure_networks.rb index d60bb8306..00902dbd0 100644 --- a/plugins/guests/suse/cap/configure_networks.rb +++ b/plugins/guests/suse/cap/configure_networks.rb @@ -5,7 +5,7 @@ require "vagrant/util/retryable" require "vagrant/util/template_renderer" module VagrantPlugins - module GuestSuse + module GuestSUSE module Cap class ConfigureNetworks extend Vagrant::Util::Retryable diff --git a/plugins/guests/suse/cap/halt.rb b/plugins/guests/suse/cap/halt.rb index ea1957594..e6b20818b 100644 --- a/plugins/guests/suse/cap/halt.rb +++ b/plugins/guests/suse/cap/halt.rb @@ -1,5 +1,5 @@ module VagrantPlugins - module GuestSuse + module GuestSUSE module Cap class Halt def self.halt(machine) diff --git a/plugins/guests/suse/cap/network_scripts_dir.rb b/plugins/guests/suse/cap/network_scripts_dir.rb index d8c34b290..82b2e7f4a 100644 --- a/plugins/guests/suse/cap/network_scripts_dir.rb +++ b/plugins/guests/suse/cap/network_scripts_dir.rb @@ -1,9 +1,9 @@ module VagrantPlugins - module GuestSuse + module GuestSUSE module Cap class NetworkScriptsDir def self.network_scripts_dir(machine) - "/etc/sysconfig/network/" + "/etc/sysconfig/network" end end end diff --git a/plugins/guests/suse/cap/nfs_client.rb b/plugins/guests/suse/cap/nfs_client.rb new file mode 100644 index 000000000..36a92d201 --- /dev/null +++ b/plugins/guests/suse/cap/nfs_client.rb @@ -0,0 +1,16 @@ +module VagrantPlugins + module GuestSUSE + module Cap + class NFSClient + def self.nfs_client_install(machine) + machine.communicate.tap do |comm| + comm.sudo("zypper -n install nfs-client") + + comm.sudo("/sbin/service rpcbind restart") + comm.sudo("/sbin/service nfs restart") + end + end + end + end + end +end diff --git a/plugins/guests/suse/cap/rsync.rb b/plugins/guests/suse/cap/rsync.rb new file mode 100644 index 000000000..aed989613 --- /dev/null +++ b/plugins/guests/suse/cap/rsync.rb @@ -0,0 +1,17 @@ +module VagrantPlugins + module GuestSUSE + module Cap + class RSync + def self.rsync_installed(machine) + machine.communicate.test("test -f /usr/bin/rsync") + end + + def self.rsync_install(machine) + machine.communicate.tap do |comm| + comm.sudo("zypper -n install rsync") + end + end + end + end + end +end diff --git a/plugins/guests/suse/guest.rb b/plugins/guests/suse/guest.rb index 340f5818d..643403f19 100644 --- a/plugins/guests/suse/guest.rb +++ b/plugins/guests/suse/guest.rb @@ -1,10 +1,10 @@ require "vagrant" module VagrantPlugins - module GuestSuse + module GuestSUSE class Guest < Vagrant.plugin("2", :guest) def detect?(machine) - machine.communicate.test("cat /etc/SuSE-release") + machine.communicate.test("test -f /etc/SuSE-release || grep -q SUSE /etc/os-release") end end end diff --git a/plugins/guests/suse/plugin.rb b/plugins/guests/suse/plugin.rb index 0aa9bd289..3850ae45c 100644 --- a/plugins/guests/suse/plugin.rb +++ b/plugins/guests/suse/plugin.rb @@ -1,12 +1,12 @@ require "vagrant" module VagrantPlugins - module GuestSuse + module GuestSUSE class Plugin < Vagrant.plugin("2") name "SUSE guest" description "SUSE guest support." - guest("suse", "redhat") do + guest("suse", "linux") do require File.expand_path("../guest", __FILE__) Guest end @@ -16,20 +16,35 @@ module VagrantPlugins Cap::ChangeHostName end - guest_capability("suse", "halt") do - require_relative "cap/halt" - Cap::Halt - end - guest_capability("suse", "configure_networks") do require_relative "cap/configure_networks" Cap::ConfigureNetworks end + guest_capability("suse", "halt") do + require_relative "cap/halt" + Cap::Halt + end + guest_capability("suse", "network_scripts_dir") do require_relative "cap/network_scripts_dir" Cap::NetworkScriptsDir end + + guest_capability("suse", "nfs_client_install") do + require_relative "cap/nfs_client" + Cap::NFSClient + end + + guest_capability("suse", "rsync_install") do + require_relative "cap/rsync" + Cap::RSync + end + + guest_capability("suse", "rsync_installed") do + require_relative "cap/rsync" + Cap::RSync + end end end end From 2d4454dcb486e76225e56cbe0b33aa2659b464c2 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 11 Sep 2014 17:44:28 +0200 Subject: [PATCH 013/615] Added a nonsudo command for nfsd check --- plugins/hosts/suse/cap/nfs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hosts/suse/cap/nfs.rb b/plugins/hosts/suse/cap/nfs.rb index 6bb17b172..facaa68ae 100644 --- a/plugins/hosts/suse/cap/nfs.rb +++ b/plugins/hosts/suse/cap/nfs.rb @@ -3,7 +3,7 @@ module VagrantPlugins module Cap class NFS def self.nfs_check_command(env) - "/sbin/service nfsserver status" + "pidof nfsd > /dev/null" end def self.nfs_start_command(env) From a712f70634fa19fbabdb0b2061d77f5b15c9f6ff Mon Sep 17 00:00:00 2001 From: sprin Date: Fri, 12 Sep 2014 15:08:56 -0700 Subject: [PATCH 014/615] Fix NFSClient plugin for Redhat / Centos 7 guests Fixes #4476. --- plugins/guests/redhat/cap/nfs_client.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/guests/redhat/cap/nfs_client.rb b/plugins/guests/redhat/cap/nfs_client.rb index 98858f70f..0e8023062 100644 --- a/plugins/guests/redhat/cap/nfs_client.rb +++ b/plugins/guests/redhat/cap/nfs_client.rb @@ -5,7 +5,12 @@ module VagrantPlugins def self.nfs_client_install(machine) machine.communicate.tap do |comm| comm.sudo("yum -y install nfs-utils nfs-utils-lib") - comm.sudo("/etc/init.d/rpcbind restart; /etc/init.d/nfs restart") + case machine.guest.capability("flavor") + when :rhel_7 + comm.sudo("/bin/systemctl restart rpcbind nfs") + else + comm.sudo("/etc/init.d/rpcbind restart; /etc/init.d/nfs restart") + end end end end From 57afab9d25fee691e0be6029cb9193c2546dda2e Mon Sep 17 00:00:00 2001 From: Jack Pearkes Date: Mon, 15 Sep 2014 11:53:18 -0400 Subject: [PATCH 015/615] website: add info for vmware --- website/www/source/vmware/index.html.erb | 3 + website/www/source/vmware/reseller.html.md | 67 ++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 website/www/source/vmware/reseller.html.md diff --git a/website/www/source/vmware/index.html.erb b/website/www/source/vmware/index.html.erb index 3ee061ab8..d401aeb03 100644 --- a/website/www/source/vmware/index.html.erb +++ b/website/www/source/vmware/index.html.erb @@ -176,6 +176,9 @@ page_title: "VMware Vagrant Environments" The provider license does not include a license to the VMware software, which must be purchased separately. If you're buying over 100 licenses, contact biz@hashicorp.com for volume pricing. +
+ For reseller information, click here. +
diff --git a/website/www/source/vmware/reseller.html.md b/website/www/source/vmware/reseller.html.md new file mode 100644 index 000000000..073fa36cf --- /dev/null +++ b/website/www/source/vmware/reseller.html.md @@ -0,0 +1,67 @@ +--- +layout: "inner" +--- + +# Reseller Information + +We are very happy to work with resllers for the Vagrant VMware provider. + +This page is intended to answer questions commonly +needed by resellers. If you are a reseller, +all the information required should be here. + +## Volume Pricing + +We do not offer reseller discounts. However, we do offer volume pricing +when purchasing more than 100 licenses. In that case, please email +biz@hashicorp.com to learn more. + +## Quote + +One time $79 purchase fee per seat. + +## Workstation vs. Fusion + +The VMware Workstation and Fusion licenses are separate. They are both +priced the same. + +## Purchase Orders + +Althought we prefer the self-serve purchase, you may email us a complete +PO (with credit card information included) to support@hashicorp.com. We +will then process your order. + +## Seats + +A single seat can be used on two computers (such as a desktop and a laptop) +for a single person. The license is valid forever with access to free +maintenance updates. + +## Upgrades + +Future major updates may require an upgrade fee. + +## Licenses + +After purchase, license files are generated and emailed to you. + +## Software EULA/Terms + +You can download a copy of the EULA [here](https://s3.amazonaws.com/hc-public/sales/EULA_standalone.docx). + +## Company Details + +Business name: + + HashiCorp, Inc. + +Business website and support: + + hashicorp.com + support@hashicorp.com + +Our current registered business address is: + + 3120 23rd St + San Francisco, CA + 94110 USA From 4a56c39c72f3490afbb84e52b21c741a2c52b8b0 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Mon, 15 Sep 2014 14:00:16 -0300 Subject: [PATCH 016/615] website: Fix a minor typo on reseller page --- website/www/source/vmware/reseller.html.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/www/source/vmware/reseller.html.md b/website/www/source/vmware/reseller.html.md index 073fa36cf..0a2b3e194 100644 --- a/website/www/source/vmware/reseller.html.md +++ b/website/www/source/vmware/reseller.html.md @@ -4,7 +4,7 @@ layout: "inner" # Reseller Information -We are very happy to work with resllers for the Vagrant VMware provider. +We are very happy to work with resellers for the Vagrant VMware provider. This page is intended to answer questions commonly needed by resellers. If you are a reseller, From b5d22f490aeddcdc920abbd7852598c55d641e47 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 16 Sep 2014 17:45:31 +0200 Subject: [PATCH 017/615] fix "forwared" typo --- website/docs/source/v2/networking/forwarded_ports.html.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/source/v2/networking/forwarded_ports.html.md b/website/docs/source/v2/networking/forwarded_ports.html.md index 9c94bd530..f8ab3d2e8 100644 --- a/website/docs/source/v2/networking/forwarded_ports.html.md +++ b/website/docs/source/v2/networking/forwarded_ports.html.md @@ -50,7 +50,7 @@ there are more detailed examples of using these options. this is empty. * `protocol` (string) - Either "udp" or "tcp". This specifies the protocol - that will be allowed through the forwared port. By default this is "tcp". + that will be allowed through the forwarded port. By default this is "tcp". ## Forwarded Port Protocols From 6747f1295197de9627ccaee69e40b459d5937eac Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 16 Sep 2014 11:24:35 -0700 Subject: [PATCH 018/615] website/docs: clarify that add_recipe order matters --- website/docs/source/v2/provisioning/chef_solo.html.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/website/docs/source/v2/provisioning/chef_solo.html.md b/website/docs/source/v2/provisioning/chef_solo.html.md index f20cf33bd..cb8e34ac8 100644 --- a/website/docs/source/v2/provisioning/chef_solo.html.md +++ b/website/docs/source/v2/provisioning/chef_solo.html.md @@ -89,6 +89,9 @@ $ tree |   |-- default.rb ``` +The order of the calls to `add_recipe` will specify the order of the run list. +Earlier recipes added with `add_recipe` are run before later recipes added. + ## Custom Cookbooks Path Instead of using the default "cookbooks" directory, a custom cookbooks From c755bf2aaef564b291c5defd1843a3b9e5efd3f3 Mon Sep 17 00:00:00 2001 From: Chris Kuehl Date: Tue, 16 Sep 2014 18:32:11 -0700 Subject: [PATCH 019/615] Fix typo in HTTP sharing docs --- website/docs/source/v2/share/http.html.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/source/v2/share/http.html.md b/website/docs/source/v2/share/http.html.md index 8c8a88830..0e99b5127 100644 --- a/website/docs/source/v2/share/http.html.md +++ b/website/docs/source/v2/share/http.html.md @@ -12,7 +12,7 @@ sharing," and is enabled by default when `vagrant share` is used. Because this mode of sharing creates a publicly accessible URL, the accessing party does not need to have Vagrant installed in order to view your environment. -This has a number of useful use cases: you can test webooks by exposing +This has a number of useful use cases: you can test webhooks by exposing your Vagrant environment to the internet, you can show your work to clients, teammates, or managers, etc. From d4b30dd12aa810d497c94ff26644288fed385402 Mon Sep 17 00:00:00 2001 From: Matthias Breddin Date: Thu, 18 Sep 2014 17:14:13 +0200 Subject: [PATCH 020/615] Allow nfs --- plugins/guests/freebsd/cap/mount_nfs_folder.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/guests/freebsd/cap/mount_nfs_folder.rb b/plugins/guests/freebsd/cap/mount_nfs_folder.rb index c36f928ca..0741c954b 100644 --- a/plugins/guests/freebsd/cap/mount_nfs_folder.rb +++ b/plugins/guests/freebsd/cap/mount_nfs_folder.rb @@ -4,8 +4,10 @@ module VagrantPlugins class MountNFSFolder def self.mount_nfs_folder(machine, ip, folders) folders.each do |name, opts| - machine.communicate.sudo("mkdir -p #{opts[:guestpath]}", {shell: "sh"}) - machine.communicate.sudo("mount -t nfs '#{ip}:#{opts[:hostpath]}' '#{opts[:guestpath]}'", {shell: "sh"}) + if opts[:nfs_version] + nfs_version_mount_option="-o nfsv#{opts[:nfs_version]}" + end + machine.communicate.sudo("mount -t nfs #{nfs_version_mount_option} '#{ip}:#{opts[:hostpath]}' '#{opts[:guestpath]}'", {shell: "sh"}) end end end From 96b011b39ec2e96f8756f40c43874eb4b6e29fd9 Mon Sep 17 00:00:00 2001 From: Felix Gilcher Date: Sat, 20 Sep 2014 17:34:01 +0200 Subject: [PATCH 021/615] update /etc/hosts on rhel 7 the previous fix for #4465 assumed that the NetworkManager takes care of updating /etc/hosts with the new hostname, but testing shows it doesn't. This change ensures that the change is always added to /etc/hosts when the name changes. --- plugins/guests/redhat/cap/change_host_name.rb | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/plugins/guests/redhat/cap/change_host_name.rb b/plugins/guests/redhat/cap/change_host_name.rb index 72ad47e8d..2520904ec 100644 --- a/plugins/guests/redhat/cap/change_host_name.rb +++ b/plugins/guests/redhat/cap/change_host_name.rb @@ -3,16 +3,7 @@ module VagrantPlugins module Cap class ChangeHostName def self.change_host_name(machine, name) - case machine.guest.capability("flavor") - when :rhel_7 - change_host_name_rhel7(machine, name) - else - new(machine, name).change! - end - end - - def self.change_host_name_rhel7(machine, name) - machine.communicate.sudo("hostnamectl set-hostname #{name}") + new(machine, name).change! end attr_reader :machine, :new_hostname @@ -25,11 +16,17 @@ module VagrantPlugins def change! return unless should_change? - update_sysconfig - update_hostname - update_etc_hosts - update_dhcp_hostnames - restart_networking + case machine.guest.capability("flavor") + when :rhel_7 + update_hostname_rhel7 + update_etc_hosts + else + update_sysconfig + update_hostname + update_etc_hosts + update_dhcp_hostnames + restart_networking + end end def should_change? @@ -61,6 +58,10 @@ module VagrantPlugins sudo "hostname #{fqdn}" end + def update_hostname_rhel7 + sudo "hostnamectl set-hostname #{fqdn}" + end + # /etc/hosts should resemble: # 127.0.0.1 host.fqdn.com host localhost ... def update_etc_hosts From 9b937db6c9fa65ec1b642746ba1bfe17ae537c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20G=C3=BCnther?= Date: Sun, 21 Sep 2014 15:11:00 +0200 Subject: [PATCH 022/615] hosts/windows: Don't mount all drives into the RDP session This setting mounts all available drives (C:\ and mapped network drives) into the RDP session. This shouldn't be the default. --- plugins/hosts/windows/cap/rdp.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/hosts/windows/cap/rdp.rb b/plugins/hosts/windows/cap/rdp.rb index 9976834de..8ddc67117 100644 --- a/plugins/hosts/windows/cap/rdp.rb +++ b/plugins/hosts/windows/cap/rdp.rb @@ -10,7 +10,6 @@ module VagrantPlugins def self.rdp_client(env, rdp_info) config = nil opts = { - "drivestoredirect:s" => "*", "full address:s" => "#{rdp_info[:host]}:#{rdp_info[:port]}", "prompt for credentials:i" => "1", "username:s" => rdp_info[:username], From 286e9cd01ee6422e9631ac9a3293d6a3a561e658 Mon Sep 17 00:00:00 2001 From: Johannes Plunien Date: Sun, 21 Sep 2014 19:14:57 +0200 Subject: [PATCH 023/615] Set ComputerName and LocalHostName on darwin guests This sets the bonjour host name for darwin guests to the same value as config.vm.hostname. It also sets the user-friendly name for the system. --- plugins/guests/darwin/cap/change_host_name.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/guests/darwin/cap/change_host_name.rb b/plugins/guests/darwin/cap/change_host_name.rb index 80df9870d..ad7242c91 100644 --- a/plugins/guests/darwin/cap/change_host_name.rb +++ b/plugins/guests/darwin/cap/change_host_name.rb @@ -4,7 +4,9 @@ module VagrantPlugins class ChangeHostName def self.change_host_name(machine, name) if !machine.communicate.test("hostname -f | grep '^#{name}$' || hostname -s | grep '^#{name}$'") + machine.communicate.sudo("scutil --set ComputerName #{name}") machine.communicate.sudo("scutil --set HostName #{name}") + machine.communicate.sudo("scutil --set LocalHostName #{name}") machine.communicate.sudo("hostname #{name}") end end From b22259107b87ff5f3c313dfaac875badf559404a Mon Sep 17 00:00:00 2001 From: Mark Whelan Date: Tue, 23 Sep 2014 14:38:26 -0400 Subject: [PATCH 024/615] fix typos --- website/docs/source/v2/provisioning/ansible.html.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/source/v2/provisioning/ansible.html.md b/website/docs/source/v2/provisioning/ansible.html.md index 296185ef8..a39315bba 100644 --- a/website/docs/source/v2/provisioning/ansible.html.md +++ b/website/docs/source/v2/provisioning/ansible.html.md @@ -32,7 +32,7 @@ this by way of an [inventory](http://docs.ansible.com/intro_inventory.html) file there are two ways to approach working with inventory files. The first and simplest option is to not provide one to Vagrant at all. Vagrant will generate an -inventory file encompassing all of the virtual machine it manages, and use it for provisioning +inventory file encompassing all of the virtual machines it manages, and use it for provisioning machines. The generated inventory file is stored as part of your local Vagrant environment in `.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory`. The `ansible.groups` option can be used to pass a hash of group @@ -232,7 +232,7 @@ Note that it is also possible to reference an Ansible configuration file via `AN ### Why does the Ansible provisioner connect as the wrong user? -It is good to know that following Ansible settings always override the `config.ssh.username` option defined in [Vagrant SSH Settings](/v2/vagrantfile/ssh_settings.html): +It is good to know that the following Ansible settings always override the `config.ssh.username` option defined in [Vagrant SSH Settings](/v2/vagrantfile/ssh_settings.html): * `ansible_ssh_user` variable * `remote_user` (or `user`) play attribute From 7a73f5bd7cac1ffec748936905e7caddc4c372b1 Mon Sep 17 00:00:00 2001 From: Eris Belew Date: Tue, 23 Sep 2014 12:46:25 -0700 Subject: [PATCH 025/615] Update shell provisioner for powershell to add "shell_args", saner defaults and more useful detail in logging output; Add Eclipse .project file to .gitignore IDE section --- .gitignore | 1 + plugins/provisioners/shell/config.rb | 3 +++ plugins/provisioners/shell/provisioner.rb | 16 ++++++++++++---- templates/locales/en.yml | 1 + 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 225e014d6..47b95a67e 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ doc/ # IDE junk .idea/* *.iml +.project # Ruby Managers .rbenv diff --git a/plugins/provisioners/shell/config.rb b/plugins/provisioners/shell/config.rb index fbb7c812e..f69f8b731 100644 --- a/plugins/provisioners/shell/config.rb +++ b/plugins/provisioners/shell/config.rb @@ -10,6 +10,7 @@ module VagrantPlugins attr_accessor :privileged attr_accessor :binary attr_accessor :keep_color + attr_accessor :shell_args def initialize @args = UNSET_VALUE @@ -19,6 +20,7 @@ module VagrantPlugins @privileged = UNSET_VALUE @binary = UNSET_VALUE @keep_color = UNSET_VALUE + @shell_args = UNSET_VALUE end def finalize! @@ -29,6 +31,7 @@ module VagrantPlugins @privileged = true if @privileged == UNSET_VALUE @binary = false if @binary == UNSET_VALUE @keep_color = false if @keep_color == UNSET_VALUE + @shell_args = "-ExecutionPolicy Bypass" if @shell_args == UNSET_VALUE if @args && args_valid? @args = @args.is_a?(Array) ? @args.map { |a| a.to_s } : @args.to_s diff --git a/plugins/provisioners/shell/provisioner.rb b/plugins/provisioners/shell/provisioner.rb index 674c9c5fb..5aa19c401 100644 --- a/plugins/provisioners/shell/provisioner.rb +++ b/plugins/provisioners/shell/provisioner.rb @@ -100,14 +100,22 @@ module VagrantPlugins exec_path.gsub!('/', '\\') exec_path = "c:#{exec_path}" if exec_path.start_with?("\\") - # For PowerShell scripts bypass the execution policy + # Copy shell_args from configuration + shell_args = config.shell_args + + # For PowerShell scripts bypass the execution policy unless already specified + shell_args += " -ExecutionPolicy Bypass" if config.shell_args !~ /[-\/]ExecutionPolicy/i + + # CLIXML output is kinda useless, especially on non-windows hosts + shell_args += " -OutputFormat Text" if config.shell_args !~ /[-\/]OutputFormat/i + command = "#{exec_path}#{args}" - command = "powershell -executionpolicy bypass -file #{command}" if + command = "powershell #{shell_args.to_s} -file #{command}" if File.extname(exec_path).downcase == '.ps1' if config.path - @machine.ui.detail(I18n.t("vagrant.provisioners.shell.running", - script: exec_path)) + @machine.ui.detail(I18n.t("vagrant.provisioners.shell.runningas", + local: config.path.to_s, remote: exec_path)) else @machine.ui.detail(I18n.t("vagrant.provisioners.shell.running", script: "inline PowerShell script")) diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 4be7a92e7..a2055ae6f 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1773,6 +1773,7 @@ en: path_and_inline_set: "Only one of `path` or `inline` may be set." path_invalid: "`path` for shell provisioner does not exist on the host system: %{path}" running: "Running: %{script}" + runningas: "Running: %{local} as %{remote}" upload_path_not_set: "`upload_path` must be set for the shell provisioner." ansible: From 09738e082aa680e4ea14e85e818af3fc6211bacf Mon Sep 17 00:00:00 2001 From: Jack Pearkes Date: Wed, 24 Sep 2014 09:31:54 -0400 Subject: [PATCH 026/615] website: remove unneeded colon in docs --- website/docs/source/v2/getting-started/share.html.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/source/v2/getting-started/share.html.md b/website/docs/source/v2/getting-started/share.html.md index 5c39d5de7..96c6ffe6a 100644 --- a/website/docs/source/v2/getting-started/share.html.md +++ b/website/docs/source/v2/getting-started/share.html.md @@ -23,7 +23,7 @@ Before being able to share your Vagrant environment, you'll need an account on Once you have an account, log in using `vagrant login`: ``` -$ vagrant login: +$ vagrant login Username or Email: mitchellh Password (will be hidden): You're now logged in! From 779e54eef504113f82fe4e7912ddc7e63c08fd56 Mon Sep 17 00:00:00 2001 From: "Dr. Zarkov" Date: Fri, 26 Sep 2014 14:05:54 +0200 Subject: [PATCH 027/615] A more reliable way to detect Ubuntu The default /etc/issue might have been changed by the administrator and not contain the string 'Ubuntu' anymore. --- plugins/guests/ubuntu/guest.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/guests/ubuntu/guest.rb b/plugins/guests/ubuntu/guest.rb index 9e9a9a9ad..9295ede22 100644 --- a/plugins/guests/ubuntu/guest.rb +++ b/plugins/guests/ubuntu/guest.rb @@ -4,7 +4,7 @@ module VagrantPlugins module GuestUbuntu class Guest < Vagrant.plugin("2", :guest) def detect?(machine) - machine.communicate.test("cat /etc/issue | grep 'Ubuntu'") + machine.communicate.test("[ -x /usr/bin/lsb_release ] && /usr/bin/lsb_release -i 2>/dev/null | grep Ubuntu") end end end From bddca42bcbb1f5dd39ff184fd8e5ef417009513b Mon Sep 17 00:00:00 2001 From: Jack Pearkes Date: Fri, 26 Sep 2014 10:50:29 -0400 Subject: [PATCH 028/615] docs: fix typo --- website/docs/source/v2/boxes/base.html.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/source/v2/boxes/base.html.md b/website/docs/source/v2/boxes/base.html.md index 282efd4fc..2ea27c6cf 100644 --- a/website/docs/source/v2/boxes/base.html.md +++ b/website/docs/source/v2/boxes/base.html.md @@ -93,7 +93,7 @@ can be easily added via the Vagrantfile in most cases. Just about every aspect of Vagrant can be modified. However, Vagrant does expect some defaults which will cause your base box to "just work" out -of the box. You should create these as defaults if you intent to publicly +of the box. You should create these as defaults if you intend to publicly distribute your box. If you're creating a base box for private use, you should try _not_ to From 97341c3234bccc29893715147d041cc387201251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Pervill=C3=A9?= Date: Mon, 29 Sep 2014 18:46:01 +0200 Subject: [PATCH 029/615] providers/docker: allow multiple links to same backend (different aliases). --- plugins/providers/docker/action/create.rb | 4 ++-- test/unit/plugins/providers/docker/driver_test.rb | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/providers/docker/action/create.rb b/plugins/providers/docker/action/create.rb index e960f10b0..dcf92ce44 100644 --- a/plugins/providers/docker/action/create.rb +++ b/plugins/providers/docker/action/create.rb @@ -96,10 +96,10 @@ module VagrantPlugins image = @env[:create_image] image ||= @provider_config.image - links = {} + links = [] @provider_config._links.each do |link| parts = link.split(":", 2) - links[parts[0]] = parts[1] + links << parts end { diff --git a/test/unit/plugins/providers/docker/driver_test.rb b/test/unit/plugins/providers/docker/driver_test.rb index 337436a51..1f0ea3ece 100644 --- a/test/unit/plugins/providers/docker/driver_test.rb +++ b/test/unit/plugins/providers/docker/driver_test.rb @@ -17,7 +17,7 @@ describe VagrantPlugins::DockerProvider::Driver do ports: '8080:80', volumes: '/host/path:guest/path', detach: true, - links: {janis: 'joplin'}, + links: [[:janis, 'joplin'], [:janis, 'janis']], env: {key: 'value'}, name: cid, hostname: 'jimi-hendrix', @@ -43,7 +43,9 @@ describe VagrantPlugins::DockerProvider::Driver do end it 'links containers' do - expect(cmd_executed).to match(/--link #{params[:links].to_a.flatten.join(':')} .+ #{Regexp.escape params[:image]}/) + params[:links].each do |link| + expect(cmd_executed).to match(/--link #{link.join(':')} .+ #{Regexp.escape params[:image]}/) + end end it 'sets environmental variables' do From bdef7efb2dc48f0534d199b9067b00b9bec4af67 Mon Sep 17 00:00:00 2001 From: Michael Kuzmin Date: Mon, 29 Sep 2014 22:36:37 +0400 Subject: [PATCH 030/615] Fix for ignored `config.vm.box_server_url` setting. https://github.com/mitchellh/vagrant/pull/4282 introduced new setting to set alternate vagrant cloud server URLs, but it doesn't work actually. This PR helps to process the value correctly. --- lib/vagrant/action/builtin/handle_box.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/vagrant/action/builtin/handle_box.rb b/lib/vagrant/action/builtin/handle_box.rb index 0ecaece67..992ab0126 100644 --- a/lib/vagrant/action/builtin/handle_box.rb +++ b/lib/vagrant/action/builtin/handle_box.rb @@ -79,6 +79,7 @@ module Vagrant env[:action_runner].run(Vagrant::Action.action_box_add, env.merge({ box_name: machine.config.vm.box, box_url: machine.config.vm.box_url || machine.config.vm.box, + box_server_url: machine.config.vm.box_server_url, box_provider: box_formats, box_version: machine.config.vm.box_version, box_client_cert: box_download_client_cert, From 95f39d52faa3c90f161548a9152cee14d0171416 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Mon, 6 Oct 2014 16:32:00 +0200 Subject: [PATCH 031/615] Added better check if nfs server is available on SUSE hosts --- plugins/hosts/suse/cap/nfs.rb | 4 ++++ plugins/hosts/suse/plugin.rb | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/plugins/hosts/suse/cap/nfs.rb b/plugins/hosts/suse/cap/nfs.rb index facaa68ae..42bde6bb2 100644 --- a/plugins/hosts/suse/cap/nfs.rb +++ b/plugins/hosts/suse/cap/nfs.rb @@ -2,6 +2,10 @@ module VagrantPlugins module HostSUSE module Cap class NFS + def self.nfs_installed(env) + system("rpm -q nfs-kernel-server > /dev/null 2>&1") + end + def self.nfs_check_command(env) "pidof nfsd > /dev/null" end diff --git a/plugins/hosts/suse/plugin.rb b/plugins/hosts/suse/plugin.rb index a2d692536..3aa1b441f 100644 --- a/plugins/hosts/suse/plugin.rb +++ b/plugins/hosts/suse/plugin.rb @@ -11,6 +11,11 @@ module VagrantPlugins Host end + host_capability("suse", "nfs_installed") do + require_relative "cap/nfs" + Cap::NFS + end + host_capability("suse", "nfs_check_command") do require_relative "cap/nfs" Cap::NFS From 9b5665c3c15005f2bea136cf8a7c79faf01000e6 Mon Sep 17 00:00:00 2001 From: "David\\ Beitey" Date: Wed, 8 Oct 2014 16:05:46 +1000 Subject: [PATCH 032/615] Add security note for public networks --- .../source/v2/networking/public_network.html.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/website/docs/source/v2/networking/public_network.html.md b/website/docs/source/v2/networking/public_network.html.md index 81a650f53..4e482b1b7 100644 --- a/website/docs/source/v2/networking/public_network.html.md +++ b/website/docs/source/v2/networking/public_network.html.md @@ -23,6 +23,19 @@ general public access to your machine, public networks can.

+
+

+ Warning! Vagrant boxes are insecure by default + and by design, featuring public passwords, insecure keypairs + for SSH access, and potentially allow root access over SSH. With + these known credentials, your box is easily accessible by anyone on + your network. Before configuring Vagrant to use a public network, + consider all potential security implications + and review the default box + configuration to identify potential security risks. +

+
+ ## DHCP The easiest way to use a public network is to allow the IP to be assigned From fdbf3366ceaa053d88039de6b07f6db0cda7492a Mon Sep 17 00:00:00 2001 From: Anton D Date: Fri, 10 Oct 2014 23:20:50 +1300 Subject: [PATCH 033/615] Check whether Salt bootstrap script exists before attempting to delete it. GH-4614 --- plugins/provisioners/salt/provisioner.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/provisioners/salt/provisioner.rb b/plugins/provisioners/salt/provisioner.rb index 6225fd339..827ee20e7 100644 --- a/plugins/provisioners/salt/provisioner.rb +++ b/plugins/provisioners/salt/provisioner.rb @@ -236,7 +236,9 @@ module VagrantPlugins bootstrap_destination = File.join(config_dir, "bootstrap_salt.sh") end - @machine.communicate.sudo("rm -f %s" % bootstrap_destination) + if @machine.communicate.test("test -f %s" % bootstrap_destination) + @machine.communicate.sudo("rm -f %s" % bootstrap_destination) + end @machine.communicate.upload(bootstrap_path.to_s, bootstrap_destination) @machine.communicate.sudo("chmod +x %s" % bootstrap_destination) if @machine.config.vm.communicator == :winrm From ca1456ff8214f9f37b25dd960a23a77f9388f1a2 Mon Sep 17 00:00:00 2001 From: crypt1d Date: Fri, 10 Oct 2014 13:01:04 +0200 Subject: [PATCH 034/615] initial changes for forwarding port modifications --- .../builtin/handle_forwarded_port_collisions.rb | 9 +++++---- .../prepare_forwarded_port_collision_params.rb | 2 +- plugins/providers/virtualbox/driver/version_4_3.rb | 13 +++++++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb b/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb index b53ba35c2..7edb256f3 100644 --- a/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +++ b/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb @@ -92,6 +92,7 @@ module Vagrant with_forwarded_ports(env) do |options| guest_port = options[:guest] host_port = options[:host] + host_ip = options[:host_ip] if options[:protocol] && options[:protocol] != "tcp" @logger.debug("Skipping #{host_port} because UDP protocol.") @@ -105,8 +106,8 @@ module Vagrant end # If the port is open (listening for TCP connections) - in_use = extra_in_use.include?(host_port) || - port_checker[host_port] || + in_use = extra_in_use.include?([host_ip,host_port]) || + port_checker[host_ip,host_port] || lease_check(host_port) if in_use if !repair || !options[:auto_correct] @@ -205,8 +206,8 @@ module Vagrant end end - def port_check(port) - is_port_open?("127.0.0.1", port) + def port_check(host="127.0.0.1",port) + is_port_open?(host, port) end def with_forwarded_ports(env) diff --git a/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb b/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb index 7fad5ee1e..0bc1982d5 100644 --- a/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb +++ b/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb @@ -14,7 +14,7 @@ module VagrantPlugins # Build the remap for any existing collision detections remap = {} env[:port_collision_remap] = remap - env[:machine].provider.driver.read_forwarded_ports.each do |_nic, name, hostport, _guestport| + env[:machine].provider.driver.read_forwarded_ports.each do |_nic, name, hostaddr, hostport, _guestport| env[:machine].config.vm.networks.each do |type, options| next if type != :forwarded_port diff --git a/plugins/providers/virtualbox/driver/version_4_3.rb b/plugins/providers/virtualbox/driver/version_4_3.rb index cc700c0fa..230de74f0 100644 --- a/plugins/providers/virtualbox/driver/version_4_3.rb +++ b/plugins/providers/virtualbox/driver/version_4_3.rb @@ -18,7 +18,7 @@ module VagrantPlugins def clear_forwarded_ports args = [] - read_forwarded_ports(@uuid).each do |nic, name, _, _| + read_forwarded_ports(@uuid).each do |nic, name, _, _, _| args.concat(["--natpf#{nic}", "delete", name]) end @@ -261,8 +261,9 @@ module VagrantPlugins end # Parse out the forwarded port information - if line =~ /^Forwarding.+?="(.+?),.+?,.*?,(.+?),.*?,(.+?)"$/ - result = [current_nic, $1.to_s, $2.to_i, $3.to_i] + if line =~ /^Forwarding.+?="(.+?),.*?,.(.+?),(.+?),.*?,(.+?)"$/ + result = [current_nic, $1.to_s, $2.to_s, $3.to_i, $4.to_i] + #[["nat", "ssh", "127.0.0.1", 2222, 22]] @logger.debug(" - #{result.inspect}") results << result end @@ -449,8 +450,8 @@ module VagrantPlugins # Ignore our own used ports next if uuid == @uuid - read_forwarded_ports(uuid, true).each do |_, _, hostport, _| - ports << hostport + read_forwarded_ports(uuid, true).each do |_, _, hostaddr, hostport, _| + ports << [hostaddr, hostport] end end end @@ -497,7 +498,7 @@ module VagrantPlugins @logger.debug("Searching for SSH port: #{expected_port.inspect}") # Look for the forwarded port only by comparing the guest port - read_forwarded_ports.each do |_, _, hostport, guestport| + read_forwarded_ports.each do |_, _, _, hostport, guestport| return hostport if guestport == expected_port end From 8b40f2bb2d919543347b0c7e96249a417c9b96bd Mon Sep 17 00:00:00 2001 From: David Lundgren Date: Fri, 10 Oct 2014 11:02:01 -0500 Subject: [PATCH 035/615] Don't update the NFS exports file [GH-4148] Wrapped the NFS export modification process with a check for when there are not exports to be modified --- plugins/synced_folders/nfs/synced_folder.rb | 29 ++++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/plugins/synced_folders/nfs/synced_folder.rb b/plugins/synced_folders/nfs/synced_folder.rb index f84c43b33..f2cdbd0dd 100644 --- a/plugins/synced_folders/nfs/synced_folder.rb +++ b/plugins/synced_folders/nfs/synced_folder.rb @@ -69,20 +69,23 @@ module VagrantPlugins end end - # Export the folders. We do this with a class-wide lock because - # NFS exporting often requires sudo privilege and we don't want - # overlapping input requests. [GH-2680] - @@lock.synchronize do - begin - machine.env.lock("nfs-export") do - machine.ui.info I18n.t("vagrant.actions.vm.nfs.exporting") - machine.env.host.capability( - :nfs_export, - machine.ui, machine.id, machine_ip, export_folders) + # Update the exports when there are actually exports [GH-4148] + if !export_folders.empty? + # Export the folders. We do this with a class-wide lock because + # NFS exporting often requires sudo privilege and we don't want + # overlapping input requests. [GH-2680] + @@lock.synchronize do + begin + machine.env.lock("nfs-export") do + machine.ui.info I18n.t("vagrant.actions.vm.nfs.exporting") + machine.env.host.capability( + :nfs_export, + machine.ui, machine.id, machine_ip, export_folders) + end + rescue Vagrant::Errors::EnvironmentLockedError + sleep 1 + retry end - rescue Vagrant::Errors::EnvironmentLockedError - sleep 1 - retry end end From 503632631983f75aff2dd0794ea0e4aabb8944ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Schwarze?= Date: Fri, 10 Oct 2014 20:09:42 +0200 Subject: [PATCH 036/615] Adding condition for the ipadm command on static ip addresses. This will enable restarting solaris 11 vagrant boxes with static ip addresses. --- plugins/guests/solaris11/cap/configure_networks.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/guests/solaris11/cap/configure_networks.rb b/plugins/guests/solaris11/cap/configure_networks.rb index 92e47703a..3aab75d86 100644 --- a/plugins/guests/solaris11/cap/configure_networks.rb +++ b/plugins/guests/solaris11/cap/configure_networks.rb @@ -19,7 +19,9 @@ module VagrantPlugins #machine.communicate.execute("#{ifconfig_cmd} up") #machine.communicate.execute("#{su_cmd} sh -c \"echo '#{network[:ip]}' > /etc/hostname.#{device}\"") # ipadm create-addr -T static -a local=172.16.10.15/24 net2/v4 - machine.communicate.execute("#{su_cmd} ipadm create-addr -T static -a #{network[:ip]}/#{cidr} #{device}/v4") + if not machine.communicate.test("ipadm | grep #{network[:ip]} | tr -s ' ' | cut -d ' ' -f 4") + machine.communicate.execute("#{su_cmd} ipadm create-addr -T static -a #{network[:ip]}/#{cidr} #{device}/v4") + end elsif network[:type].to_sym == :dhcp #machine.communicate.execute("#{ifconfig_cmd} dhcp start") if machine.communicate.test("ipadm show-if -o all | grep #{device} | tr -s ' ' | cut -d ' ' -f 6 | grep '4\|6'") From fe3a38082398972328654a586e521a36ceb8ff38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Schwarze?= Date: Fri, 10 Oct 2014 22:42:13 +0200 Subject: [PATCH 037/615] First fix didn't work correctly. Now, the ip address will be removed, if there (from dhcp) and re-configured with the given value. --- plugins/guests/solaris11/cap/configure_networks.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/guests/solaris11/cap/configure_networks.rb b/plugins/guests/solaris11/cap/configure_networks.rb index 3aab75d86..db448a4e8 100644 --- a/plugins/guests/solaris11/cap/configure_networks.rb +++ b/plugins/guests/solaris11/cap/configure_networks.rb @@ -19,9 +19,10 @@ module VagrantPlugins #machine.communicate.execute("#{ifconfig_cmd} up") #machine.communicate.execute("#{su_cmd} sh -c \"echo '#{network[:ip]}' > /etc/hostname.#{device}\"") # ipadm create-addr -T static -a local=172.16.10.15/24 net2/v4 - if not machine.communicate.test("ipadm | grep #{network[:ip]} | tr -s ' ' | cut -d ' ' -f 4") - machine.communicate.execute("#{su_cmd} ipadm create-addr -T static -a #{network[:ip]}/#{cidr} #{device}/v4") + if machine.communicate.test("ipadm | grep net1/v4") + machine.communicate.execute("#{su_cmd} ipadm delete-addr net1/v4") end + machine.communicate.execute("#{su_cmd} ipadm create-addr -T static -a #{network[:ip]}/#{cidr} #{device}/v4") elsif network[:type].to_sym == :dhcp #machine.communicate.execute("#{ifconfig_cmd} dhcp start") if machine.communicate.test("ipadm show-if -o all | grep #{device} | tr -s ' ' | cut -d ' ' -f 6 | grep '4\|6'") From b2a37dae993b3cc605bb81e157381ea149a398da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Schwarze?= Date: Fri, 10 Oct 2014 22:49:45 +0200 Subject: [PATCH 038/615] ...missed to replace the device variable :-) --- plugins/guests/solaris11/cap/configure_networks.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/guests/solaris11/cap/configure_networks.rb b/plugins/guests/solaris11/cap/configure_networks.rb index db448a4e8..15aa62679 100644 --- a/plugins/guests/solaris11/cap/configure_networks.rb +++ b/plugins/guests/solaris11/cap/configure_networks.rb @@ -19,8 +19,8 @@ module VagrantPlugins #machine.communicate.execute("#{ifconfig_cmd} up") #machine.communicate.execute("#{su_cmd} sh -c \"echo '#{network[:ip]}' > /etc/hostname.#{device}\"") # ipadm create-addr -T static -a local=172.16.10.15/24 net2/v4 - if machine.communicate.test("ipadm | grep net1/v4") - machine.communicate.execute("#{su_cmd} ipadm delete-addr net1/v4") + if machine.communicate.test("ipadm | grep #{device}/v4") + machine.communicate.execute("#{su_cmd} ipadm delete-addr #{device}/v4") end machine.communicate.execute("#{su_cmd} ipadm create-addr -T static -a #{network[:ip]}/#{cidr} #{device}/v4") elsif network[:type].to_sym == :dhcp From 3955d533f3c1994f243006a14359f1bba1b39e19 Mon Sep 17 00:00:00 2001 From: Teemu Matilainen Date: Sat, 11 Oct 2014 18:52:50 +0300 Subject: [PATCH 039/615] Force compatible Bundler version in Travis --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9baf9785e..6fb40430b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,9 @@ language: ruby before_install: - sudo apt-get update -qq - sudo apt-get install -qq -y bsdtar + - rvm @global do gem uninstall bundler --all --executables + - gem uninstall bundler --all --executables + - gem install bundler --version '< 1.7.0' rvm: - 2.0.0 env: From 0c8d0e4d1aaa7169aa59612f077986f6b165571e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janek=20Warcho=C5=82?= Date: Mon, 13 Oct 2014 16:03:57 +0200 Subject: [PATCH 040/615] docs - http sharing: fix typo --- website/docs/source/v2/share/http.html.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/source/v2/share/http.html.md b/website/docs/source/v2/share/http.html.md index 8c8a88830..0e99b5127 100644 --- a/website/docs/source/v2/share/http.html.md +++ b/website/docs/source/v2/share/http.html.md @@ -12,7 +12,7 @@ sharing," and is enabled by default when `vagrant share` is used. Because this mode of sharing creates a publicly accessible URL, the accessing party does not need to have Vagrant installed in order to view your environment. -This has a number of useful use cases: you can test webooks by exposing +This has a number of useful use cases: you can test webhooks by exposing your Vagrant environment to the internet, you can show your work to clients, teammates, or managers, etc. From 97589636b14b46cabde5f46eeaa477ddd78c091a Mon Sep 17 00:00:00 2001 From: dch Date: Tue, 14 Oct 2014 18:25:13 +0100 Subject: [PATCH 041/615] Provide output on raising LinuxMountFailed --- plugins/guests/linux/cap/mount_smb_shared_folder.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/guests/linux/cap/mount_smb_shared_folder.rb b/plugins/guests/linux/cap/mount_smb_shared_folder.rb index d50aae686..424982520 100644 --- a/plugins/guests/linux/cap/mount_smb_shared_folder.rb +++ b/plugins/guests/linux/cap/mount_smb_shared_folder.rb @@ -51,10 +51,15 @@ module VagrantPlugins while true success = true + stderr = "" mount_commands.each do |command| no_such_device = false + stderr = "" status = machine.communicate.sudo(command, error_check: false) do |type, data| - no_such_device = true if type == :stderr && data =~ /No such device/i + if type == :stderr + no_such_device = true if data =~ /No such device/i + stderr += data.to_s + end end success = status == 0 && !no_such_device @@ -69,7 +74,8 @@ module VagrantPlugins command.gsub!(smb_password, "PASSWORDHIDDEN") raise Vagrant::Errors::LinuxMountFailed, - command: command + command: command, + output: stderr end sleep 2 From d7493892f482eb9477c0030fa55249cecfdab4d4 Mon Sep 17 00:00:00 2001 From: Julien Vey Date: Tue, 14 Oct 2014 15:00:25 +0200 Subject: [PATCH 042/615] Allow SSH LogLevel to be overridden --- lib/vagrant/util/ssh.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/util/ssh.rb b/lib/vagrant/util/ssh.rb index 44e0403aa..0a71613c7 100644 --- a/lib/vagrant/util/ssh.rb +++ b/lib/vagrant/util/ssh.rb @@ -102,12 +102,14 @@ module Vagrant options[:username] = ssh_info[:username] options[:private_key_path] = ssh_info[:private_key_path] + log_level = ssh_info[:log_level] || "FATAL" + # Command line options command_options = [ "-p", options[:port].to_s, "-o", "Compression=yes", "-o", "DSAAuthentication=yes", - "-o", "LogLevel=FATAL", + "-o", "LogLevel=#{log_level}", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null"] From 189fd3246b86071998c43cbe571a97710dda485d Mon Sep 17 00:00:00 2001 From: Shawn Neal Date: Thu, 16 Oct 2014 08:11:38 -0700 Subject: [PATCH 043/615] Added basic WinRM config website docs --- website/docs/source/layouts/layout.erb | 1 + .../v2/vagrantfile/winrm_settings.html.md | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 website/docs/source/v2/vagrantfile/winrm_settings.html.md diff --git a/website/docs/source/layouts/layout.erb b/website/docs/source/layouts/layout.erb index 029d39fad..8d6dcd261 100644 --- a/website/docs/source/layouts/layout.erb +++ b/website/docs/source/layouts/layout.erb @@ -150,6 +150,7 @@ >Tips & Tricks >config.vm >config.ssh + >config.winrm >config.vagrant <% end %> diff --git a/website/docs/source/v2/vagrantfile/winrm_settings.html.md b/website/docs/source/v2/vagrantfile/winrm_settings.html.md new file mode 100644 index 000000000..93489ce60 --- /dev/null +++ b/website/docs/source/v2/vagrantfile/winrm_settings.html.md @@ -0,0 +1,45 @@ +--- +page_title: "config.winrm - Vagrantfile" +sidebar_current: "vagrantfile-winrm" +--- + +# WinRM Settings + +**Config namespace: `config.winrm`** + +The settings within `config.winrm` relate to configuring how Vagrant +will access your Windows guest over WinRM. As with most Vagrant settings, the +defaults are typically fine, but you can fine tune whatever you'd like. + +These settings are only used if you've set your communicator type to `:winrm`. + +## Available Settings + +`config.winrm.username` - This sets the username that Vagrant will use +to login to the WinRM web service by default. Providers are free to override +this if they detect a more appropriate user. By default this is "vagrant," +since that is what most public boxes are made as. + +
+ +`config.winrm.password` - This sets a password that Vagrant will use to +authenticate the WinRM user. By default this is "vagrant," since that is +what most public boxes are made as. + +
+ +`config.winrm.host` - The hostname or IP to SSH into. By default this is +empty, because the provider usually figures this out for you. + +
+ +`config.winrm.port` - The port to SSH into. By default this is port 22. + +
+ +`config.winrm.guest_port` - The port on the guest that SSH is running on. This +is used by some providers to detect forwarded ports for SSH. For example, if +this is set to 22 (the default), and Vagrant detects a forwarded port to +port 22 on the guest from port 4567 on the host, Vagrant will attempt +to use port 4567 to talk to the guest if there is no other option. + From e91cc1e0dfcfe759fe38435e6e686da4e40c9a02 Mon Sep 17 00:00:00 2001 From: Shawn Neal Date: Thu, 16 Oct 2014 08:16:01 -0700 Subject: [PATCH 044/615] Added communicator to config docs, specifically for winrm --- website/docs/source/v2/vagrantfile/machine_settings.html.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/website/docs/source/v2/vagrantfile/machine_settings.html.md b/website/docs/source/v2/vagrantfile/machine_settings.html.md index cfcca719b..b68d6f49a 100644 --- a/website/docs/source/v2/vagrantfile/machine_settings.html.md +++ b/website/docs/source/v2/vagrantfile/machine_settings.html.md @@ -85,6 +85,12 @@ constraints.
+`config.vm.communicator` - The communicator type to use to connect to the +guest box. By default this is `:ssh`, but should be changed to `:winrm` for +Windows guests. + +
+ `config.vm.graceful_halt_timeout` - The time in seconds that Vagrant will wait for the machine to gracefully halt when `vagrant halt` is called. Defaults to 60 seconds. From 7ff755c0dac699800e6329b3ba06999a421b76e0 Mon Sep 17 00:00:00 2001 From: Shawn Neal Date: Thu, 16 Oct 2014 08:56:30 -0700 Subject: [PATCH 045/615] Added Windows base box creation docs --- website/docs/source/v2/boxes/base.html.md | 50 +++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/website/docs/source/v2/boxes/base.html.md b/website/docs/source/v2/boxes/base.html.md index 2ea27c6cf..7e34bf1b5 100644 --- a/website/docs/source/v2/boxes/base.html.md +++ b/website/docs/source/v2/boxes/base.html.md @@ -157,6 +157,56 @@ in the SSH server configuration. This avoids a reverse DNS lookup on the connecting SSH client which can take many seconds. +## Windows Boxes + +Supported Windows guest operating systems: +- Windows 7 +- Windows 8 +- Windows Server 2008 +- Windows Server 2008 R2 +- Windows Server 2012 +- Windows Server 2012 R2 + +Windows Server 2003 and Windows XP are _not_ supported, but if you're a die +hard XP fan [this](http://stackoverflow.com/a/18593425/18475) may help you. + +### Base Windows Configuration + + - Turn off UAC + - Disable complex passwords + - Disable "Shutdown Tracker" + - Disable "Server Manager" starting at login (for non-Core) + +### Base WinRM Configuration + +To enable and configure WinRM you'll need to set the WinRM service to +auto-start and allow unencrypted basic auth (obviously this is not secure). +Run the following commands from a regular Windows command prompt: +``` +winrm quickconfig -q +winrm set winrm/config/winrs @{MaxMemoryPerShellMB="512"} +winrm set winrm/config @{MaxTimeoutms="1800000"} +winrm set winrm/config/service @{AllowUnencrypted="true"} +winrm set winrm/config/service/auth @{Basic="true"} +sc config WinRM start= auto +``` + +### Additional WinRM 1.1 Configuration + +These additional configuration steps are specific to Windows Server 2008 +(WinRM 1.1). For Windows Server 2008 R2, Windows 7 and later versions of +Windows you can ignore this section. + +1. Ensure the Windows PowerShell feature is installed +2. Change the WinRM port to 5985 or upgrade to WinRM 2.0 + +The following commands will change the WinRM 1.1 port to what's expected by +Vagrant: +``` +netsh firewall add portopening TCP 5985 "Port 5985" +winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"} +``` + ## Other Software At this point, you have all the common software you absolutely _need_ for From c0db48b0ab7a674357f98766b24f59631507acab Mon Sep 17 00:00:00 2001 From: Shawn Neal Date: Thu, 16 Oct 2014 09:00:08 -0700 Subject: [PATCH 046/615] Fixed the WinRM config documentation --- .../source/v2/vagrantfile/winrm_settings.html.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/website/docs/source/v2/vagrantfile/winrm_settings.html.md b/website/docs/source/v2/vagrantfile/winrm_settings.html.md index 93489ce60..462ccf56e 100644 --- a/website/docs/source/v2/vagrantfile/winrm_settings.html.md +++ b/website/docs/source/v2/vagrantfile/winrm_settings.html.md @@ -28,18 +28,19 @@ what most public boxes are made as.
-`config.winrm.host` - The hostname or IP to SSH into. By default this is -empty, because the provider usually figures this out for you. +`config.winrm.host` - The hostname or IP to connect to the WinRM service. +By default this is empty, because the provider usually figures this out for +you.
-`config.winrm.port` - The port to SSH into. By default this is port 22. +`config.winrm.port` - The WinRM port to connect to, by default 5985.
-`config.winrm.guest_port` - The port on the guest that SSH is running on. This -is used by some providers to detect forwarded ports for SSH. For example, if -this is set to 22 (the default), and Vagrant detects a forwarded port to -port 22 on the guest from port 4567 on the host, Vagrant will attempt +`config.winrm.guest_port` - The port on the guest that WinRM is running on. +This is used by some providers to detect forwarded ports for WinRM. For +example, if this is set to 5985 (the default), and Vagrant detects a forwarded +port to port 5985 on the guest from port 4567 on the host, Vagrant will attempt to use port 4567 to talk to the guest if there is no other option. From 1dd816cbe28da84a53db8f226bf932805ded7a0d Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Fri, 17 Oct 2014 11:21:11 -0400 Subject: [PATCH 047/615] Do not require rb-notify (temporary until we can upgrade middleman) --- website/docs/Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/Gemfile b/website/docs/Gemfile index 5f8d1e016..4a2399f5d 100644 --- a/website/docs/Gemfile +++ b/website/docs/Gemfile @@ -5,7 +5,7 @@ gem "middleman", "~> 3.0.6" gem "middleman-minify-html", "~> 3.0.0" gem "rack-contrib", "~> 1.1.0" gem "redcarpet", "~> 2.2.2" -gem "rb-inotify", "~> 0.9" +gem "rb-inotify", "~> 0.9", require: false gem "therubyracer", "~> 0.12.0" gem "thin", "~> 1.5.0" From 201e6b4d693d451105a2346f40388532bb6b4a81 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Fri, 17 Oct 2014 11:21:24 -0400 Subject: [PATCH 048/615] Update to the latest bundle to fix rubyracer issues --- website/docs/Gemfile.lock | 55 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/website/docs/Gemfile.lock b/website/docs/Gemfile.lock index c88f8653b..7e3a024b4 100644 --- a/website/docs/Gemfile.lock +++ b/website/docs/Gemfile.lock @@ -1,42 +1,44 @@ GEM remote: https://rubygems.org/ specs: - POpen4 (0.1.4) - Platform (>= 0.4.0) - open4 - Platform (0.4.0) activesupport (3.2.13) i18n (= 0.6.1) multi_json (~> 1.0) - chunky_png (1.2.8) + chunky_png (1.3.1) coffee-script (2.2.0) coffee-script-source execjs coffee-script-source (1.3.3) commonjs (0.2.7) - compass (0.12.2) + compass (1.0.1) chunky_png (~> 1.2) - fssm (>= 0.2.7) - sass (~> 3.1) + compass-core (~> 1.0.1) + compass-import-once (~> 1.0.5) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) + sass (>= 3.3.13, < 3.5) + compass-core (1.0.1) + multi_json (~> 1.0) + sass (>= 3.3.0, < 3.5) + compass-import-once (1.0.5) + sass (>= 3.2, < 3.5) daemons (1.1.9) eventmachine (1.0.3) - execjs (1.4.0) + execjs (1.4.1) multi_json (~> 1.0) - ffi (1.9.3) - fssm (0.2.10) - haml (4.0.3) + ffi (1.9.6) + haml (4.0.5) tilt - highline (1.6.19) + highline (1.6.21) hike (1.2.3) - htmlcompressor (0.0.7) - yui-compressor (~> 0.9.6) + htmlcompressor (0.1.2) http_router (0.10.2) rack (>= 1.0.0) url_mount (~> 0.2.1) i18n (0.6.1) less (2.2.2) commonjs (~> 0.2.6) - libv8 (3.16.14.3) + libv8 (3.16.14.7) listen (0.7.3) maruku (0.6.1) syntax (>= 1.0.0) @@ -74,8 +76,7 @@ GEM sprockets (~> 2.1) sprockets-helpers (~> 1.0.0) sprockets-sass (~> 1.0.0) - multi_json (1.8.0) - open4 (1.3.0) + multi_json (1.10.1) padrino-core (0.10.7) activesupport (~> 3.2.0) http_router (~> 0.10.2) @@ -88,32 +89,32 @@ GEM rack (1.4.5) rack-contrib (1.1.0) rack (>= 0.9.1) - rack-protection (1.5.0) + rack-protection (1.5.3) rack rack-test (0.6.2) rack (>= 1.0) - rb-fsevent (0.9.3) - rb-inotify (0.9.3) + rb-fsevent (0.9.4) + rb-inotify (0.9.5) ffi (>= 0.5.0) redcarpet (2.2.2) ref (1.0.5) - sass (3.2.10) + sass (3.4.6) sinatra (1.3.6) rack (~> 1.4) rack-protection (~> 1.3) tilt (~> 1.3, >= 1.3.3) - sprockets (2.10.0) + sprockets (2.12.2) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) sprockets-helpers (1.0.1) sprockets (~> 2.0) - sprockets-sass (1.0.1) + sprockets-sass (1.0.3) sprockets (~> 2.0) tilt (~> 1.1) - syntax (1.0.0) - therubyracer (0.12.0) + syntax (1.2.0) + therubyracer (0.12.1) libv8 (~> 3.16.14.0) ref thin (1.5.1) @@ -127,8 +128,6 @@ GEM multi_json (~> 1.3) url_mount (0.2.1) rack - yui-compressor (0.9.6) - POpen4 (>= 0.1.4) PLATFORMS ruby From 29c5658ce83e510802b12f1321dd1cc15a386108 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Fri, 17 Oct 2014 11:21:35 -0400 Subject: [PATCH 049/615] Add a note that VirtualBox supports parallelization --- website/docs/source/v2/virtualbox/usage.html.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/website/docs/source/v2/virtualbox/usage.html.md b/website/docs/source/v2/virtualbox/usage.html.md index 85c0f047f..20d76ac7f 100644 --- a/website/docs/source/v2/virtualbox/usage.html.md +++ b/website/docs/source/v2/virtualbox/usage.html.md @@ -5,8 +5,11 @@ sidebar_current: "virtualbox-usage" # Usage -The VirtualBox provider is used just like any other provider. Please +The Vagrant VirtualBox provider is used just like any other provider. Please read the general [basic usage](/v2/providers/basic_usage.html) page for providers. The value to use for the `--provider` flag is `virtualbox`. + +The Vagrant VirtualBox provider supports parallel execution with the +optional `--parallel` flag. From ea9d56f459eda7277bbc431aaeb1362ea4d37360 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Fri, 17 Oct 2014 11:21:48 -0400 Subject: [PATCH 050/615] Add a note that VMWare does not support parallelization at this time --- website/docs/source/v2/vmware/usage.html.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/website/docs/source/v2/vmware/usage.html.md b/website/docs/source/v2/vmware/usage.html.md index bf1a5e575..8771d1276 100644 --- a/website/docs/source/v2/vmware/usage.html.md +++ b/website/docs/source/v2/vmware/usage.html.md @@ -5,13 +5,16 @@ sidebar_current: "vmware-usage" # Usage -The VMware providers are used just like any other provider. Please +The Vagrant VMware providers are used just like any other provider. Please read the general [basic usage](/v2/providers/basic_usage.html) page for providers. The value to use for the `--provider` flag is `vmware_fusion` for VMware Fusion, and `vmware_workstation` for VMware Workstation. +The Vagrant VMWare provider does not support parallel execution at this time. +Specifying the `--parallel` option will have no effect. +

To get started, a 64-bit Ubuntu 12.04 LTS VMware box is available at: http://files.vagrantup.com/precise64_vmware.box From 5ad5411e0fe4ffb9a9b5236efa393e409809f8ba Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Fri, 17 Oct 2014 11:23:31 -0400 Subject: [PATCH 051/615] Add a note to check the docs --- website/docs/source/v2/cli/up.html.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/docs/source/v2/cli/up.html.md b/website/docs/source/v2/cli/up.html.md index fdbbcccbb..a0408a9a6 100644 --- a/website/docs/source/v2/cli/up.html.md +++ b/website/docs/source/v2/cli/up.html.md @@ -21,7 +21,8 @@ on a day-to-day basis. By default this is set. * `--[no-]parallel` - Bring multiple machines up in parallel if the provider - supports it. + supports it. Please consult the provider documentation to see if this feature + is supported. * `--provider x` - Bring the machine up with the given [provider](/v2/providers/index.html). By default this is "virtualbox". From e47a8b90688f2fec482ffebc4ced0a1d8fff8975 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Fri, 17 Oct 2014 11:31:13 -0400 Subject: [PATCH 052/615] VirtualBox does not support it either --- website/docs/source/v2/virtualbox/usage.html.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/source/v2/virtualbox/usage.html.md b/website/docs/source/v2/virtualbox/usage.html.md index 20d76ac7f..282cbc6d3 100644 --- a/website/docs/source/v2/virtualbox/usage.html.md +++ b/website/docs/source/v2/virtualbox/usage.html.md @@ -11,5 +11,5 @@ providers. The value to use for the `--provider` flag is `virtualbox`. -The Vagrant VirtualBox provider supports parallel execution with the -optional `--parallel` flag. +The Vagrant VirtualBox provider does not support parallel execution at this +time. Specifying the `--parallel` option will have no effect. From 4af0f9b9c67c9fc66aeb2a968e543c1f294c2037 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 18 Oct 2014 16:13:01 -0700 Subject: [PATCH 053/615] whitespace --- plugins/communicators/winrm/command_filters/rm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/communicators/winrm/command_filters/rm.rb b/plugins/communicators/winrm/command_filters/rm.rb index 251e26076..8ef79f148 100644 --- a/plugins/communicators/winrm/command_filters/rm.rb +++ b/plugins/communicators/winrm/command_filters/rm.rb @@ -20,7 +20,7 @@ module VagrantPlugins break end end - + # Figure out which argument is the path dir = cmd_parts.pop while !dir.nil? && dir.start_with?('-') From de408dafbf5b7c552d60b34ded5d2591107e7989 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 18 Oct 2014 16:13:59 -0700 Subject: [PATCH 054/615] Update CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9be106c2..7c36f99a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ BUG FIXES: - guests/redhat: Fix typo causing crash in configuring networks. [GH-4438] - guests/redhat: Fix typo causing hostnames to not set. [GH-4443] - providers/virtualbox: NFS works when using DHCP private network. [GH-4433] + - provisioners/salt: Fix error when removing non-existent bootstrap script + on Windows. [GH-4614] ## 1.6.4 (September 2, 2014) From 6986a8eeb20e8d543ad4896924ca63b799a5374f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 18 Oct 2014 16:28:05 -0700 Subject: [PATCH 055/615] Update wording for unreleased boxes --- templates/locales/en.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 4be7a92e7..47f80fac5 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -348,6 +348,9 @@ en: provider. Double-check your requested provider to verify you didn't simply misspell it. + If you're adding a box from Vagrant Cloud, make sure the box is + released. + Name: %{name} Address: %{url} Requested provider: %{requested} From 4e81be879c04f6f6c3dbd87b0f78a4a7206dd957 Mon Sep 17 00:00:00 2001 From: Gilles Cornu Date: Mon, 20 Oct 2014 17:33:06 +0200 Subject: [PATCH 056/615] Check SSH key permissions in machine.ssh_info With this change, any caller of machine.ssh_info is assured that best efforts will be done to fix possible wrong permissions on the private key files. Fix #4652 --- lib/vagrant/action/builtin/ssh_exec.rb | 5 --- lib/vagrant/action/builtin/ssh_run.rb | 5 --- lib/vagrant/machine.rb | 10 ++++++ plugins/communicators/ssh/communicator.rb | 6 ---- .../vagrant/action/builtin/ssh_exec_test.rb | 20 ------------ test/unit/vagrant/machine_test.rb | 31 ++++++++++++++++++- 6 files changed, 40 insertions(+), 37 deletions(-) diff --git a/lib/vagrant/action/builtin/ssh_exec.rb b/lib/vagrant/action/builtin/ssh_exec.rb index 23b209066..81ae53cd6 100644 --- a/lib/vagrant/action/builtin/ssh_exec.rb +++ b/lib/vagrant/action/builtin/ssh_exec.rb @@ -31,11 +31,6 @@ module Vagrant info[:private_key_path] ||= [] - # Check SSH key permissions - info[:private_key_path].each do |path| - SSH.check_key_permissions(Pathname.new(path)) - end - if info[:private_key_path].empty? && info[:password] env[:ui].warn(I18n.t("vagrant.ssh_exec_password")) end diff --git a/lib/vagrant/action/builtin/ssh_run.rb b/lib/vagrant/action/builtin/ssh_run.rb index db2a0d79e..d4058e6e4 100644 --- a/lib/vagrant/action/builtin/ssh_run.rb +++ b/lib/vagrant/action/builtin/ssh_run.rb @@ -29,11 +29,6 @@ module Vagrant info[:private_key_path] ||= [] - # Check SSH key permissions - info[:private_key_path].each do |path| - SSH.check_key_permissions(Pathname.new(path)) - end - if info[:private_key_path].empty? raise Errors::SSHRunRequiresKeys end diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index 9d2c0d15c..c38b983b2 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -1,3 +1,5 @@ +require_relative "util/ssh" + require "digest/md5" require "thread" @@ -434,6 +436,14 @@ module Vagrant File.expand_path(path, @env.root_path) end + # Check that the private key permissions are valid + info[:private_key_path].each do |path| + key_path = Pathname.new(path) + if key_path.exist? + Vagrant::Util::SSH.check_key_permissions(key_path) + end + end + # Return the final compiled SSH info data info end diff --git a/plugins/communicators/ssh/communicator.rb b/plugins/communicators/ssh/communicator.rb index f4d152002..f8d0978df 100644 --- a/plugins/communicators/ssh/communicator.rb +++ b/plugins/communicators/ssh/communicator.rb @@ -13,7 +13,6 @@ require 'vagrant/util/ansi_escape_code_remover' require 'vagrant/util/file_mode' require 'vagrant/util/platform' require 'vagrant/util/retryable' -require 'vagrant/util/ssh' module VagrantPlugins module CommunicatorSSH @@ -305,11 +304,6 @@ module VagrantPlugins verbose: :debug, } - # Check that the private key permissions are valid - ssh_info[:private_key_path].each do |path| - Vagrant::Util::SSH.check_key_permissions(Pathname.new(path)) - end - # Connect to SSH, giving it a few tries connection = nil begin diff --git a/test/unit/vagrant/action/builtin/ssh_exec_test.rb b/test/unit/vagrant/action/builtin/ssh_exec_test.rb index 17f355497..94b42b99c 100644 --- a/test/unit/vagrant/action/builtin/ssh_exec_test.rb +++ b/test/unit/vagrant/action/builtin/ssh_exec_test.rb @@ -1,7 +1,5 @@ require File.expand_path("../../../../base", __FILE__) -require "vagrant/util/ssh" - describe Vagrant::Action::Builtin::SSHExec do let(:app) { lambda { |env| } } let(:env) { { machine: machine } } @@ -16,7 +14,6 @@ describe Vagrant::Action::Builtin::SSHExec do before(:each) do # Stub the methods so that even if we test incorrectly, no side # effects actually happen. - allow(ssh_klass).to receive(:check_key_permissions) allow(ssh_klass).to receive(:exec) end @@ -29,23 +26,6 @@ describe Vagrant::Action::Builtin::SSHExec do to raise_error(Vagrant::Errors::SSHNotReady) end - it "should check key permissions then exec" do - key_path = "/foo" - machine_ssh_info[:private_key_path] = [key_path] - - expect(ssh_klass).to receive(:check_key_permissions). - with(Pathname.new(key_path)). - once. - ordered - - expect(ssh_klass).to receive(:exec). - with(machine_ssh_info, nil). - once. - ordered - - described_class.new(app, env).call(env) - end - it "should exec with the SSH info in the env if given" do ssh_info = { foo: :bar } diff --git a/test/unit/vagrant/machine_test.rb b/test/unit/vagrant/machine_test.rb index d8e55e346..ec7c67f53 100644 --- a/test/unit/vagrant/machine_test.rb +++ b/test/unit/vagrant/machine_test.rb @@ -470,7 +470,8 @@ describe Vagrant::Machine do end end - describe "ssh info" do + describe "#ssh_info" do + describe "with the provider returning nil" do it "should return nil if the provider returns nil" do expect(provider).to receive(:ssh_info).and_return(nil) @@ -480,9 +481,13 @@ describe Vagrant::Machine do describe "with the provider returning data" do let(:provider_ssh_info) { {} } + let(:ssh_klass) { Vagrant::Util::SSH } before(:each) do allow(provider).to receive(:ssh_info).and_return(provider_ssh_info) + # Stub the check_key_permissions method so that even if we test incorrectly, + # no side effects actually happen. + allow(ssh_klass).to receive(:check_key_permissions) end [:host, :port, :username].each do |type| @@ -554,6 +559,30 @@ describe Vagrant::Machine do ]) end + it "should check and try to fix the permissions of the default private key file" do + provider_ssh_info[:private_key_path] = nil + instance.config.ssh.private_key_path = nil + + expect(ssh_klass).to receive(:check_key_permissions).once.with(Pathname.new(instance.env.default_private_key_path.to_s)) + instance.ssh_info + end + + it "should check and try to fix the permissions of given private key files" do + provider_ssh_info[:private_key_path] = nil + # Use __FILE__ to provide an existing file + instance.config.ssh.private_key_path = [File.expand_path(__FILE__), File.expand_path(__FILE__)] + + expect(ssh_klass).to receive(:check_key_permissions).twice.with(Pathname.new(File.expand_path(__FILE__))) + instance.ssh_info + end + + it "should not check the permissions of a private key file that does not exist" do + provider_ssh_info[:private_key_path] = "/foo" + + expect(ssh_klass).to_not receive(:check_key_permissions) + instance.ssh_info + end + context "expanding path relative to the root path" do it "should with the provider key path" do provider_ssh_info[:private_key_path] = "~/foo" From 89a4a29d65cace4d970d0f220ad01815883ab8aa Mon Sep 17 00:00:00 2001 From: Gilles Cornu Date: Mon, 20 Oct 2014 17:45:02 +0200 Subject: [PATCH 057/615] Memoize machine.ssh_info when ready for connection --- lib/vagrant/machine.rb | 13 +++++++++++-- test/unit/vagrant/machine_test.rb | 11 +++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index c38b983b2..4e3638c9b 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -72,6 +72,12 @@ module Vagrant # @return [Vagrantfile] attr_reader :vagrantfile + # The SSH information for accessing this machine. + # This attribute is set only when the machine is ready for SSH communication. + # + # @return [Hash] + attr_reader :ssh_info + # Initialize a new machine. # # @param [String] name Name of the virtual machine. @@ -377,6 +383,9 @@ module Vagrant # # @return [Hash] SSH information. def ssh_info + + return @ssh_info unless @ssh_info.nil? + # First, ask the provider for their information. If the provider # returns nil, then the machine is simply not ready for SSH, and # we return nil as well. @@ -444,8 +453,8 @@ module Vagrant end end - # Return the final compiled SSH info data - info + # Memoize the final compiled SSH info data and return it + @ssh_info = info end # Returns the state of this machine. The state is queried from the diff --git a/test/unit/vagrant/machine_test.rb b/test/unit/vagrant/machine_test.rb index ec7c67f53..f24b4bd42 100644 --- a/test/unit/vagrant/machine_test.rb +++ b/test/unit/vagrant/machine_test.rb @@ -583,6 +583,17 @@ describe Vagrant::Machine do instance.ssh_info end + # It is not possible to test the memoization of a Ruby Hash with object equality, + # but we can verify that some code of ssh_info method is not executed again. + it "should check and try to fix the permissions of the private key file only once" do + provider_ssh_info[:private_key_path] = nil + instance.config.ssh.private_key_path = nil + + expect(ssh_klass).to receive(:check_key_permissions).once.with(Pathname.new(instance.env.default_private_key_path.to_s)) + instance.ssh_info + instance.ssh_info + end + context "expanding path relative to the root path" do it "should with the provider key path" do provider_ssh_info[:private_key_path] = "~/foo" From e9a28b02a55ecfd2b9006386ec8ece135f068cfb Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Wed, 8 Oct 2014 22:01:20 +0200 Subject: [PATCH 058/615] Remove Vagrant constants --- templates/commands/init/Vagrantfile.erb | 5 +---- templates/commands/init/Vagrantfile.min.erb | 5 +---- website/docs/Vagrantfile | 5 +---- website/docs/source/v2/vagrantfile/version.html.md | 4 +--- website/www/Vagrantfile | 5 +---- 5 files changed, 5 insertions(+), 19 deletions(-) diff --git a/templates/commands/init/Vagrantfile.erb b/templates/commands/init/Vagrantfile.erb index 7c8d05709..0a9f8e219 100644 --- a/templates/commands/init/Vagrantfile.erb +++ b/templates/commands/init/Vagrantfile.erb @@ -1,10 +1,7 @@ # -*- mode: ruby -*- # vi: set ft=ruby : -# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! -VAGRANTFILE_API_VERSION = "2" - -Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| +Vagrant.configure(2) do |config| # All Vagrant configuration is done here. The most common configuration # options are documented and commented below. For a complete reference, # please see the online documentation at vagrantup.com. diff --git a/templates/commands/init/Vagrantfile.min.erb b/templates/commands/init/Vagrantfile.min.erb index a1f886d47..6120ce0e4 100644 --- a/templates/commands/init/Vagrantfile.min.erb +++ b/templates/commands/init/Vagrantfile.min.erb @@ -1,10 +1,7 @@ # -*- mode: ruby -*- # vi: set ft=ruby : -# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! -VAGRANTFILE_API_VERSION = "2" - -Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| +Vagrant.configure(2) do |config| config.vm.box = "<%= box_name %>" <% if box_url -%> config.vm.box_url = "<%= box_url %>" diff --git a/website/docs/Vagrantfile b/website/docs/Vagrantfile index 7e26cbed8..7ce24fe70 100644 --- a/website/docs/Vagrantfile +++ b/website/docs/Vagrantfile @@ -1,9 +1,6 @@ # -*- mode: ruby -*- # vi: set ft=ruby : -# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! -VAGRANTFILE_API_VERSION = "2" - $script = <