From 1a6805d469528c80b94f9844c1498d45e0084121 Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Mon, 15 Sep 2014 21:49:37 -0700 Subject: [PATCH 001/165] Use the more canonical require_relative to include files --- plugins/provisioners/puppet/plugin.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/provisioners/puppet/plugin.rb b/plugins/provisioners/puppet/plugin.rb index 362a1c421..4d2b74bbe 100644 --- a/plugins/provisioners/puppet/plugin.rb +++ b/plugins/provisioners/puppet/plugin.rb @@ -10,22 +10,22 @@ module VagrantPlugins DESC config(:puppet, :provisioner) do - require File.expand_path("../config/puppet", __FILE__) + require_relative "config/puppet" Config::Puppet end config(:puppet_server, :provisioner) do - require File.expand_path("../config/puppet_server", __FILE__) + require_relative "config/puppet_server" Config::PuppetServer end provisioner(:puppet) do - require File.expand_path("../provisioner/puppet", __FILE__) + require_relative "provisioner/puppet" Provisioner::Puppet end provisioner(:puppet_server) do - require File.expand_path("../provisioner/puppet_server", __FILE__) + require_relative "provisioner/puppet_server" Provisioner::PuppetServer end end From 16870d72d1102ef3623a4269af2b87e37628f3bf Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Sun, 19 Oct 2014 21:28:38 -0700 Subject: [PATCH 002/165] Some work in progress environment support --- Vagrantfile | 79 +++++++----------- plugins/provisioners/puppet/config/puppet.rb | 69 +++++++++++++--- .../provisioners/puppet/provisioner/puppet.rb | 80 ++++++++++++++++--- templates/locales/en.yml | 11 +++ vagrant.gemspec | 3 +- 5 files changed, 171 insertions(+), 71 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 075157ed9..2dea5e123 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,54 +1,35 @@ -# This Vagrantfile can be used to develop Vagrant. Note that VirtualBox -# doesn't run in VirtualBox so you can't actually _run_ Vagrant within -# the VM created by this Vagrantfile, but you can use it to develop the -# Ruby, run unit tests, etc. -Vagrant.configure("2") do |config| - config.vm.box = "hashicorp/precise64" +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" - ["virtualbox", "vmware_fusion", "vmware_workstation"].each do |provider| - config.vm.provider provider do |v, override| - v.memory = "1024" +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + config.vm.box = "centos7" + + config.vm.define :centos7 do |centos7| + config.vm.network "private_network", ip: "192.168.11.3" + config.vm.hostname = "centos7" + # config.vm.network "public_network" + # config.ssh.forward_agent = true + config.vm.synced_folder "../puppet", "/puppet" + + config.vm.provider "virtualbox" do |vb| + vb.gui = false + # Use VBoxManage to customize the VM. For example to change memory: + vb.customize ["modifyvm", :id, "--memory", "2048"] end + + config.vm.provision "puppet" do |puppet| + puppet.environmentpath = "../puppet/environments" + puppet.environment = "testenv" + # puppet.manifests_path = "../puppet/manifests" + # puppet.manifest_file = "site.pp" + puppet.module_path = [ "../puppet/modules/public", "../puppet/modules/private" ] + # puppet.options = "--debug --verbose" + end + + # Deprecated method: + #puppet apply --debug --verbose --modulepath '/puppet/modules/private:/puppet/modules/public:/etc/puppet/modules' + #--manifestdir /tmp/vagrant-puppet-1/manifests --detailed-exitcodes /tmp/vagrant-puppet-1/manifests/site.pp + end - - config.vm.provision "shell", inline: $shell end - -$shell = <<-CONTENTS -MARKER_FILE="/usr/local/etc/vagrant_provision_marker" - -# Only provision once -if [ -f "${MARKER_FILE}" ]; then - exit 0 -fi - -# Update apt -apt-get update - -# Install basic dependencies -apt-get install -y build-essential bsdtar curl - -# Install RVM -su -l -c 'curl -L https://get.rvm.io | bash -s stable' vagrant - -# Add the vagrant user to the RVM group -#usermod -a -G rvm vagrant - -# Install some Rubies -su -l -c 'rvm install 2.1.1' vagrant -su -l -c 'rvm --default use 2.1.1' vagrant - -# Output the Ruby version (for sanity) -su -l -c 'ruby --version' vagrant - -# Install Git -apt-get install -y git - -# Automatically move into the shared folder, but only add the command -# if it's not already there. -grep -q 'cd /vagrant' /home/vagrant/.bash_profile || echo 'cd /vagrant' >> /home/vagrant/.bash_profile - -# Touch the marker file so we don't do this again -touch ${MARKER_FILE} -CONTENTS diff --git a/plugins/provisioners/puppet/config/puppet.rb b/plugins/provisioners/puppet/config/puppet.rb index 3117f9f6f..cc028b8db 100644 --- a/plugins/provisioners/puppet/config/puppet.rb +++ b/plugins/provisioners/puppet/config/puppet.rb @@ -10,6 +10,8 @@ module VagrantPlugins attr_accessor :hiera_config_path attr_accessor :manifest_file attr_accessor :manifests_path + attr_accessor :environment + attr_accessor :environmentpath attr_accessor :module_path attr_accessor :options attr_accessor :synced_folder_type @@ -22,6 +24,8 @@ module VagrantPlugins @hiera_config_path = UNSET_VALUE @manifest_file = UNSET_VALUE @manifests_path = UNSET_VALUE + @environment = UNSET_VALUE + @environmentpath = UNSET_VALUE @module_path = UNSET_VALUE @options = [] @facter = {} @@ -45,24 +49,45 @@ module VagrantPlugins def merge(other) super.tap do |result| result.facter = @facter.merge(other.facter) + result.environmentpath = @facter.merge(other.environmentpath) + result.environment = @facter.merge(other.environment) end end def finalize! super - if @manifests_path == UNSET_VALUE - @manifests_path = [:host, "manifests"] - end + if @environmentpath == UNSET_VALUE + if @manifests_path == UNSET_VALUE + if 1 #If puppet 3.4+ + puts "Puppet 3.4+, manifests_path is unset and environmentpath is unset, presuming an environment" + @environmentpath = [:host, "environments"] + else + @manifests_path = [:host, "manifests"] + end + end - if @manifests_path && !@manifests_path.is_a?(Array) - @manifests_path = [:host, @manifests_path] + if @manifests_path && !@manifests_path.is_a?(Array) + @manifests_path = [:host, @manifests_path] + end + else + if @environmentpath && !@environmentpath.is_a?(Array) + @environmentpath = [:host, @environmentpath] + end end - @manifests_path[0] = @manifests_path[0].to_sym - @hiera_config_path = nil if @hiera_config_path == UNSET_VALUE - @manifest_file = "default.pp" if @manifest_file == UNSET_VALUE + + if @environmentpath == UNSET_VALUE + @manifests_path[0] = @manifests_path[0].to_sym + @environmentpath = nil + @manifest_file = "default.pp" if @manifest_file == UNSET_VALUE + else + @environmentpath[0] = @environmentpath[0].to_sym + @environment = "production" if @environment == UNSET_VALUE + @manifest_file = nil + end + @module_path = nil if @module_path == UNSET_VALUE @synced_folder_type = nil if @synced_folder_type == UNSET_VALUE @temp_dir = nil if @temp_dir == UNSET_VALUE @@ -96,8 +121,13 @@ module VagrantPlugins # Calculate the manifests and module paths based on env this_expanded_module_paths = expanded_module_paths(machine.env.root_path) + if environmentpath != UNSET_VALUE && manifests_path != UNSET_VALUE + errors << "You may not specify both environmentpath and manifests_path. Please specify environment and environmentpath only" + end + # Manifests path/file validation - if manifests_path[0].to_sym == :host + puts "manifests_path is #{manifests_path}" + if manifests_path != UNSET_VALUE && manifests_path[0].to_sym == :host expanded_path = Pathname.new(manifests_path[1]). expand_path(machine.env.root_path) if !expanded_path.directory? @@ -110,8 +140,29 @@ module VagrantPlugins manifest: expanded_manifest_file.to_s) end end + end + + # Environments path/file validation + if environmentpath != UNSET_VALUE && environmentpath[0].to_sym == :host + expanded_path = Pathname.new(environmentpath[1]). + expand_path(machine.env.root_path) + if !expanded_path.directory? + errors << I18n.t("vagrant.provisioners.puppet.environmentpath_missing", + path: expanded_path.to_s) + else + expanded_environment_file = expanded_path.join(environment) + if !expanded_environment_file.file? && !expanded_environment_file.directory? + errors << I18n.t("vagrant.provisioners.puppet.environment_missing", + environment: environment.to_s, + environmentpath: expanded_path.to_s) + end + end end + if environmentpath == UNSET_VALUE && manifests_path == UNSET_VALUE + errors << "Please specify either a Puppet environmentpath + environment (preferred) or manifests_path (deprecated)." + end + # Module paths validation this_expanded_module_paths.each do |path| if !path.directory? diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb index f49316bf7..14b64087e 100644 --- a/plugins/provisioners/puppet/provisioner/puppet.rb +++ b/plugins/provisioners/puppet/provisioner/puppet.rb @@ -18,7 +18,6 @@ module VagrantPlugins # Calculate the paths we're going to use based on the environment root_path = @machine.env.root_path @expanded_module_paths = @config.expanded_module_paths(root_path) - @manifest_file = File.join(manifests_guest_path, @config.manifest_file) # Setup the module paths @module_paths = [] @@ -30,11 +29,23 @@ module VagrantPlugins folder_opts[:type] = @config.synced_folder_type if @config.synced_folder_type folder_opts[:owner] = "root" if !@config.synced_folder_type - # Share the manifests directory with the guest - if @config.manifests_path[0].to_sym == :host - root_config.vm.synced_folder( - File.expand_path(@config.manifests_path[1], root_path), - manifests_guest_path, folder_opts) + if @config.environmentpath.is_a?(Array) + # Share the environments directory with the guest + if @config.environmentpath[0].to_sym == :host + root_config.vm.synced_folder( + File.expand_path(@config.environmentpath[1], root_path), + environments_guest_path, folder_opts) + end + parse_environment_metadata() + else + # Non-Environment mode + @manifest_file = File.join(manifests_guest_path, @config.manifest_file) + # Share the manifests directory with the guest + if @config.manifests_path[0].to_sym == :host + root_config.vm.synced_folder( + File.expand_path(@config.manifests_path[1], root_path), + manifests_guest_path, folder_opts) + end end # Share the module paths @@ -43,6 +54,24 @@ module VagrantPlugins end end + # For convenience, add in any module_paths from the Puppet environment.cfg to the vagrant module_paths + # This is needed because puppet apply does not read environment metadata (as of v3.6) + def parse_environment_metadata + environment_conf = File.join(environments_guest_path, @config.environment, "environment.conf") + if @machine.communicate.test("test -e #{environment_conf}", sudo: true) + conf = @machine.communicate.sudo("cat #{environment_conf}") do | type, data| + if type == :stdout + #modulepath = $basemodulepath:modules/private:modules/public + puts "got line #{data}" + end + end + puts "Found an environment cfg at: #{environment_conf} - #{conf}" + else + puts "env cfg not found, looked for #{environment_conf}" + end + end + + def provision # If the machine has a wait for reboot functionality, then # do that (primarily Windows) @@ -52,9 +81,12 @@ module VagrantPlugins # Check that the shared folders are properly shared check = [] - if @config.manifests_path[0] == :host + if @config.manifests_path.is_a?(Array) && @config.manifests_path[0] == :host check << manifests_guest_path end + if @config.environmentpath.is_a?(Array) && @config.environmentpath[0] == :host + check << environments_guest_path + end @module_paths.each do |host_path, guest_path| check << guest_path end @@ -92,6 +124,16 @@ module VagrantPlugins end end + def environments_guest_path + if config.environmentpath[0] == :host + # The path is on the host, so point to where it is shared + File.join(config.temp_dir, "environments") + else + # The path is on the VM, so just point directly to it + config.environmentpath[1] + end + end + def verify_binary(binary) @machine.communicate.sudo( "which #{binary}", @@ -125,10 +167,18 @@ module VagrantPlugins options << "--color=false" end - options << "--manifestdir #{manifests_guest_path}" options << "--detailed-exitcodes" - options << @manifest_file + + if !config.environmentpath.empty? + options << "#{environments_guest_path}/#{@config.environment}/manifests" + options << "--environment #{@config.environment}" + else + options << "--manifestdir #{manifests_guest_path}" + options << @manifest_file + end options = options.join(" ") + + @machine.ui.info("Running ye puppet apply with options #{options}") # Build up the custom facts if we have any facter = "" @@ -155,9 +205,15 @@ module VagrantPlugins end end - @machine.ui.info(I18n.t( - "vagrant.provisioners.puppet.running_puppet", - manifest: config.manifest_file)) + if !config.environmentpath.empty? + @machine.ui.info(I18n.t( + "vagrant.provisioners.puppet.running_puppet_env", + environment: config.environment)) + else + @machine.ui.info(I18n.t( + "vagrant.provisioners.puppet.running_puppet", + manifest: config.manifest_file)) + end opts = { elevated: true, diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 4be7a92e7..2ec1d5c54 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1733,12 +1733,23 @@ en: installed on this guest. Puppet provisioning can not continue without Puppet properly installed. running_puppet: "Running Puppet with %{manifest}..." + running_puppet_env: "Running Puppet with environment %{environment}..." manifest_missing: |- The configured Puppet manifest is missing. Please specify a path to an existing manifest: %{manifest} + environment_missing: |- + The configured Puppet environment folder '%{environment}' was not found in the + specified environmentpath %{environmentpath}. + Please specify a path to an existing Puppet directory environment. manifests_path_missing: "The manifests path specified for Puppet does not exist: %{path}" + manifest_missing: |- + The configured Puppet envrionment is missing. Please specify a path to an + existing envrionment file: + + %{environment} + manifests_path_missing: "The environment path specified for Puppet does not exist: %{path}" missing_shared_folders: |- Shared folders that Puppet requires are missing on the virtual machine. This is usually due to configuration changing after already booting the diff --git a/vagrant.gemspec b/vagrant.gemspec index c4131b270..4a53983dc 100644 --- a/vagrant.gemspec +++ b/vagrant.gemspec @@ -15,7 +15,8 @@ Gem::Specification.new do |s| s.required_rubygems_version = ">= 1.3.6" s.rubyforge_project = "vagrant" - s.add_dependency "bundler", ">= 1.5.2", "< 1.7.0" + s.add_dependency "bundler", ">= 1.5.2" +#, "< 1.7.0" s.add_dependency "childprocess", "~> 0.5.0" s.add_dependency "erubis", "~> 2.7.0" s.add_dependency "i18n", "~> 0.6.0" From 3321a6da117b050713a6f250aa18b91a3e985352 Mon Sep 17 00:00:00 2001 From: Ben Hines Date: Sun, 19 Oct 2014 21:34:54 -0700 Subject: [PATCH 003/165] Make environment path param more canonical with an underscore --- Vagrantfile | 2 +- plugins/provisioners/puppet/config/puppet.rb | 56 ++++++++++---------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 2dea5e123..0f5f34c66 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -19,7 +19,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| end config.vm.provision "puppet" do |puppet| - puppet.environmentpath = "../puppet/environments" + puppet.environment_path = "../puppet/environments" puppet.environment = "testenv" # puppet.manifests_path = "../puppet/manifests" # puppet.manifest_file = "site.pp" diff --git a/plugins/provisioners/puppet/config/puppet.rb b/plugins/provisioners/puppet/config/puppet.rb index cc028b8db..a6140b037 100644 --- a/plugins/provisioners/puppet/config/puppet.rb +++ b/plugins/provisioners/puppet/config/puppet.rb @@ -11,7 +11,7 @@ module VagrantPlugins attr_accessor :manifest_file attr_accessor :manifests_path attr_accessor :environment - attr_accessor :environmentpath + attr_accessor :environment_path attr_accessor :module_path attr_accessor :options attr_accessor :synced_folder_type @@ -21,17 +21,17 @@ module VagrantPlugins def initialize super - @hiera_config_path = UNSET_VALUE - @manifest_file = UNSET_VALUE - @manifests_path = UNSET_VALUE - @environment = UNSET_VALUE - @environmentpath = UNSET_VALUE - @module_path = UNSET_VALUE - @options = [] - @facter = {} + @hiera_config_path = UNSET_VALUE + @manifest_file = UNSET_VALUE + @manifests_path = UNSET_VALUE + @environment = UNSET_VALUE + @environment_path = UNSET_VALUE + @module_path = UNSET_VALUE + @options = [] + @facter = {} @synced_folder_type = UNSET_VALUE - @temp_dir = UNSET_VALUE - @working_directory = UNSET_VALUE + @temp_dir = UNSET_VALUE + @working_directory = UNSET_VALUE end def nfs=(value) @@ -49,7 +49,7 @@ module VagrantPlugins def merge(other) super.tap do |result| result.facter = @facter.merge(other.facter) - result.environmentpath = @facter.merge(other.environmentpath) + result.environment_path = @facter.merge(other.environment_path) result.environment = @facter.merge(other.environment) end end @@ -57,11 +57,11 @@ module VagrantPlugins def finalize! super - if @environmentpath == UNSET_VALUE + if @environment_path == UNSET_VALUE if @manifests_path == UNSET_VALUE if 1 #If puppet 3.4+ - puts "Puppet 3.4+, manifests_path is unset and environmentpath is unset, presuming an environment" - @environmentpath = [:host, "environments"] + puts "Puppet 3.4+, manifests_path is unset and environment_path is unset, presuming an environment" + @environment_path = [:host, "environments"] else @manifests_path = [:host, "manifests"] end @@ -71,19 +71,19 @@ module VagrantPlugins @manifests_path = [:host, @manifests_path] end else - if @environmentpath && !@environmentpath.is_a?(Array) - @environmentpath = [:host, @environmentpath] + if @environment_path && !@environment_path.is_a?(Array) + @environment_path = [:host, @environment_path] end end @hiera_config_path = nil if @hiera_config_path == UNSET_VALUE - if @environmentpath == UNSET_VALUE + if @environment_path == UNSET_VALUE @manifests_path[0] = @manifests_path[0].to_sym - @environmentpath = nil + @environment_path = nil @manifest_file = "default.pp" if @manifest_file == UNSET_VALUE else - @environmentpath[0] = @environmentpath[0].to_sym + @environment_path[0] = @environment_path[0].to_sym @environment = "production" if @environment == UNSET_VALUE @manifest_file = nil end @@ -121,8 +121,8 @@ module VagrantPlugins # Calculate the manifests and module paths based on env this_expanded_module_paths = expanded_module_paths(machine.env.root_path) - if environmentpath != UNSET_VALUE && manifests_path != UNSET_VALUE - errors << "You may not specify both environmentpath and manifests_path. Please specify environment and environmentpath only" + if environment_path != UNSET_VALUE && manifests_path != UNSET_VALUE + errors << "You may not specify both environment_path and manifests_path. Please specify environment and environment_path only" end # Manifests path/file validation @@ -143,24 +143,24 @@ module VagrantPlugins end # Environments path/file validation - if environmentpath != UNSET_VALUE && environmentpath[0].to_sym == :host - expanded_path = Pathname.new(environmentpath[1]). + if environment_path != UNSET_VALUE && environment_path[0].to_sym == :host + expanded_path = Pathname.new(environment_path[1]). expand_path(machine.env.root_path) if !expanded_path.directory? - errors << I18n.t("vagrant.provisioners.puppet.environmentpath_missing", + errors << I18n.t("vagrant.provisioners.puppet.environment_path_missing", path: expanded_path.to_s) else expanded_environment_file = expanded_path.join(environment) if !expanded_environment_file.file? && !expanded_environment_file.directory? errors << I18n.t("vagrant.provisioners.puppet.environment_missing", environment: environment.to_s, - environmentpath: expanded_path.to_s) + environment_path: expanded_path.to_s) end end end - if environmentpath == UNSET_VALUE && manifests_path == UNSET_VALUE - errors << "Please specify either a Puppet environmentpath + environment (preferred) or manifests_path (deprecated)." + if environment_path == UNSET_VALUE && manifests_path == UNSET_VALUE + errors << "Please specify either a Puppet environment_path + environment (preferred) or manifests_path (deprecated)." end # Module paths validation From d33c7b4d7affd90834baa981fc6f6454f6542882 Mon Sep 17 00:00:00 2001 From: Fabian Ruff Date: Mon, 27 Oct 2014 18:21:02 +0100 Subject: [PATCH 004/165] Add password to rdp_info hash Any specific reason the password was omitted from the rdp_info hash? Without the password in the rdp_info hash I see no way of figuring out the password in the rdp_client capability. --- plugins/commands/rdp/command.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/commands/rdp/command.rb b/plugins/commands/rdp/command.rb index 156312dd2..ba6d4d453 100644 --- a/plugins/commands/rdp/command.rb +++ b/plugins/commands/rdp/command.rb @@ -69,7 +69,15 @@ module VagrantPlugins end rdp_info[:username] = username end - + + if !rdp_info[:password] + username = ssh_info[:password] + if machine.config.vm.communicator == :winrm + username = machine.config.winrm.password + end + rdp_info[:password] = username + end + rdp_info[:host] ||= ssh_info[:host] rdp_info[:port] ||= machine.config.rdp.port From 8990e18e6df7324298905fc652b229a2efc42a36 Mon Sep 17 00:00:00 2001 From: Fabian Ruff Date: Mon, 27 Oct 2014 18:23:00 +0100 Subject: [PATCH 005/165] fix copy and paste bug --- plugins/commands/rdp/command.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/commands/rdp/command.rb b/plugins/commands/rdp/command.rb index ba6d4d453..e41c177fc 100644 --- a/plugins/commands/rdp/command.rb +++ b/plugins/commands/rdp/command.rb @@ -71,11 +71,11 @@ module VagrantPlugins end if !rdp_info[:password] - username = ssh_info[:password] + password = ssh_info[:password] if machine.config.vm.communicator == :winrm - username = machine.config.winrm.password + password = machine.config.winrm.password end - rdp_info[:password] = username + rdp_info[:password] = password end rdp_info[:host] ||= ssh_info[:host] From 9ab8d05cc7b2590ce0ea88cb63fa5da45ec2cb9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?W=C5=82odzimierz=20Gajda?= Date: Fri, 14 Nov 2014 07:46:20 +0100 Subject: [PATCH 006/165] doc destroy - notice about space occupied by the box --- website/docs/source/v2/cli/destroy.html.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/website/docs/source/v2/cli/destroy.html.md b/website/docs/source/v2/cli/destroy.html.md index 8b16e7973..9ed12ea11 100644 --- a/website/docs/source/v2/cli/destroy.html.md +++ b/website/docs/source/v2/cli/destroy.html.md @@ -18,3 +18,15 @@ confirmation can be skipped by passing in the `-f` or `--force` flag. ## Options * `-f` or `--force` - Don't ask for confirmation before destroying. + +
+

+ The vagrant destroy command does not remove a box + that may have been installed on your computer during vagrant up. + Thus, even if you run vagrant destroy, the box installed in the system + will still be present on the hard drive. To return your computer to the + state as it was before vagrant up command, you need to use + vagrant box remove. For more information, read about the + [vagrant box remove](/v2/cli/box.html) command. +

+
From 5de3f30bb0d3481dea8bc941ab8e36494ddc4d39 Mon Sep 17 00:00:00 2001 From: Chad Maloney Date: Tue, 25 Nov 2014 12:38:41 -0600 Subject: [PATCH 007/165] GH-4201: Added rsync__showoutput to display rsync output to console --- CHANGELOG.md | 2 ++ plugins/synced_folders/rsync/helper.rb | 12 +++++++++++- templates/locales/en.yml | 1 + website/docs/source/v2/synced-folders/rsync.html.md | 4 ++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53565b085..72a0903d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,8 @@ IMPROVEMENTS: - synced\_folders/nfs: Won't use `sudo` to write to /etc/exports if there are write privileges. [GH-2643] - synced\_folders/smb: Credentials from one SMB will be copied to the rest. [GH-4675] + - synced\_filders/rsync: Added rsync__showoutput option to echo rsync output + to console [GH-4201] BUG FIXES: diff --git a/plugins/synced_folders/rsync/helper.rb b/plugins/synced_folders/rsync/helper.rb index bc7f6d116..21d0890ad 100644 --- a/plugins/synced_folders/rsync/helper.rb +++ b/plugins/synced_folders/rsync/helper.rb @@ -121,13 +121,23 @@ module VagrantPlugins machine.ui.info(I18n.t( "vagrant.rsync_folder_excludes", excludes: excludes.inspect)) end + if opts.include?(:showoutput) + machine.ui.info(I18n.t("vagrant.rsync_showingoutput")); + end # If we have tasks to do before rsyncing, do those. if machine.guest.capability?(:rsync_pre) machine.guest.capability(:rsync_pre, opts) end - r = Vagrant::Util::Subprocess.execute(*(command + [command_opts])) + if opts.include?(:showoutput) + command_opts[:notify] = [ :stdout, :stderr ]; + r = Vagrant::Util::Subprocess.execute( + *(command + [command_opts])) { |io_name,data| machine.ui.info("rsync[#{io_name}] -> #{data}") } + else + r = Vagrant::Util::Subprocess.execute(*(command + [command_opts])) + end + if r.exit_code != 0 raise Vagrant::Errors::RSyncError, command: command.join(" "), diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 81365587d..908e3bfea 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -212,6 +212,7 @@ en: The provider ('%{provider}') for the machine '%{name}' is using a proxy machine. RSync will sync to this proxy instead of directly to the environment itself. + rsync_showing_output: "Showing rsync output..." rsync_ssh_password: |- The machine you're rsyncing folders to is configured to use password-based authentication. Vagrant can't script rsync to automatically diff --git a/website/docs/source/v2/synced-folders/rsync.html.md b/website/docs/source/v2/synced-folders/rsync.html.md index 62e88d0dd..d92c6d46c 100644 --- a/website/docs/source/v2/synced-folders/rsync.html.md +++ b/website/docs/source/v2/synced-folders/rsync.html.md @@ -62,6 +62,10 @@ The rsync synced folder type accepts the following options: pattern. By default, the ".vagrant/" directory is excluded. We recommend excluding revision control directories such as ".git/" as well. +* `rsync__showoutput` (boolean) - If true, then the output from the rsync + process will be echoed to the console. The output of rsync is subject + to rsync__args of course. By default, this is false. + ## Example The following is an example of using RSync to sync a folder: From cf784d5d3cdc2c1a49b15fc4dc5a0fcc76a40664 Mon Sep 17 00:00:00 2001 From: Chad Maloney Date: Tue, 25 Nov 2014 14:37:59 -0600 Subject: [PATCH 008/165] GH-4201: Split process output by line so prefix shows on each line. Also fixed localization reference. --- plugins/synced_folders/rsync/helper.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/synced_folders/rsync/helper.rb b/plugins/synced_folders/rsync/helper.rb index 21d0890ad..eb637af96 100644 --- a/plugins/synced_folders/rsync/helper.rb +++ b/plugins/synced_folders/rsync/helper.rb @@ -31,6 +31,10 @@ module VagrantPlugins Regexp.new(regexp) end + # Output rsync process stdout/stderr line by line + def self.outputRsyncData(io_name, data) + end + def self.rsync_single(machine, ssh_info, opts) # Folder info guestpath = opts[:guestpath] @@ -122,7 +126,7 @@ module VagrantPlugins "vagrant.rsync_folder_excludes", excludes: excludes.inspect)) end if opts.include?(:showoutput) - machine.ui.info(I18n.t("vagrant.rsync_showingoutput")); + machine.ui.info(I18n.t("vagrant.rsync_showing_output")); end # If we have tasks to do before rsyncing, do those. @@ -132,8 +136,9 @@ module VagrantPlugins if opts.include?(:showoutput) command_opts[:notify] = [ :stdout, :stderr ]; - r = Vagrant::Util::Subprocess.execute( - *(command + [command_opts])) { |io_name,data| machine.ui.info("rsync[#{io_name}] -> #{data}") } + r = Vagrant::Util::Subprocess.execute(*(command + [command_opts])) { + |io_name,data| data.each_line { |line| machine.ui.info("rsync[#{io_name}] -> #{line}") } + } else r = Vagrant::Util::Subprocess.execute(*(command + [command_opts])) end From fa99f95ea1b77259f8b3956fa4b01c88f76fdaa9 Mon Sep 17 00:00:00 2001 From: Chad Maloney Date: Tue, 25 Nov 2014 14:38:59 -0600 Subject: [PATCH 009/165] GH-4201: Filders isn't a real word --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72a0903d6..8880478e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,7 +40,7 @@ IMPROVEMENTS: - synced\_folders/nfs: Won't use `sudo` to write to /etc/exports if there are write privileges. [GH-2643] - synced\_folders/smb: Credentials from one SMB will be copied to the rest. [GH-4675] - - synced\_filders/rsync: Added rsync__showoutput option to echo rsync output + - synced\_folders/rsync: Added rsync__showoutput option to echo rsync output to console [GH-4201] BUG FIXES: From 1ed31afeba7b919b0ab54a02f0858c45278ce35c Mon Sep 17 00:00:00 2001 From: Chad Maloney Date: Tue, 25 Nov 2014 14:39:56 -0600 Subject: [PATCH 010/165] GH-4201: Cleaned up some leftover junk I missed removing --- plugins/synced_folders/rsync/helper.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugins/synced_folders/rsync/helper.rb b/plugins/synced_folders/rsync/helper.rb index eb637af96..a0a8598e6 100644 --- a/plugins/synced_folders/rsync/helper.rb +++ b/plugins/synced_folders/rsync/helper.rb @@ -31,10 +31,6 @@ module VagrantPlugins Regexp.new(regexp) end - # Output rsync process stdout/stderr line by line - def self.outputRsyncData(io_name, data) - end - def self.rsync_single(machine, ssh_info, opts) # Folder info guestpath = opts[:guestpath] From 9aa20d5d6b91bb1185a0177eac2700ef6eac6314 Mon Sep 17 00:00:00 2001 From: Andrew Mains Date: Wed, 20 Aug 2014 12:04:32 -0700 Subject: [PATCH 011/165] Added ability to run salt orchestrations to salt provisioner --- plugins/provisioners/salt/config.rb | 1 + plugins/provisioners/salt/provisioner.rb | 29 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/plugins/provisioners/salt/config.rb b/plugins/provisioners/salt/config.rb index 4d97d942c..2d325dfe0 100644 --- a/plugins/provisioners/salt/config.rb +++ b/plugins/provisioners/salt/config.rb @@ -15,6 +15,7 @@ module VagrantPlugins attr_accessor :grains_config attr_accessor :run_highstate attr_accessor :run_overstate + attr_accessor :orchestrations attr_accessor :always_install attr_accessor :bootstrap_script attr_accessor :verbose diff --git a/plugins/provisioners/salt/provisioner.rb b/plugins/provisioners/salt/provisioner.rb index 87af7cc7d..65ef63077 100644 --- a/plugins/provisioners/salt/provisioner.rb +++ b/plugins/provisioners/salt/provisioner.rb @@ -9,6 +9,7 @@ module VagrantPlugins run_bootstrap_script call_overstate call_highstate + call_orchestrate end # Return a list of accepted keys @@ -336,6 +337,34 @@ module VagrantPlugins @machine.env.ui.info "run_highstate set to false. Not running state.highstate." end end + + def call_orchestrate + if not @config.orchestrations + @machine.env.ui.info "orchestrate is nil. Not running state.orchestrate." + return + end + + if not @config.install_master + @machine.env.ui.info "orchestrate does not make sense on a minion. Not running state.orchestrate" + return + end + + log_output = lambda do |type, data| + if @config.verbose + @machine.env.ui.info(data) + end + end + + @machine.env.ui.info "Running the following orchestrations: #{@config.orchestrations}" + @machine.env.ui.info "Running saltutil.sync_all before orchestrating" + @machine.communicate.sudo("salt '*' saltutil.sync_all", &log_output) + + @config.orchestrations.each do |orchestration| + cmd = "salt-run -l info state.orchestrate #{orchestration}" + @machine.env.ui.info "Calling #{cmd}... (this may take a while)" + @machine.communicate.sudo(cmd, &log_output) + end + end end end end From d2e1500c748051ecfd900f2cd3ebbcf7a4a38774 Mon Sep 17 00:00:00 2001 From: Chad Maloney Date: Mon, 5 Jan 2015 14:36:00 -0600 Subject: [PATCH 012/165] Review comments applied. Removed changelog. Changed showoutput to verbose. --- CHANGELOG.md | 2 -- plugins/synced_folders/rsync/helper.rb | 4 ++-- website/docs/source/v2/synced-folders/rsync.html.md | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8880478e9..53565b085 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,8 +40,6 @@ IMPROVEMENTS: - synced\_folders/nfs: Won't use `sudo` to write to /etc/exports if there are write privileges. [GH-2643] - synced\_folders/smb: Credentials from one SMB will be copied to the rest. [GH-4675] - - synced\_folders/rsync: Added rsync__showoutput option to echo rsync output - to console [GH-4201] BUG FIXES: diff --git a/plugins/synced_folders/rsync/helper.rb b/plugins/synced_folders/rsync/helper.rb index a0a8598e6..37a8a1ddd 100644 --- a/plugins/synced_folders/rsync/helper.rb +++ b/plugins/synced_folders/rsync/helper.rb @@ -121,7 +121,7 @@ module VagrantPlugins machine.ui.info(I18n.t( "vagrant.rsync_folder_excludes", excludes: excludes.inspect)) end - if opts.include?(:showoutput) + if opts.include?(:verbose) machine.ui.info(I18n.t("vagrant.rsync_showing_output")); end @@ -130,7 +130,7 @@ module VagrantPlugins machine.guest.capability(:rsync_pre, opts) end - if opts.include?(:showoutput) + if opts.include?(:verbose) command_opts[:notify] = [ :stdout, :stderr ]; r = Vagrant::Util::Subprocess.execute(*(command + [command_opts])) { |io_name,data| data.each_line { |line| machine.ui.info("rsync[#{io_name}] -> #{line}") } diff --git a/website/docs/source/v2/synced-folders/rsync.html.md b/website/docs/source/v2/synced-folders/rsync.html.md index d92c6d46c..3e97be86d 100644 --- a/website/docs/source/v2/synced-folders/rsync.html.md +++ b/website/docs/source/v2/synced-folders/rsync.html.md @@ -62,7 +62,7 @@ The rsync synced folder type accepts the following options: pattern. By default, the ".vagrant/" directory is excluded. We recommend excluding revision control directories such as ".git/" as well. -* `rsync__showoutput` (boolean) - If true, then the output from the rsync +* `rsync__verbose` (boolean) - If true, then the output from the rsync process will be echoed to the console. The output of rsync is subject to rsync__args of course. By default, this is false. From 0b6e65380a9894cf71ac8193a3f05fe18e36800a Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Sat, 17 Jan 2015 01:06:56 -0800 Subject: [PATCH 013/165] select a switch ased on a network_name --- plugins/providers/hyperv/action/import.rb | 46 +++++++++++++++-------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/plugins/providers/hyperv/action/import.rb b/plugins/providers/hyperv/action/import.rb index 468a55c57..acd7e2124 100644 --- a/plugins/providers/hyperv/action/import.rb +++ b/plugins/providers/hyperv/action/import.rb @@ -55,23 +55,39 @@ module VagrantPlugins switches = env[:machine].provider.driver.execute("get_switches.ps1", {}) raise Errors::NoSwitches if switches.empty? - switch = switches[0]["Name"] - if switches.length > 1 - env[:ui].detail(I18n.t("vagrant_hyperv.choose_switch") + "\n ") - switches.each_index do |i| - switch = switches[i] - env[:ui].detail("#{i+1}) #{switch["Name"]}") - end - env[:ui].detail(" ") + switch = nil + env[:machine].config.vm.networks.each do |type, opts| + next if type != :public_network && type != :private_network - switch = nil - while !switch - switch = env[:ui].ask("What switch would you like to use? ") - next if !switch - switch = switch.to_i - 1 - switch = nil if switch < 0 || switch >= switches.length + switchToFind = opts[:network_name] + + if switchToFind + puts "Looking for switch with name: #{switchToFind}" + switch = switches.find { |s| s["Name"].downcase == switchToFind.downcase }["Name"] + puts "Found switch: #{switch}" + end + end + + if switch.nil? + if switches.length > 1 + env[:ui].detail(I18n.t("vagrant_hyperv.choose_switch") + "\n ") + switches.each_index do |i| + switch = switches[i] + env[:ui].detail("#{i+1}) #{switch["Name"]}") + end + env[:ui].detail(" ") + + switch = nil + while !switch + switch = env[:ui].ask("What switch would you like to use? ") + next if !switch + switch = switch.to_i - 1 + switch = nil if switch < 0 || switch >= switches.length + end + switch = switches[switch]["Name"] + else + switch = switches[0]["Name"] end - switch = switches[switch]["Name"] end env[:ui].detail("Cloning virtual hard drive...") From 87195f8336d839ff3867cf1c092d85a1261f8290 Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Sat, 17 Jan 2015 11:39:32 -0800 Subject: [PATCH 014/165] use :bridge instead of network_name to align with site docs --- plugins/providers/hyperv/action/import.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/providers/hyperv/action/import.rb b/plugins/providers/hyperv/action/import.rb index acd7e2124..0b617ad54 100644 --- a/plugins/providers/hyperv/action/import.rb +++ b/plugins/providers/hyperv/action/import.rb @@ -59,7 +59,7 @@ module VagrantPlugins env[:machine].config.vm.networks.each do |type, opts| next if type != :public_network && type != :private_network - switchToFind = opts[:network_name] + switchToFind = opts[:bridge] if switchToFind puts "Looking for switch with name: #{switchToFind}" From 90719dc82f234655de86533d39c436219d97f9b9 Mon Sep 17 00:00:00 2001 From: Frank Baalbergen Date: Wed, 11 Feb 2015 15:35:05 +0100 Subject: [PATCH 015/165] vagrant duplicates >= eth2 when defining two config.vm.network :private_network When a vagrant box has two private network ips /etc/network/interfaces will duplicate eth2 and bigger. sed matches greedy, so the first #VAGRANT-END matches. This will result in: /etc/network/interfaces:29: interface eth2 declared allow-auto twice /sbin/ifup: couldn't read interfaces file "/etc/network/interfaces" --- plugins/guests/debian/cap/configure_networks.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/guests/debian/cap/configure_networks.rb b/plugins/guests/debian/cap/configure_networks.rb index 3cb896b15..cf416ec09 100644 --- a/plugins/guests/debian/cap/configure_networks.rb +++ b/plugins/guests/debian/cap/configure_networks.rb @@ -14,7 +14,7 @@ module VagrantPlugins # First, remove any previous network modifications # from the interface file. comm.sudo("sed -e '/^#VAGRANT-BEGIN/,$ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces.pre") - comm.sudo("sed -ne '/^#VAGRANT-END/,$ p' /etc/network/interfaces | tail -n +2 > /tmp/vagrant-network-interfaces.post") + comm.sudo("sed -ne '/^#VAGRANT-END/,$ p' /etc/network/interfaces | tac | sed -e '/^#VAGRANT-END/,$ d' | tac > /tmp/vagrant-network-interfaces.post") # Accumulate the configurations to add to the interfaces file as # well as what interfaces we're actually configuring since we use that From 6c2cc31926f8521e08387af8b0ad521650dd6b9b Mon Sep 17 00:00:00 2001 From: Tim Rensen Date: Wed, 25 Feb 2015 20:37:54 +0100 Subject: [PATCH 016/165] Fixed inaccurate downloading status message Importing a base box from the local file system currently outputs 'Downloading: file://...' which is more accurate now by presenting it as: 'Unpacking necessary files from: file://...'. Fixes #5386. --- lib/vagrant/action/builtin/box_add.rb | 9 ++++++++- templates/locales/en.yml | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/action/builtin/box_add.rb b/lib/vagrant/action/builtin/box_add.rb index deed8b9ef..fdfb4edc4 100644 --- a/lib/vagrant/action/builtin/box_add.rb +++ b/lib/vagrant/action/builtin/box_add.rb @@ -420,8 +420,15 @@ module Vagrant show_url = opts[:show_url] show_url ||= url + textLoading = "vagrant.box_downloading" + + # Adjust status message when 'downloading' a local box. + if(show_url.start_with?('file://')) + textLoading = "vagrant.box_unpacking" + end + env[:ui].detail(I18n.t( - "vagrant.box_downloading", + textLoading, url: show_url)) if File.file?(d.destination) env[:ui].info(I18n.t("vagrant.actions.box.download.resuming")) diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 155cd77dc..fa75c2a01 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -24,6 +24,8 @@ en: Downloading: %{url} box_download_error: |- Error downloading: %{message} + box_unpacking: |- + Unpacking necessary files from: %{url} box_expanding_url: |- URL: %{url} box_loading_metadata: |- From 51842623db19fc7bbbe8edce21dd21b3493f3874 Mon Sep 17 00:00:00 2001 From: edward010 Date: Thu, 26 Feb 2015 18:31:01 +0100 Subject: [PATCH 017/165] Improved the package error message The package error message will now show the actual package name if the package already existed. --- lib/vagrant/action/general/package.rb | 5 +++-- templates/locales/en.yml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/vagrant/action/general/package.rb b/lib/vagrant/action/general/package.rb index 99c0002ec..58991222c 100644 --- a/lib/vagrant/action/general/package.rb +++ b/lib/vagrant/action/general/package.rb @@ -29,9 +29,10 @@ module Vagrant def call(env) @env = env - + file_name = File.basename(@env["package.output"].to_s) + raise Errors::PackageOutputDirectory if File.directory?(tar_path) - raise Errors::PackageOutputExists if File.exist?(tar_path) + raise Errors::PackageOutputExists, file_name:file_name if File.exist?(tar_path) raise Errors::PackageRequiresDirectory if !env["package.directory"] || !File.directory?(env["package.directory"]) diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 155cd77dc..4ce7b28ec 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1749,7 +1749,7 @@ en: packaging: "Packaging additional file: %{file}" compressing: "Compressing package to: %{tar_path}" output_exists: |- - The specified file to save the package as already exists. Please + The specified file '%{file_name}' to save the package as already exists. Please remove this file or specify a different file name for outputting. output_is_directory: |- The specified output is a directory. Please specify a path including From 3b8bc2a433c14a1c8ce159f034a457180683b788 Mon Sep 17 00:00:00 2001 From: Dan Duvall Date: Wed, 4 Mar 2015 11:09:34 -0800 Subject: [PATCH 018/165] core: allow IO redirection of UI for testing Use of $stdin, $stdout, and $stderr globals makes testing difficult. By exposing the IO objects as writable attributes, input/output can be more easily simulated using StringIO or doubles. --- lib/vagrant/ui.rb | 23 ++++++++++++++++++----- test/unit/vagrant/ui_test.rb | 22 ++++++++++++++++++---- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/lib/vagrant/ui.rb b/lib/vagrant/ui.rb index a84448a1c..d26633f2f 100644 --- a/lib/vagrant/ui.rb +++ b/lib/vagrant/ui.rb @@ -21,9 +21,22 @@ module Vagrant # specific. See the implementation for more docs. attr_accessor :opts + # @return [IO] UI input. Defaults to `$stdin`. + attr_accessor :stdin + + # @return [IO] UI output. Defaults to `$stdout`. + attr_accessor :stdout + + # @return [IO] UI error output. Defaults to `$stderr`. + attr_accessor :stderr + def initialize @logger = Log4r::Logger.new("vagrant::ui::interface") @opts = {} + + @stdin = $stdin + @stdout = $stdout + @stderr = $stderr end def initialize_copy(original) @@ -132,7 +145,7 @@ module Vagrant super(message) # We can't ask questions when the output isn't a TTY. - raise Errors::UIExpectsTTY if !$stdin.tty? && !Vagrant::Util::Platform.cygwin? + raise Errors::UIExpectsTTY if !@stdin.tty? && !Vagrant::Util::Platform.cygwin? # Setup the options so that the new line is suppressed opts ||= {} @@ -144,11 +157,11 @@ module Vagrant say(:info, message, opts) input = nil - if opts[:echo] - input = $stdin.gets + if opts[:echo] || !@stdin.respond_to?(:noecho) + input = @stdin.gets else begin - input = $stdin.noecho(&:gets) + input = @stdin.noecho(&:gets) # Output a newline because without echo, the newline isn't # echoed either. @@ -206,7 +219,7 @@ module Vagrant # Determine the proper IO channel to send this message # to based on the type of the message - channel = type == :error || opts[:channel] == :error ? $stderr : $stdout + channel = type == :error || opts[:channel] == :error ? @stderr : @stdout # Output! We wrap this in a lock so that it safely outputs only # one line at a time. We wrap this in a thread because as of Ruby 2.0 diff --git a/test/unit/vagrant/ui_test.rb b/test/unit/vagrant/ui_test.rb index 537161a56..b4a7d7d89 100644 --- a/test/unit/vagrant/ui_test.rb +++ b/test/unit/vagrant/ui_test.rb @@ -40,23 +40,37 @@ describe Vagrant::UI::Basic do subject.output("foo", new_line: false) end - it "outputs to stdout" do + it "outputs to the assigned stdout" do + stdout = StringIO.new + subject.stdout = stdout + expect(subject).to receive(:safe_puts).with { |message, **opts| - expect(opts[:io]).to be($stdout) + expect(opts[:io]).to be(stdout) true } subject.output("foo") end - it "outputs to stderr for errors" do + it "outputs to stdout by default" do + expect(subject.stdout).to be($stdout) + end + + it "outputs to the assigned stderr for errors" do + stderr = StringIO.new + subject.stderr = stderr + expect(subject).to receive(:safe_puts).with { |message, **opts| - expect(opts[:io]).to be($stderr) + expect(opts[:io]).to be(stderr) true } subject.error("foo") end + + it "outputs to stderr for errors by default" do + expect(subject.stderr).to be($stderr) + end end context "#detail" do From 2f4a0af5d13e24e2a019130dd6a84ecb10f36b21 Mon Sep 17 00:00:00 2001 From: Jamezz Date: Wed, 4 Mar 2015 18:08:07 -0800 Subject: [PATCH 019/165] Fix issue #4152: Salt minion bootstrapping Copy the config after we know the installer exits. Also rev the installed version to 2014.7.1 (latest stable as of 3/4/2015) --- plugins/provisioners/salt/bootstrap-salt.ps1 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/plugins/provisioners/salt/bootstrap-salt.ps1 b/plugins/provisioners/salt/bootstrap-salt.ps1 index c8d7e7ab2..1b6d1f6ab 100644 --- a/plugins/provisioners/salt/bootstrap-salt.ps1 +++ b/plugins/provisioners/salt/bootstrap-salt.ps1 @@ -1,5 +1,5 @@ # Salt version to install -$version = '2014.1.10' +$version = '2014.7.1' # Create C:\tmp\ - if Vagrant doesn't upload keys and/or config it might not exist New-Item C:\tmp\ -ItemType directory | out-null @@ -13,11 +13,6 @@ if (Test-Path C:\tmp\minion.pem) { cp C:\tmp\minion.pub C:\salt\conf\pki\minion\ } -# Check if minion config has been uploaded -if (Test-Path C:\tmp\minion) { - cp C:\tmp\minion C:\salt\conf\ -} - # Detect architecture if ([IntPtr]::Size -eq 4) { $arch = "win32" @@ -34,7 +29,13 @@ $webclient.DownloadFile($url, $file) # Install minion silently Write-Host "Installing Salt minion..." -C:\tmp\salt.exe /S +#Wait for process to exit before continuing... +C:\tmp\salt.exe /S | Out-Null + +# Check if minion config has been uploaded +if (Test-Path C:\tmp\minion) { + cp C:\tmp\minion C:\salt\conf\ +} # Wait for salt-minion service to be registered before trying to start it $service = Get-Service salt-minion -ErrorAction SilentlyContinue From 71c40bdf6a03a2fb1d25ca39952d9f3b05cac213 Mon Sep 17 00:00:00 2001 From: Jamezz Date: Fri, 6 Mar 2015 13:14:11 -0800 Subject: [PATCH 020/165] File architecture string should be x86 As of 2014.7.0, Salt has changed their file naming for 32-bit from win32 to x86. --- plugins/provisioners/salt/bootstrap-salt.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/provisioners/salt/bootstrap-salt.ps1 b/plugins/provisioners/salt/bootstrap-salt.ps1 index 1b6d1f6ab..75dcc9462 100644 --- a/plugins/provisioners/salt/bootstrap-salt.ps1 +++ b/plugins/provisioners/salt/bootstrap-salt.ps1 @@ -15,7 +15,7 @@ if (Test-Path C:\tmp\minion.pem) { # Detect architecture if ([IntPtr]::Size -eq 4) { - $arch = "win32" + $arch = "x86" } else { $arch = "AMD64" } From 291db96510af6687569536e25150fb087737f89a Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Thu, 12 Mar 2015 15:25:40 -0500 Subject: [PATCH 021/165] communicators/winrm: don't stop task on idle end StopOnIdleEnd was set in the task definition for elevated/privileged windows guest scripts. This setting: > specifies that the task stops when the idle condition ceases to be true [1] The "idle condition" is something that Windows periodically checks for, and it's defined by a bunch of criteria like user presence/absence, CPU / IO idle time, etc. [2] Telling our provisioner to stop the task if the "idle condition" ceases to be true is a recipe for some sporadically stopped tasks, which seems like precisely the behavior being reported in #5362. I'm pretty sure this fixes #5362 [1] https://msdn.microsoft.com/en-us/library/cc248332.aspx [2] https://msdn.microsoft.com/en-us/library/windows/desktop/aa383561%28v=vs.85%29.aspx --- plugins/communicators/winrm/scripts/elevated_shell.ps1.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/communicators/winrm/scripts/elevated_shell.ps1.erb b/plugins/communicators/winrm/scripts/elevated_shell.ps1.erb index 454e5e874..923f034bb 100644 --- a/plugins/communicators/winrm/scripts/elevated_shell.ps1.erb +++ b/plugins/communicators/winrm/scripts/elevated_shell.ps1.erb @@ -27,7 +27,7 @@ $task_xml = @' false false - true + false false true From 992c148169ec1881868933aa8448e1198dcfeabf Mon Sep 17 00:00:00 2001 From: Ben Jansen Date: Fri, 13 Mar 2015 11:42:55 -0700 Subject: [PATCH 022/165] Ignore Windows NICs with nil :net_connection_id When upping a Win XP box, vagrant found a lot of "virtual" network connections that did not have DHCP enabled, and tried to configure them for DHCP. This did not work because their :net_connection_id is nil. Ignoring these network connections enabled the XP box to be upped. --- plugins/guests/windows/cap/configure_networks.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/guests/windows/cap/configure_networks.rb b/plugins/guests/windows/cap/configure_networks.rb index 8130cef77..8e766a319 100644 --- a/plugins/guests/windows/cap/configure_networks.rb +++ b/plugins/guests/windows/cap/configure_networks.rb @@ -64,7 +64,9 @@ module VagrantPlugins guest_network.network_adapters.each do |nic| @@logger.debug("nic: #{nic.inspect}") naked_mac = nic[:mac_address].gsub(':','') - if driver_mac_address[naked_mac] + # If the :net_connection_id entry is nil then it is probably a virtual connection + # and should be ignored. + if driver_mac_address[naked_mac] && !nic[:net_connection_id].nil? vm_interface_map[driver_mac_address[naked_mac]] = { net_connection_id: nic[:net_connection_id], mac_address: naked_mac, From 21538fd64f201437e9883b234f43655bf01bb383 Mon Sep 17 00:00:00 2001 From: follower Date: Mon, 16 Mar 2015 03:17:56 +1300 Subject: [PATCH 023/165] Fix known/kownn typo --- website/docs/source/v2/provisioning/ansible.html.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/source/v2/provisioning/ansible.html.md b/website/docs/source/v2/provisioning/ansible.html.md index 10fd1fc6d..21d469a97 100644 --- a/website/docs/source/v2/provisioning/ansible.html.md +++ b/website/docs/source/v2/provisioning/ansible.html.md @@ -218,7 +218,7 @@ by the sudo command. * `ansible.start_at_task` can be set to a string corresponding to the task name where the playbook provision will start. * `ansible.raw_arguments` can be set to an array of strings corresponding to a list of `ansible-playbook` arguments (e.g. `['--check', '-M /my/modules']`). It is an *unsafe wildcard* that can be used to apply Ansible options that are not (yet) supported by this Vagrant provisioner. As of Vagrant 1.7, `raw_arguments` has the highest priority and its values can potentially override or break other Vagrant settings. * `ansible.raw_ssh_args` can be set to an array of strings corresponding to a list of OpenSSH client parameters (e.g. `['-o ControlMaster=no']`). It is an *unsafe wildcard* that can be used to pass additional SSH settings to Ansible via `ANSIBLE_SSH_ARGS` environment variable. -* `ansible.host_key_checking` can be set to `true` which will enable host key checking. As of Vagrant 1.5, the default value is `false` and as of Vagrant 1.7 the user kownn host file (e.g. `~/.ssh/known_hosts`) is no longer read nor modified. In other words: by default, the Ansible provisioner behaves the same as Vagrant native commands (e.g `vagrant ssh`). +* `ansible.host_key_checking` can be set to `true` which will enable host key checking. As of Vagrant 1.5, the default value is `false` and as of Vagrant 1.7 the user known host file (e.g. `~/.ssh/known_hosts`) is no longer read nor modified. In other words: by default, the Ansible provisioner behaves the same as Vagrant native commands (e.g `vagrant ssh`). ## Tips and Tricks From 7d17574a76e97ec5548dce44a4d13e43886eaa6d Mon Sep 17 00:00:00 2001 From: Jean-Francois Bibeau Date: Wed, 18 Mar 2015 15:29:43 -0400 Subject: [PATCH 024/165] changing windows/virtualbox shared path names to UNC format to allow > 256 characters --- plugins/providers/virtualbox/driver/version_4_3.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/providers/virtualbox/driver/version_4_3.rb b/plugins/providers/virtualbox/driver/version_4_3.rb index 2d257a8c1..81f2252b6 100644 --- a/plugins/providers/virtualbox/driver/version_4_3.rb +++ b/plugins/providers/virtualbox/driver/version_4_3.rb @@ -499,7 +499,7 @@ module VagrantPlugins args = ["--name", folder[:name], "--hostpath", - folder[:hostpath]] + Vagrant::Util::Platform.windows? ? ("//?/" + File.expand_path(folder[:hostpath])).gsub("/","\\") : folder[:hostpath]] args << "--transient" if folder.key?(:transient) && folder[:transient] # Enable symlinks on the shared folder From b43413525fea4fd38a80fc9b6f3687ed6ac759b3 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 23 Mar 2015 13:11:54 +0100 Subject: [PATCH 025/165] guests/freebsd: fix call of set -i : missing extension Sed on freebsd seems to be mores strict than on other platforms about use of -i: the extension is not optional. Signed-off-by: Michael Adam --- plugins/guests/freebsd/cap/remove_public_key.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/guests/freebsd/cap/remove_public_key.rb b/plugins/guests/freebsd/cap/remove_public_key.rb index 13abc864b..8d5526ca4 100644 --- a/plugins/guests/freebsd/cap/remove_public_key.rb +++ b/plugins/guests/freebsd/cap/remove_public_key.rb @@ -11,7 +11,7 @@ module VagrantPlugins machine.communicate.tap do |comm| if comm.test("test -f ~/.ssh/authorized_keys") comm.execute( - "sed -i '/^.*#{contents}.*$/d' ~/.ssh/authorized_keys") + "sed -i .bak '/^.*#{contents}.*$/d' ~/.ssh/authorized_keys") end end end From 0b737b86839f5c2fde5547cd464cb94095536a97 Mon Sep 17 00:00:00 2001 From: Mattias Appelgren Date: Wed, 25 Mar 2015 15:51:23 +0100 Subject: [PATCH 026/165] contrib/bash: Auto-complete VMs for up command --- contrib/bash/completion.sh | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/contrib/bash/completion.sh b/contrib/bash/completion.sh index e21dc8dcf..2b201d1ba 100644 --- a/contrib/bash/completion.sh +++ b/contrib/bash/completion.sh @@ -70,8 +70,13 @@ _vagrant() { return 0 ;; "up") + vagrant_state_file=$(__vagrantinvestigate) || return 1 + if [[ -d $vagrant_state_file ]] + then + local vm_list=$(find $vagrant_state_file/machines -mindepth 1 -maxdepth 1 -type d -exec basename {} \;) + fi local up_commands="--no-provision" - COMPREPLY=($(compgen -W "${up_commands}" -- ${cur})) + COMPREPLY=($(compgen -W "${up_commands} ${vm_list}" -- ${cur})) return 0 ;; "ssh"|"provision"|"reload"|"halt"|"suspend"|"resume"|"ssh-config") @@ -107,18 +112,32 @@ _vagrant() { if [ $COMP_CWORD == 3 ] then action="${COMP_WORDS[COMP_CWORD-2]}" - if [ $action == 'box' ] - then - case "$prev" in + case "$action" in + "up") + if [ "$prev" == "--no-provision" ] + then + if [[ -d $vagrant_state_file ]] + then + local vm_list=$(find $vagrant_state_file/machines -mindepth 1 -maxdepth 1 -type d -exec basename {} \;) + fi + COMPREPLY=($(compgen -W "${vm_list}" -- ${cur})) + return 0 + fi + ;; + "box") + case "$prev" in "remove"|"repackage") local box_list=$(find "${VAGRANT_HOME:-${HOME}/.vagrant.d}/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;) COMPREPLY=($(compgen -W "${box_list}" -- ${cur})) return 0 ;; *) - ;; - esac - fi + ;; + esac + ;; + *) + ;; + esac fi } From e745436df3c64537570953d4d815eaec840da46d Mon Sep 17 00:00:00 2001 From: Mario Rodas Date: Sat, 28 Mar 2015 19:05:54 -0500 Subject: [PATCH 027/165] provisioners/ansible: disable color if Vagrant has no color [GH-5531] --- plugins/provisioners/ansible/provisioner.rb | 3 ++- .../unit/plugins/provisioners/ansible/provisioner_test.rb | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/provisioners/ansible/provisioner.rb b/plugins/provisioners/ansible/provisioner.rb index 9e2cb155b..6b6ea2d87 100644 --- a/plugins/provisioners/ansible/provisioner.rb +++ b/plugins/provisioners/ansible/provisioner.rb @@ -68,9 +68,10 @@ module VagrantPlugins # Some Ansible options must be passed as environment variables, # as there is no equivalent command line arguments - "ANSIBLE_FORCE_COLOR" => "true", "ANSIBLE_HOST_KEY_CHECKING" => "#{config.host_key_checking}", } + env["ANSIBLE_NOCOLOR"] = "true" unless @machine.env.ui.is_a?(Vagrant::UI::Colored) + # ANSIBLE_SSH_ARGS is required for Multiple SSH keys, SSH forwarding and custom SSH settings env["ANSIBLE_SSH_ARGS"] = ansible_ssh_args unless ansible_ssh_args.empty? diff --git a/test/unit/plugins/provisioners/ansible/provisioner_test.rb b/test/unit/plugins/provisioners/ansible/provisioner_test.rb index 05fa8fae3..5ed6f80e5 100644 --- a/test/unit/plugins/provisioners/ansible/provisioner_test.rb +++ b/test/unit/plugins/provisioners/ansible/provisioner_test.rb @@ -110,7 +110,7 @@ VF expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o UserKnownHostsFile=/dev/null") end expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to include("-o IdentitiesOnly=yes") - expect(cmd_opts[:env]['ANSIBLE_FORCE_COLOR']).to eql("true") + expect(cmd_opts[:env]['ANSIBLE_NOCOLOR']).to eql("true") expect(cmd_opts[:env]['ANSIBLE_HOST_KEY_CHECKING']).to eql(expected_host_key_checking.to_s) expect(cmd_opts[:env]['PYTHONUNBUFFERED']).to eql(1) } @@ -468,7 +468,7 @@ VF it "shows the ansible-playbook command" do expect(machine.env.ui).to receive(:detail).with { |full_command| - expect(full_command).to eq("PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --private-key=/path/to/my/key --user=testuser --connection=ssh --timeout=30 --limit='machine1' --inventory-file=#{generated_inventory_dir} playbook.yml") + expect(full_command).to eq("PYTHONUNBUFFERED=1 ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_NOCOLOR=true ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --private-key=/path/to/my/key --user=testuser --connection=ssh --timeout=30 --limit='machine1' --inventory-file=#{generated_inventory_dir} playbook.yml") } end end @@ -483,7 +483,7 @@ VF it "shows the ansible-playbook command" do expect(machine.env.ui).to receive(:detail).with { |full_command| - expect(full_command).to eq("PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --private-key=/path/to/my/key --user=testuser --connection=ssh --timeout=30 --limit='machine1' --inventory-file=#{generated_inventory_dir} -v playbook.yml") + expect(full_command).to eq("PYTHONUNBUFFERED=1 ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_NOCOLOR=true ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --private-key=/path/to/my/key --user=testuser --connection=ssh --timeout=30 --limit='machine1' --inventory-file=#{generated_inventory_dir} -v playbook.yml") } end end @@ -541,7 +541,7 @@ VF it "shows the ansible-playbook command, with additional quotes when required" do expect(machine.env.ui).to receive(:detail).with { |full_command| - expect(full_command).to eq("PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=true ANSIBLE_SSH_ARGS='-o IdentitiesOnly=yes -o IdentityFile=/my/key2 -o ForwardAgent=yes -o ControlMaster=no -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --private-key=/my/key1 --user=testuser --connection=ssh --timeout=30 --limit='machine*:&vagrant:!that_one' --inventory-file=#{generated_inventory_dir} --extra-vars=@#{File.expand_path(__FILE__)} --sudo --sudo-user=deployer -vvv --ask-sudo-pass --ask-vault-pass --vault-password-file=#{File.expand_path(__FILE__)} --tags=db,www --skip-tags=foo,bar --start-at-task='an awesome task' --why-not --su-user=foot --ask-su-pass --limit='all' playbook.yml") + expect(full_command).to eq("PYTHONUNBUFFERED=1 ANSIBLE_HOST_KEY_CHECKING=true ANSIBLE_NOCOLOR=true ANSIBLE_SSH_ARGS='-o IdentitiesOnly=yes -o IdentityFile=/my/key2 -o ForwardAgent=yes -o ControlMaster=no -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --private-key=/my/key1 --user=testuser --connection=ssh --timeout=30 --limit='machine*:&vagrant:!that_one' --inventory-file=#{generated_inventory_dir} --extra-vars=@#{File.expand_path(__FILE__)} --sudo --sudo-user=deployer -vvv --ask-sudo-pass --ask-vault-pass --vault-password-file=#{File.expand_path(__FILE__)} --tags=db,www --skip-tags=foo,bar --start-at-task='an awesome task' --why-not --su-user=foot --ask-su-pass --limit='all' playbook.yml") } end end From 1a2f403d0c73a09ecb5151b2c2b65a02f7341f58 Mon Sep 17 00:00:00 2001 From: Tim Rensen Date: Mon, 30 Mar 2015 12:41:19 +0200 Subject: [PATCH 028/165] Fixed VirtualBox's error message on 'private_network' --- templates/locales/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 155cd77dc..f5de5b2c0 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -285,7 +285,7 @@ en: id_in_pre_import: |- The ':id' parameter is not available in "pre-import" customizations. intnet_on_bad_type: |- - VirtualBox internal networks can only be enabled on "private_networks" + VirtualBox internal networks can only be enabled on "private_network" invalid_event: |- %{event} is not a valid event for customization. Valid events are: %{valid_events} From fd557592d4f6fb96055837b6ce6fb132f8a84d91 Mon Sep 17 00:00:00 2001 From: ssugar Date: Mon, 30 Mar 2015 20:00:16 +0700 Subject: [PATCH 029/165] only set EFI secure boot for gen 2 machines in hyperv provider --- plugins/providers/hyperv/scripts/import_vm.ps1 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/providers/hyperv/scripts/import_vm.ps1 b/plugins/providers/hyperv/scripts/import_vm.ps1 index 791daecd7..3e8664eb2 100644 --- a/plugins/providers/hyperv/scripts/import_vm.ps1 +++ b/plugins/providers/hyperv/scripts/import_vm.ps1 @@ -136,11 +136,14 @@ $vm | Set-VM @more_vm_params -Passthru # Add drives to the virtual machine $controllers = Select-Xml -xml $vmconfig -xpath "//*[starts-with(name(.),'controller')]" -# Set EFI secure boot -if ($secure_boot_enabled -eq "True") { - Set-VMFirmware -VM $vm -EnableSecureBoot On -} else { - Set-VMFirmware -VM $vm -EnableSecureBoot Off +# Only set EFI secure boot for Gen 2 machines, not gen 1 +if ($generation -ne 1) { + # Set EFI secure boot + if ($secure_boot_enabled -eq "True") { + Set-VMFirmware -VM $vm -EnableSecureBoot On + } else { + Set-VMFirmware -VM $vm -EnableSecureBoot Off + } } # A regular expression pattern to pull the number from controllers From 91752bcd1a512cb30fda78a685f82c6e2be89754 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Mon, 30 Mar 2015 10:18:38 -0400 Subject: [PATCH 030/165] Update CHANGELOG --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd657fa48..979ad1cf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ BUG FIXES: space on some systems. [GH-5302] - providers/hyperv: allow users to configure memory, cpu count, and vmname [GH-5183] - providers/hyperv: import respects secure boot. [GH-5209] + - providers/hyperv: only set EFI secure boot for gen 2 machines [GH-5538] - providers/virtualbox: read netmask from dhcpservers [GH-5233] - providers/virtualbox: Fix exception when VirtualBox version is empty. [GH-5308] - provisioners/ansible: fix SSH settings to support more than 5 ssh keys [GH-5017] @@ -39,7 +40,8 @@ BUG FIXES: - provisioners/chef-zero: support more chef-zero/local mode attributes [GH-5339] - provisioners/docker: use docker.com instead of docker.io [GH-5216] - pushes/atlas: send additional box metadata [GH-5283] - - synced\_folders/rsync: Add `IdentitiesOnly=yes` to the rsync command. [GH-5175] + - synced\_folders/rsync: add `IdentitiesOnly=yes` to the rsync command. [GH-5175] + - virtualbox/config: fix misleading error message for private_network [GH-5536, GH-5418] ## 1.7.2 (January 6, 2015) From f5ee8b8b7d25883e2715de630e03dcb550da3958 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Mon, 30 Mar 2015 10:19:02 -0400 Subject: [PATCH 031/165] Ignore vendor/ --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 801132d2d..b1274f4d0 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ pkg/* tags /Gemfile.lock test/tmp/ +vendor/ # Documentation _site/* From 9e23d16d9c07d5544280d58e218c6d99ce7c1366 Mon Sep 17 00:00:00 2001 From: Volodymyr Babchynskyy Date: Mon, 30 Mar 2015 08:37:29 -0600 Subject: [PATCH 032/165] merged vlan_id changes for hyperv by tomassrnka --- plugins/providers/hyperv/action.rb | 2 ++ .../providers/hyperv/action/net_set_vlan.rb | 19 +++++++++++++++++++ plugins/providers/hyperv/config.rb | 7 +++++++ plugins/providers/hyperv/driver.rb | 4 ++++ .../hyperv/scripts/set_network_vlan.ps1 | 18 ++++++++++++++++++ .../plugins/providers/hyperv/config_test.rb | 12 ++++++++++++ 6 files changed, 62 insertions(+) create mode 100644 plugins/providers/hyperv/action/net_set_vlan.rb create mode 100644 plugins/providers/hyperv/scripts/set_network_vlan.ps1 diff --git a/plugins/providers/hyperv/action.rb b/plugins/providers/hyperv/action.rb index 49e2be33f..64fbec180 100644 --- a/plugins/providers/hyperv/action.rb +++ b/plugins/providers/hyperv/action.rb @@ -116,6 +116,7 @@ module VagrantPlugins end b2.use Provision + b2.use NetSetVLan b2.use StartInstance b2.use WaitForIPAddress b2.use WaitForCommunicator, [:running] @@ -216,6 +217,7 @@ module VagrantPlugins autoload :StopInstance, action_root.join('stop_instance') autoload :SuspendVM, action_root.join("suspend_vm") autoload :WaitForIPAddress, action_root.join("wait_for_ip_address") + autoload :NetSetVLan, action_root.join("net_set_vlan") autoload :MessageWillNotDestroy, action_root.join("message_will_not_destroy") end end diff --git a/plugins/providers/hyperv/action/net_set_vlan.rb b/plugins/providers/hyperv/action/net_set_vlan.rb new file mode 100644 index 000000000..9ce26d324 --- /dev/null +++ b/plugins/providers/hyperv/action/net_set_vlan.rb @@ -0,0 +1,19 @@ +module VagrantPlugins + module HyperV + module Action + class NetSetVLan + def initialize(app, env) + @app = app + end + + def call(env) + vlan_id = env[:machine].provider_config.vlan_id + + env[:ui].info("[Settings] [Network Adapter] Setting Vlan ID to: #{vlan_id}") + env[:machine].provider.driver.net_set_vlan(vlan_id) + @app.call(env) + end + end + end + end +end diff --git a/plugins/providers/hyperv/config.rb b/plugins/providers/hyperv/config.rb index 89b51c0a6..55c1be673 100644 --- a/plugins/providers/hyperv/config.rb +++ b/plugins/providers/hyperv/config.rb @@ -13,12 +13,18 @@ module VagrantPlugins attr_accessor :cpus attr_accessor :vmname + # The default VLAN ID for network interface for the virtual machine. + # + # @return [Integer] + attr_accessor :vlan_id + def initialize @ip_address_timeout = UNSET_VALUE @memory = UNSET_VALUE @maxmemory = UNSET_VALUE @cpus = UNSET_VALUE @vmname = UNSET_VALUE + @vlan_id = UNSET_VALUE end def finalize! @@ -29,6 +35,7 @@ module VagrantPlugins @maxmemory = nil if @maxmemory == UNSET_VALUE @cpus = nil if @cpus == UNSET_VALUE @vmname = nil if @vmname == UNSET_VALUE + @vlan_id = 0 if @vlan_id == UNSET_VALUE end def validate(machine) diff --git a/plugins/providers/hyperv/driver.rb b/plugins/providers/hyperv/driver.rb index 9f11881e6..db99d5dfe 100644 --- a/plugins/providers/hyperv/driver.rb +++ b/plugins/providers/hyperv/driver.rb @@ -77,6 +77,10 @@ module VagrantPlugins execute('import_vm.ps1', options) end + def net_set_vlan(vlan_id) + execute("set_network_vlan.ps1", { VmId: vm_id, VlanId: vlan_id }) + end + protected def execute_powershell(path, options, &block) diff --git a/plugins/providers/hyperv/scripts/set_network_vlan.ps1 b/plugins/providers/hyperv/scripts/set_network_vlan.ps1 new file mode 100644 index 000000000..a2b271b91 --- /dev/null +++ b/plugins/providers/hyperv/scripts/set_network_vlan.ps1 @@ -0,0 +1,18 @@ +param ( + [string]$VmId = $(throw "-VmId is required."), + [int]$VlanId = $(throw "-VlanId ") + ) + +# Include the following modules +$presentDir = Split-Path -parent $PSCommandPath +$modules = @() +$modules += $presentDir + "\utils\write_messages.ps1" +forEach ($module in $modules) { . $module } + +try { + $vm = Get-VM -Id $VmId -ErrorAction "stop" + Set-VMNetworkAdapterVlan $vm -Access -Vlanid $VlanId +} +catch { + Write-Error-Message "Failed to set VM's Vlan ID $_" +} diff --git a/test/unit/plugins/providers/hyperv/config_test.rb b/test/unit/plugins/providers/hyperv/config_test.rb index a3c46c619..4bdc2daa3 100644 --- a/test/unit/plugins/providers/hyperv/config_test.rb +++ b/test/unit/plugins/providers/hyperv/config_test.rb @@ -13,6 +13,18 @@ describe VagrantPlugins::HyperV::Config do subject.finalize! expect(subject.ip_address_timeout).to eq(120) end + + describe "#vlan_id" do + it "can be set" do + subject.vlan_id = 100 + subject.finalize! + expect(subject.vlan_id).to eq(100) + end + + it "defaults to a number" do + subject.finalize! + expect(subject.vlan_id).to eq(0) + end end describe "#vmname" do it "can be set" do From 9a0aab4bd783240d1938026ec4a4d4f355fe49cc Mon Sep 17 00:00:00 2001 From: Volodymyr Babchynskyy Date: Mon, 30 Mar 2015 10:17:29 -0600 Subject: [PATCH 033/165] Improved behavior for case if vlan_id is not set --- .../providers/hyperv/action/net_set_vlan.rb | 7 +++--- plugins/providers/hyperv/config.rb | 23 +++++++------------ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/plugins/providers/hyperv/action/net_set_vlan.rb b/plugins/providers/hyperv/action/net_set_vlan.rb index 9ce26d324..c65f5a7cb 100644 --- a/plugins/providers/hyperv/action/net_set_vlan.rb +++ b/plugins/providers/hyperv/action/net_set_vlan.rb @@ -8,9 +8,10 @@ module VagrantPlugins def call(env) vlan_id = env[:machine].provider_config.vlan_id - - env[:ui].info("[Settings] [Network Adapter] Setting Vlan ID to: #{vlan_id}") - env[:machine].provider.driver.net_set_vlan(vlan_id) + if vlan_id + env[:ui].info("[Settings] [Network Adapter] Setting Vlan ID to: #{vlan_id}") + env[:machine].provider.driver.net_set_vlan(vlan_id) + end @app.call(env) end end diff --git a/plugins/providers/hyperv/config.rb b/plugins/providers/hyperv/config.rb index 55c1be673..fe247a242 100644 --- a/plugins/providers/hyperv/config.rb +++ b/plugins/providers/hyperv/config.rb @@ -3,20 +3,13 @@ require "vagrant" module VagrantPlugins module HyperV class Config < Vagrant.plugin("2", :config) - # The timeout to wait for an IP address when booting the machine, - # in seconds. - # - # @return [Integer] - attr_accessor :ip_address_timeout - attr_accessor :memory - attr_accessor :maxmemory - attr_accessor :cpus - attr_accessor :vmname - - # The default VLAN ID for network interface for the virtual machine. - # - # @return [Integer] - attr_accessor :vlan_id + + attr_accessor :ip_address_timeout # Time to wait for an IP address when booting, in seconds @return [Integer] + attr_accessor :memory # Memory size in mb @return [Integer] + attr_accessor :maxmemory # Maximal memory size in mb enables dynamical memory allocation @return [Integer] + attr_accessor :cpus # Number of cpu's @return [Integer] + attr_accessor :vmname # Name that will be shoen in Hyperv Manager @return [String] + attr_accessor :vlan_id # VLAN ID for network interface for the virtual machine. @return [Integer] def initialize @ip_address_timeout = UNSET_VALUE @@ -35,7 +28,7 @@ module VagrantPlugins @maxmemory = nil if @maxmemory == UNSET_VALUE @cpus = nil if @cpus == UNSET_VALUE @vmname = nil if @vmname == UNSET_VALUE - @vlan_id = 0 if @vlan_id == UNSET_VALUE + @vlan_id = nil if @vlan_id == UNSET_VALUE end def validate(machine) From b752805d537133c1614ecff91696b409d75a7a12 Mon Sep 17 00:00:00 2001 From: Volodymyr Babchynskyy Date: Mon, 30 Mar 2015 10:29:06 -0600 Subject: [PATCH 034/165] Vlan_id configuration option description added to documentation --- website/docs/source/v2/hyperv/configuration.html.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/docs/source/v2/hyperv/configuration.html.md b/website/docs/source/v2/hyperv/configuration.html.md index 18ed9e89c..b9f255181 100644 --- a/website/docs/source/v2/hyperv/configuration.html.md +++ b/website/docs/source/v2/hyperv/configuration.html.md @@ -17,6 +17,8 @@ you may set. A complete reference is shown below: * `maxmemory` (integer) - Number of MegaBytes maximal allowed to allocate for VM This parameter is switch on Dynamic Allocation of memory. Defaults is taken from box image XML. + * `vlan_id` (integer) - Number of Vlan ID for your guest network interface + Defaults is not defined, vlan configuration will be untouched if not set. * `ip_address_timeout` (integer) - The time in seconds to wait for the virtual machine to report an IP address. This defaults to 120 seconds. This may have to be increased if your VM takes longer to boot. From 7628ca71e7a6cf449e3c7ea258ed366bfffc94e6 Mon Sep 17 00:00:00 2001 From: Volodymyr Babchynskyy Date: Mon, 30 Mar 2015 10:57:11 -0600 Subject: [PATCH 035/165] Removed default dependences to number --- test/unit/plugins/providers/hyperv/config_test.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/unit/plugins/providers/hyperv/config_test.rb b/test/unit/plugins/providers/hyperv/config_test.rb index 4bdc2daa3..564473873 100644 --- a/test/unit/plugins/providers/hyperv/config_test.rb +++ b/test/unit/plugins/providers/hyperv/config_test.rb @@ -20,11 +20,6 @@ describe VagrantPlugins::HyperV::Config do subject.finalize! expect(subject.vlan_id).to eq(100) end - - it "defaults to a number" do - subject.finalize! - expect(subject.vlan_id).to eq(0) - end end describe "#vmname" do it "can be set" do From 8e6db0015f5a42ca9e3795e6cf72fde480acfa4c Mon Sep 17 00:00:00 2001 From: Volodymyr Babchynskyy Date: Mon, 30 Mar 2015 11:01:38 -0600 Subject: [PATCH 036/165] Fixed typo --- test/unit/plugins/providers/hyperv/config_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/plugins/providers/hyperv/config_test.rb b/test/unit/plugins/providers/hyperv/config_test.rb index 564473873..e8595aef7 100644 --- a/test/unit/plugins/providers/hyperv/config_test.rb +++ b/test/unit/plugins/providers/hyperv/config_test.rb @@ -13,7 +13,7 @@ describe VagrantPlugins::HyperV::Config do subject.finalize! expect(subject.ip_address_timeout).to eq(120) end - + end describe "#vlan_id" do it "can be set" do subject.vlan_id = 100 From 9d50f72df364096c3854481c2d1fa62ba55a4e85 Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Sun, 22 Mar 2015 17:47:55 -0700 Subject: [PATCH 037/165] For SMB on Linux guests, specify the user's domain as a separate parameter to the mount command. This is more reliable than passing user@domain as the username. This is not needed for SMB on Windows guests as they expect the user@domain form. This does not change how it is configured in the Vagrantfile. Fixes #3620 --- .../linux/cap/mount_smb_shared_folder.rb | 6 ++- .../linux/cap/mount_shared_folder_test.rb | 44 +++++++++++++++++++ .../docs/source/v2/synced-folders/smb.html.md | 4 +- 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 test/unit/plugins/guests/linux/cap/mount_shared_folder_test.rb diff --git a/plugins/guests/linux/cap/mount_smb_shared_folder.rb b/plugins/guests/linux/cap/mount_smb_shared_folder.rb index 424982520..ca14cf148 100644 --- a/plugins/guests/linux/cap/mount_smb_shared_folder.rb +++ b/plugins/guests/linux/cap/mount_smb_shared_folder.rb @@ -27,10 +27,14 @@ module VagrantPlugins smb_password = Shellwords.shellescape(options[:smb_password]) + # If a domain is provided in the username, separate it + username, domain = (options[:smb_username] || '').split('@', 2) + options[:mount_options] ||= [] options[:mount_options] << "sec=ntlm" - options[:mount_options] << "username=#{options[:smb_username]}" + options[:mount_options] << "username=#{username}" options[:mount_options] << "pass=#{smb_password}" + options[:mount_options] << "domain=#{domain}" if domain # First mount command uses getent to get the group mount_options = "-o uid=#{mount_uid},gid=#{mount_gid}" diff --git a/test/unit/plugins/guests/linux/cap/mount_shared_folder_test.rb b/test/unit/plugins/guests/linux/cap/mount_shared_folder_test.rb new file mode 100644 index 000000000..4d591e7fb --- /dev/null +++ b/test/unit/plugins/guests/linux/cap/mount_shared_folder_test.rb @@ -0,0 +1,44 @@ +require File.expand_path("../../../../../base", __FILE__) + +describe "VagrantPlugins::GuestLinux::Cap::MountSharedFolder" do + let(:machine) { double("machine") } + let(:communicator) { VagrantTests::DummyCommunicator::Communicator.new(machine) } + let(:guest) { double("guest") } + + before do + allow(machine).to receive(:guest).and_return(guest) + allow(machine).to receive(:communicate).and_return(communicator) + allow(guest).to receive(:capability).and_return(nil) + end + + describe "smb" do + let(:described_class) do + VagrantPlugins::GuestLinux::Plugin.components.guest_capabilities[:linux].get(:mount_smb_shared_folder) + end + + describe ".mount_shared_folder" do + describe "with a domain" do + let(:mount_command) { "mount -t cifs -o uid=`id -u `,gid=`getent group | cut -d: -f3`,sec=ntlm,username=user,pass=pass,domain=domain //host/name " } + before do + communicator.expect_command mount_command + communicator.stub_command mount_command, exit_code: 0 + end + after { communicator.verify_expectations! } + it "should call mount with correct args" do + described_class.mount_smb_shared_folder(machine, 'name', 'guestpath', {:smb_username => "user@domain", :smb_password => "pass", :smb_host => "host"}) + end + end + describe "without a domain" do + let(:mount_command) { "mount -t cifs -o uid=`id -u `,gid=`getent group | cut -d: -f3`,sec=ntlm,username=user,pass=pass //host/name " } + before do + communicator.expect_command mount_command + communicator.stub_command mount_command, exit_code: 0 + end + after { communicator.verify_expectations! } + it "should call mount with correct args" do + described_class.mount_smb_shared_folder(machine, 'name', 'guestpath', {:smb_username => "user", :smb_password => "pass", :smb_host => "host"}) + end + end + end + end +end \ No newline at end of file diff --git a/website/docs/source/v2/synced-folders/smb.html.md b/website/docs/source/v2/synced-folders/smb.html.md index 130a7dabf..b79ff50aa 100644 --- a/website/docs/source/v2/synced-folders/smb.html.md +++ b/website/docs/source/v2/synced-folders/smb.html.md @@ -49,8 +49,8 @@ The SMB synced folder type has a variety of options it accepts: * `smb_username` (string) - The username used for authentication to mount the SMB mount. This is the username to access the mount, _not_ the username of the account where the folder is being mounted to. This is usually your - Windows username. If this isn't specified, Vagrant will prompt you for - it. + Windows username. If you sign into a domain, specify it as `user@domain`. + If this option isn't specified, Vagrant will prompt you for it. ## Example From e72d03cfc6b1dd36b02ce3404d00c1a674677de8 Mon Sep 17 00:00:00 2001 From: Brian Dwyer Date: Tue, 31 Mar 2015 18:20:42 -0400 Subject: [PATCH 038/165] VMware Documentation Fix - SED Syntax we should only create the backup file on the first `sed` modification. The second `sed` operation will create a backup with the changes from the first `sed` operation. --- website/docs/source/v2/vmware/kernel-upgrade.html.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/source/v2/vmware/kernel-upgrade.html.md b/website/docs/source/v2/vmware/kernel-upgrade.html.md index 9b998ba33..b91986730 100644 --- a/website/docs/source/v2/vmware/kernel-upgrade.html.md +++ b/website/docs/source/v2/vmware/kernel-upgrade.html.md @@ -25,7 +25,7 @@ enable auto-upgrading: # when we update the linux images $fix_vmware_tools_script = <