From 10775a3b4ae08b604cb8213cbcca4a529d0fa1ec Mon Sep 17 00:00:00 2001
From: Hanno Heinrichs
Date: Thu, 15 Sep 2016 13:08:58 -0700
Subject: [PATCH 011/205] [windows] Use subprocess for safe_exec on windows
---
lib/vagrant/util/safe_exec.rb | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/lib/vagrant/util/safe_exec.rb b/lib/vagrant/util/safe_exec.rb
index d49a58a56..98875ac3b 100644
--- a/lib/vagrant/util/safe_exec.rb
+++ b/lib/vagrant/util/safe_exec.rb
@@ -7,6 +7,9 @@ module Vagrant
# thread. In that case, `safe_exec` automatically falls back to
# forking.
class SafeExec
+
+ @@logger = Log4r::Logger.new("vagrant::util::safe_exec")
+
def self.exec(command, *args)
# Create a list of things to rescue from. Since this is OS
# specific, we need to do some defined? checks here to make
@@ -18,10 +21,26 @@ module Vagrant
fork_instead = false
begin
- pid = nil
- pid = fork if fork_instead
- Kernel.exec(command, *args) if pid.nil?
- Process.wait(pid) if pid
+ if fork_instead
+ if Vagrant::Util::Platform.windows?
+ args = args.dup << {notify: [:stdout, :stderr]}
+ result = Vagrant::Util::Subprocess.execute(command, *args) do |type, data|
+ case type
+ when :stdout
+ @@logger.info(data, new_line: false)
+ when :stderr
+ @@logger.info(data, new_line: false)
+ end
+ end
+ Kernel.exit(result.exit_code)
+ else
+ pid = fork
+ Kernel.exec(command, *args)
+ Process.wait(pid)
+ end
+ else
+ Kernel.exec(command, *args)
+ end
rescue *rescue_from
# We retried already, raise the issue and be done
raise if fork_instead
From 5286410e529fa7d7dc4a6cca5322edd5e1fae0f4 Mon Sep 17 00:00:00 2001
From: Richard Quadling
Date: Fri, 16 Sep 2016 00:21:02 +0100
Subject: [PATCH 012/205] Update nfs.html.md
---
website/source/docs/synced-folders/nfs.html.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/website/source/docs/synced-folders/nfs.html.md b/website/source/docs/synced-folders/nfs.html.md
index 0ceed46ff..bbd853feb 100644
--- a/website/source/docs/synced-folders/nfs.html.md
+++ b/website/source/docs/synced-folders/nfs.html.md
@@ -182,7 +182,8 @@ Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /bin/sed -r -e * d -ibak /tmp/exports
```
If you don't want to edit `/etc/sudoers` directly, you can create
-`/etc/sudoers.d/vagrant-syncedfolders` with the appropriate entries.
+`/etc/sudoers.d/vagrant-syncedfolders` with the appropriate entries,
+assuming `/etc/sudoers.d` has been enabled.
## Other Notes
From 51f68f41a23161871c64691ddca366b36abdbc8c Mon Sep 17 00:00:00 2001
From: Jake Teton-Landis
Date: Thu, 15 Sep 2016 18:19:01 -0700
Subject: [PATCH 013/205] Unit test Vagrant::Util::Subprocess's STDIN support
- create new unit test file for this class, as none existed.
- test `Vagrant::Util::Subprocess#execute` behavior relating to STDIN
handling.
---
test/unit/vagrant/util/subprocess_test.rb | 50 +++++++++++++++++++++++
1 file changed, 50 insertions(+)
create mode 100644 test/unit/vagrant/util/subprocess_test.rb
diff --git a/test/unit/vagrant/util/subprocess_test.rb b/test/unit/vagrant/util/subprocess_test.rb
new file mode 100644
index 000000000..3934d1a3c
--- /dev/null
+++ b/test/unit/vagrant/util/subprocess_test.rb
@@ -0,0 +1,50 @@
+require File.expand_path("../../../base", __FILE__)
+require "vagrant/util/subprocess"
+
+describe Vagrant::Util::Subprocess do
+ describe '#execute' do
+ before do
+ # ensure we have `cat` and `echo` in our PATH so that we can run these
+ # tests successfully.
+ ['cat', 'echo'].each do |cmd|
+ if !Vagrant::Util::Which.which(cmd)
+ pending("cannot run subprocess tests without command #{cmd.inspect}")
+ end
+ end
+ end
+
+ let (:cat) { described_class.new('cat', :notify => [:stdin]) }
+
+ it 'yields the STDIN stream for the process if we set :notify => :stdin' do
+ echo = described_class.new('echo', 'hello world', :notify => [:stdin])
+ echo.execute do |type, data|
+ expect(type).to eq(:stdin)
+ expect(data).to be_a(::IO)
+ end
+ end
+
+ it 'can close STDIN' do
+ result = cat.execute do |type, stdin|
+ # We should be able to close STDIN without raising an exception
+ stdin.close
+ end
+
+ # we should exit successfully.
+ expect(result.exit_code).to eq(0)
+ end
+
+ it 'can write to STDIN correctly' do
+ data = "hello world\n"
+ result = cat.execute do |type, stdin|
+ stdin.write(data)
+ stdin.close
+ end
+
+ # we should exit successfully.
+ expect(result.exit_code).to eq(0)
+
+ # we should see our data as the output from `cat`
+ expect(result.stdout).to eq(data)
+ end
+ end
+end
From 0be221fbea5a633d4883066f1d8312fe2afb32ae Mon Sep 17 00:00:00 2001
From: Alejandro Ojeda
Date: Sun, 18 Sep 2016 03:58:45 +0200
Subject: [PATCH 014/205] Add test for provider priority fix
This commit adds tests for possible future regressions for the bug fixed
in the commit: "Fix Vagrant not prioritizing configured providers
correctly".
Two very similar tests were added because whether the bug manifests
or not depends on the order in which the provider dictionary keys
are iterated, which is specific to the dictionary implementation.
---
test/unit/vagrant/environment_test.rb | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/test/unit/vagrant/environment_test.rb b/test/unit/vagrant/environment_test.rb
index f2c9cf9bc..15d0a3e0e 100644
--- a/test/unit/vagrant/environment_test.rb
+++ b/test/unit/vagrant/environment_test.rb
@@ -866,6 +866,30 @@ VF
end
end
+ it "is the provider in the Vagrantfile that is usable even if only one specified (1)" do
+ subject.vagrantfile.config.vm.provider "foo"
+ subject.vagrantfile.config.vm.finalize!
+
+ plugin_providers[:foo] = [provider_usable_class(true), { priority: 5 }]
+ plugin_providers[:bar] = [provider_usable_class(true), { priority: 7 }]
+
+ with_temp_env("VAGRANT_DEFAULT_PROVIDER" => nil) do
+ expect(subject.default_provider).to eq(:foo)
+ end
+ end
+
+ it "is the provider in the Vagrantfile that is usable even if only one specified (2)" do
+ subject.vagrantfile.config.vm.provider "bar"
+ subject.vagrantfile.config.vm.finalize!
+
+ plugin_providers[:foo] = [provider_usable_class(true), { priority: 7 }]
+ plugin_providers[:bar] = [provider_usable_class(true), { priority: 5 }]
+
+ with_temp_env("VAGRANT_DEFAULT_PROVIDER" => nil) do
+ expect(subject.default_provider).to eq(:bar)
+ end
+ end
+
it "is the highest usable provider outside the Vagrantfile" do
subject.vagrantfile.config.vm.provider "foo"
subject.vagrantfile.config.vm.finalize!
From 8b8c9619353dd4069238dd9aa7fb2fec59e6e383 Mon Sep 17 00:00:00 2001
From: Rudinei Goi Roecker
Date: Tue, 20 Sep 2016 17:57:54 -0300
Subject: [PATCH 015/205] Fix non upstart linux nfs mounts
---
plugins/guests/linux/cap/nfs.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/guests/linux/cap/nfs.rb b/plugins/guests/linux/cap/nfs.rb
index d47d53b98..f017499aa 100644
--- a/plugins/guests/linux/cap/nfs.rb
+++ b/plugins/guests/linux/cap/nfs.rb
@@ -38,7 +38,7 @@ module VagrantPlugins
# Emit a mount event
commands << <<-EOH.gsub(/^ {14}/, '')
- if command -v /sbin/init && /sbin/init --version | grep upstart; then
+ if test -x /sbin/initctl && command -v /sbin/init && /sbin/init --version | grep upstart; then
/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=#{guest_path}
fi
EOH
From 2ecbc241c358be84c60380a9ebeb2adb526438d5 Mon Sep 17 00:00:00 2001
From: Rutger Swarts
Date: Fri, 23 Sep 2016 10:45:16 +0200
Subject: [PATCH 016/205] Add Virtuozzo Linux 7 to list of RHEL flavors
---
plugins/guests/redhat/cap/flavor.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/guests/redhat/cap/flavor.rb b/plugins/guests/redhat/cap/flavor.rb
index 72e16f8da..32dc1a7c2 100644
--- a/plugins/guests/redhat/cap/flavor.rb
+++ b/plugins/guests/redhat/cap/flavor.rb
@@ -10,7 +10,7 @@ module VagrantPlugins
end
# Detect various flavors we care about
- if output =~ /(CentOS|Red Hat Enterprise|Scientific|Cloud)\s*Linux( .+)? release 7/i
+ if output =~ /(CentOS|Red Hat Enterprise|Scientific|Cloud|Virtuozzo)\s*Linux( .+)? release 7/i
return :rhel_7
else
return :rhel
From bf36e6bf5c2cbd3d7da32354b453ab5a51e90966 Mon Sep 17 00:00:00 2001
From: Tim Smith
Date: Fri, 23 Sep 2016 10:00:18 -0700
Subject: [PATCH 017/205] Update required Ruby in the readme
It's 2.2 not 2.0
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index bcee1166a..dfb4fe1a3 100644
--- a/README.md
+++ b/README.md
@@ -49,7 +49,7 @@ and you're welcome to give it a shot. The following is an example showing how to
rake install
-Ruby 2.0 is needed.
+Ruby 2.2 is needed.
## Contributing to Vagrant
From c5e1a6d8c051981bc90ce6dd4bfe2f9b6d65afe6 Mon Sep 17 00:00:00 2001
From: Matt Wrock
Date: Mon, 26 Sep 2016 14:07:11 -0700
Subject: [PATCH 018/205] use the cmd shell to check winrm availability
---
plugins/communicators/winrm/communicator.rb | 2 +-
.../plugins/communicators/winrm/communicator_test.rb | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/plugins/communicators/winrm/communicator.rb b/plugins/communicators/winrm/communicator.rb
index 78ba73879..8c7a292cf 100644
--- a/plugins/communicators/winrm/communicator.rb
+++ b/plugins/communicators/winrm/communicator.rb
@@ -104,7 +104,7 @@ module VagrantPlugins
@logger.info("Checking whether WinRM is ready...")
result = Timeout.timeout(@machine.config.winrm.timeout) do
- shell(true).powershell("hostname")
+ shell(true).cmd("hostname")
end
@logger.info("WinRM is ready!")
diff --git a/test/unit/plugins/communicators/winrm/communicator_test.rb b/test/unit/plugins/communicators/winrm/communicator_test.rb
index 3e21242d9..d69185d86 100644
--- a/test/unit/plugins/communicators/winrm/communicator_test.rb
+++ b/test/unit/plugins/communicators/winrm/communicator_test.rb
@@ -45,7 +45,7 @@ describe VagrantPlugins::CommunicatorWinRM::Communicator do
port: '22',
})
# Makes ready? return true
- allow(shell).to receive(:powershell).with("hostname").and_return({ exitcode: 0 })
+ allow(shell).to receive(:cmd).with("hostname").and_return({ exitcode: 0 })
end
it "retries ssh_info until ready" do
@@ -57,22 +57,22 @@ describe VagrantPlugins::CommunicatorWinRM::Communicator do
describe ".ready?" do
it "returns true if hostname command executes without error" do
- expect(shell).to receive(:powershell).with("hostname").and_return({ exitcode: 0 })
+ expect(shell).to receive(:cmd).with("hostname").and_return({ exitcode: 0 })
expect(subject.ready?).to be_true
end
it "returns false if hostname command fails with a transient error" do
- expect(shell).to receive(:powershell).with("hostname").and_raise(VagrantPlugins::CommunicatorWinRM::Errors::TransientError)
+ expect(shell).to receive(:cmd).with("hostname").and_raise(VagrantPlugins::CommunicatorWinRM::Errors::TransientError)
expect(subject.ready?).to be_false
end
it "raises an error if hostname command fails with an unknown error" do
- expect(shell).to receive(:powershell).with("hostname").and_raise(Vagrant::Errors::VagrantError)
+ expect(shell).to receive(:cmd).with("hostname").and_raise(Vagrant::Errors::VagrantError)
expect { subject.ready? }.to raise_error(Vagrant::Errors::VagrantError)
end
it "raises timeout error when hostname command takes longer then winrm timeout" do
- expect(shell).to receive(:powershell).with("hostname") do
+ expect(shell).to receive(:cmd).with("hostname") do
sleep 2 # winrm.timeout = 1
end
expect { subject.ready? }.to raise_error(Timeout::Error)
From d92754b7e4e1658e4783f951df41dc2eb113d16b Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Tue, 27 Sep 2016 17:02:31 -0700
Subject: [PATCH 019/205] Update website version and bump for dev
---
CHANGELOG.md | 6 ++++++
version.txt | 2 +-
website/config.rb | 2 +-
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0767795ee..d240bd002 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,12 @@
FEATURES:
+IMPROVEMENTS:
+
+BUG FIXES:
+
+## 1.8.6 (September 27, 2016)
+
IMPROVEMENTS:
- Add detection for DragonFly BSD [GH-7701]
diff --git a/version.txt b/version.txt
index f263cd11b..c49ddad7b 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-1.8.6
+1.8.7.dev
diff --git a/website/config.rb b/website/config.rb
index 5f8231c81..e9b2dfba3 100644
--- a/website/config.rb
+++ b/website/config.rb
@@ -2,7 +2,7 @@ set :base_url, "https://www.vagrantup.com/"
activate :hashicorp do |h|
h.name = "vagrant"
- h.version = "1.8.5"
+ h.version = "1.8.6"
h.github_slug = "mitchellh/vagrant"
end
From b7114ced8746779ecb7511cbe2f3cc29949fd410 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Wed, 28 Sep 2016 08:24:56 -0700
Subject: [PATCH 020/205] Update CHANGELOG
---
CHANGELOG.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d240bd002..b86cf23ad 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,8 @@ FEATURES:
IMPROVEMENTS:
+ - util/subprocess: Allow closing STDIN [GH-7778]
+
BUG FIXES:
## 1.8.6 (September 27, 2016)
From 9f468d2626447d6f32ba4cfebf1837a6d343211d Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Thu, 29 Sep 2016 15:33:29 -0700
Subject: [PATCH 021/205] guests/linux: Place ethernet devices at start of
device list
---
plugins/guests/linux/cap/network_interfaces.rb | 18 ++++++++++++++++++
.../linux/cap/network_interfaces_test.rb | 13 +++++++++++++
2 files changed, 31 insertions(+)
diff --git a/plugins/guests/linux/cap/network_interfaces.rb b/plugins/guests/linux/cap/network_interfaces.rb
index 8a4c64dd3..ea7dc32da 100644
--- a/plugins/guests/linux/cap/network_interfaces.rb
+++ b/plugins/guests/linux/cap/network_interfaces.rb
@@ -2,6 +2,11 @@ module VagrantPlugins
module GuestLinux
module Cap
class NetworkInterfaces
+ # Valid ethernet device prefix values.
+ # eth - classic prefix
+ # en - predictable interface names prefix
+ ETHERNET_PREFIX = ["eth", "en"]
+
@@logger = Log4r::Logger.new("vagrant::guest::linux::network_interfaces")
# Get network interfaces as a list. The result will be something like:
@@ -15,10 +20,16 @@ module VagrantPlugins
s << data if type == :stdout
end
ifaces = s.split("\n")
+ eth_prefix = nil
@@logger.debug("Unsorted list: #{ifaces.inspect}")
# Break out integers from strings and sort the arrays to provide
# a natural sort for the interface names
ifaces = ifaces.map do |iface|
+ unless eth_prefix
+ eth_prefix = ETHERNET_PREFIX.detect do |prefix|
+ iface.start_with?(prefix)
+ end
+ end
iface.scan(/(.+?)(\d+)/).flatten.map do |iface_part|
if iface_part.to_i.to_s == iface_part
iface_part.to_i
@@ -28,6 +39,13 @@ module VagrantPlugins
end
end.sort.map(&:join)
@@logger.debug("Sorted list: #{ifaces.inspect}")
+ # Extract ethernet devices and place at start of list
+ if eth_prefix
+ eth_start = ifaces.index{|iface| iface.start_with?(eth_prefix) }
+ eth_end = ifaces.rindex{|iface| iface.start_with?(eth_prefix) }
+ ifaces.unshift(*ifaces.slice!(eth_start, eth_end - 1))
+ @@logger.debug("Ethernet preferred sorted list: #{ifaces.inspect}")
+ end
ifaces
end
end
diff --git a/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb b/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb
index 8dd4498a7..139cebfdc 100644
--- a/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb
+++ b/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb
@@ -44,5 +44,18 @@ describe "VagrantPlugins::GuestLinux::Cap::NetworkInterfaces" do
result = cap.network_interfaces(machine)
expect(result).to eq(["enp0s3", "enp0s5", "enp0s8", "enp0s10", "enp1s3"])
end
+
+ it "sorts ethernet devices discovered with classic naming first in list" do
+ expect(comm).to receive(:sudo).and_yield(:stdout, "eth1\neth2\ndocker0\nbridge0\neth0")
+ result = cap.network_interfaces(machine)
+ expect(result).to eq(["eth0", "eth1", "eth2", "bridge0", "docker0"])
+ end
+
+ it "sorts ethernet devices discovered with predictable network interfaces naming first in list" do
+ expect(comm).to receive(:sudo).and_yield(:stdout, "enp0s8\ndocker0\nenp0s3\nbridge0\nenp0s5")
+ result = cap.network_interfaces(machine)
+ expect(result).to eq(["enp0s3", "enp0s5", "enp0s8", "bridge0", "docker0"])
+ end
+
end
end
From 8a73035fdc219b948a5c05bc86306286b952a416 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Fri, 30 Sep 2016 09:11:49 -0700
Subject: [PATCH 022/205] Update CHANGELOG
---
CHANGELOG.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b86cf23ad..4cb3eff51 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,8 @@ IMPROVEMENTS:
BUG FIXES:
+ - communicators/winrm: Prevent connection leakage (GH-7712)
+
## 1.8.6 (September 27, 2016)
IMPROVEMENTS:
From 0300df09fb3aa4f05cca754de10a828502bf0321 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Fri, 30 Sep 2016 12:11:54 -0700
Subject: [PATCH 023/205] guests/linux: Update constant name, freeze constant
values
---
plugins/guests/linux/cap/network_interfaces.rb | 6 +++---
.../plugins/guests/linux/cap/network_interfaces_test.rb | 1 -
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/plugins/guests/linux/cap/network_interfaces.rb b/plugins/guests/linux/cap/network_interfaces.rb
index ea7dc32da..6d3ce657c 100644
--- a/plugins/guests/linux/cap/network_interfaces.rb
+++ b/plugins/guests/linux/cap/network_interfaces.rb
@@ -5,7 +5,7 @@ module VagrantPlugins
# Valid ethernet device prefix values.
# eth - classic prefix
# en - predictable interface names prefix
- ETHERNET_PREFIX = ["eth", "en"]
+ POSSIBLE_ETHERNET_PREFIXES = ["eth".freeze, "en".freeze].freeze
@@logger = Log4r::Logger.new("vagrant::guest::linux::network_interfaces")
@@ -25,8 +25,8 @@ module VagrantPlugins
# Break out integers from strings and sort the arrays to provide
# a natural sort for the interface names
ifaces = ifaces.map do |iface|
- unless eth_prefix
- eth_prefix = ETHERNET_PREFIX.detect do |prefix|
+ if eth_prefix.nil?
+ eth_prefix = POSSIBLE_ETHERNET_PREFIXES.detect do |prefix|
iface.start_with?(prefix)
end
end
diff --git a/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb b/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb
index 139cebfdc..810606f2a 100644
--- a/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb
+++ b/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb
@@ -56,6 +56,5 @@ describe "VagrantPlugins::GuestLinux::Cap::NetworkInterfaces" do
result = cap.network_interfaces(machine)
expect(result).to eq(["enp0s3", "enp0s5", "enp0s8", "bridge0", "docker0"])
end
-
end
end
From 977733790a5f73a3c17af23030f07efe51a6218d Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Fri, 30 Sep 2016 12:16:53 -0700
Subject: [PATCH 024/205] Include debug notification when using subprocess
---
lib/vagrant/util/safe_exec.rb | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/vagrant/util/safe_exec.rb b/lib/vagrant/util/safe_exec.rb
index 98875ac3b..37e6a38c3 100644
--- a/lib/vagrant/util/safe_exec.rb
+++ b/lib/vagrant/util/safe_exec.rb
@@ -23,6 +23,7 @@ module Vagrant
begin
if fork_instead
if Vagrant::Util::Platform.windows?
+ @@logger.debug("Using subprocess because windows platform")
args = args.dup << {notify: [:stdout, :stderr]}
result = Vagrant::Util::Subprocess.execute(command, *args) do |type, data|
case type
From 6d48f98d55e2983e1a7ed1d2bef62ca4bc0c0f65 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Fri, 30 Sep 2016 14:46:19 -0700
Subject: [PATCH 025/205] Update CHANGELOG
---
CHANGELOG.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4cb3eff51..3b400400f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,11 +4,13 @@ FEATURES:
IMPROVEMENTS:
+ - util/safe_exec: Use subprocess for safe_exec on Windows [GH-7802]
- util/subprocess: Allow closing STDIN [GH-7778]
BUG FIXES:
- - communicators/winrm: Prevent connection leakage (GH-7712)
+ - communicators/winrm: Prevent connection leakage [GH-7712]
+ - pushes/atlas: Fix atlas push on Windows platform [GH-6938, GH-7802]
## 1.8.6 (September 27, 2016)
From 4179f55928e3f027b8a06a7cd0cfabfdfd8e6f2f Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Fri, 30 Sep 2016 14:52:31 -0700
Subject: [PATCH 026/205] Update CHANGELOG
---
CHANGELOG.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3b400400f..68b310aef 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,12 +4,14 @@ FEATURES:
IMPROVEMENTS:
+ - guests/linux: Place ethernet devices at start of network devices list [GH-7848]
- util/safe_exec: Use subprocess for safe_exec on Windows [GH-7802]
- util/subprocess: Allow closing STDIN [GH-7778]
BUG FIXES:
- communicators/winrm: Prevent connection leakage [GH-7712]
+ - guests/linux: Fix incorrectly configured private network [GH-7844, GH-7848]
- pushes/atlas: Fix atlas push on Windows platform [GH-6938, GH-7802]
## 1.8.6 (September 27, 2016)
From c6423e8d9d835b1fa470ffbf5a5afb123496e42d Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Fri, 30 Sep 2016 16:18:16 -0700
Subject: [PATCH 027/205] Update CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 68b310aef..4d24283b2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@ FEATURES:
IMPROVEMENTS:
- guests/linux: Place ethernet devices at start of network devices list [GH-7848]
+ - guests/windows: Allow vagrant to start Windows Nano without provisioning [GH-7831]
- util/safe_exec: Use subprocess for safe_exec on Windows [GH-7802]
- util/subprocess: Allow closing STDIN [GH-7778]
From b041c1955ce0116b08e18f5398d72c43d95ad3f4 Mon Sep 17 00:00:00 2001
From: Bjorn Brala
Date: Sun, 2 Oct 2016 16:10:16 +0200
Subject: [PATCH 028/205] Add support for vmcx files, new binary format for
Hyper-V configurations.
---
.../hyperv/scripts/import_vm_vmcx.ps1 | 167 ++++++++++++++++++
1 file changed, 167 insertions(+)
create mode 100644 plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
diff --git a/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
new file mode 100644
index 000000000..33c961e33
--- /dev/null
+++ b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
@@ -0,0 +1,167 @@
+Param(
+ [Parameter(Mandatory=$true)]
+ [string]$vm_config,
+ [Parameter(Mandatory=$true)]
+ [string]$image_path,
+
+ [string]$switchname=$null,
+ [string]$memory=$null,
+ [string]$maxmemory=$null,
+ [string]$cpus=$null,
+ [string]$vmname=$null,
+ [string]$auto_start_action=$null,
+ [string]$auto_stop_action=$null
+)
+
+# Include the following modules
+$Dir = Split-Path $script:MyInvocation.MyCommand.Path
+. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1"))
+
+# load the config from the vmcx and make a copy for editing, use TMP path so we are sure there is no vhd at the destination
+$vmConfig = (Compare-VM -Copy -Path $vm_config -GenerateNewID -VhdDestinationPath $env:Temp)
+
+$generation = $vmConfig.VM.Generation
+
+if (!$vmname) {
+ # Get the name of the vm
+ $vm_name = $vmconfig.VM.VMName
+}else {
+ $vm_name = $vmname
+}
+
+if (!$cpus) {
+ # Get the processorcount of the VM
+ $processors = (Get-VMProcessor -VM $vmConfig.VM).Count
+
+}else {
+ $processors = $cpus
+}
+
+function GetUniqueName($name) {
+ Get-VM | ForEach-Object -Process {
+ if ($name -eq $_.Name) {
+ $name = $name + "_1"
+ }
+ }
+ return $name
+}
+
+do {
+ $name = $vm_name
+ $vm_name = GetUniqueName $name
+} while ($vm_name -ne $name)
+
+if (!$memory) {
+ $configMemory = Get-VMMemory -VM $vmConfig.VM
+ $dynamicmemory = $configMemory.DynamicMemoryEnabled
+
+ # Memory values need to be in bytes
+ $MemoryMaximumBytes = ($configMemory.Maximum)
+ $MemoryStartupBytes = ($configMemory.Startup)
+ $MemoryMinimumBytes = ($configMemory.Minimum)
+}
+else {
+ if (!$maxmemory){
+ $dynamicmemory = $False
+ $MemoryMaximumBytes = ($memory -as [int]) * 1MB
+ $MemoryStartupBytes = ($memory -as [int]) * 1MB
+ $MemoryMinimumBytes = ($memory -as [int]) * 1MB
+ }
+ else {
+ $dynamicmemory = $True
+ $MemoryMaximumBytes = ($maxmemory -as [int]) * 1MB
+ $MemoryStartupBytes = ($memory -as [int]) * 1MB
+ $MemoryMinimumBytes = ($memory -as [int]) * 1MB
+ }
+}
+
+
+if (!$switchname) {
+ $switchname = (Get-VMNetworkAdapter -VM $vmConfig.VM).SwitchName
+}
+
+$vm_params = @{
+ Name = $vm_name
+ NoVHD = $True
+ MemoryStartupBytes = $MemoryStartupBytes
+ SwitchName = $switchname
+ ErrorAction = "Stop"
+}
+
+# Generation parameter was added in ps v4
+if((get-command New-VM).Parameters.Keys.Contains("generation")) {
+ $vm_params.Generation = $generation
+}
+
+# Create the VM using the values in the hash map
+$vm = New-VM @vm_params
+
+$notes = $vmConfig.VM.Notes
+
+# Set-VM parameters to configure new VM with old values
+
+$more_vm_params = @{
+ ProcessorCount = $processors
+ MemoryStartupBytes = $MemoryStartupBytes
+}
+
+If ($dynamicmemory) {
+ $more_vm_params.Add("DynamicMemory",$True)
+ $more_vm_params.Add("MemoryMinimumBytes",$MemoryMinimumBytes)
+ $more_vm_params.Add("MemoryMaximumBytes", $MemoryMaximumBytes)
+} else {
+ $more_vm_params.Add("StaticMemory",$True)
+}
+
+if ($notes) {
+ $more_vm_params.Add("Notes",$notes)
+}
+
+if ($auto_start_action) {
+ $more_vm_params.Add("AutomaticStartAction",$auto_start_action)
+}
+
+if ($auto_stop_action) {
+ $more_vm_params.Add("AutomaticStopAction",$auto_stop_action)
+}
+
+# Set the values on the VM
+$vm | Set-VM @more_vm_params -Passthru
+
+# Only set EFI secure boot for Gen 2 machines, not gen 1
+if ($generation -ne 1) {
+ Set-VMFirmware -VM $vm -EnableSecureBoot (Get-VMFirmware -VM $vmConfig.VM).SecureBoot
+}
+
+# Get all controller on the VM, first scsi, then IDE if it is a Gen 1 device
+$controllers = Get-VMScsiController -VM $vmConfig.VM
+if($generation -eq 1){
+ $controllers = @($controllers) + @(Get-VMIdeController -VM $vmConfig.VM)
+}
+
+foreach($controller in $controllers){
+ foreach($drive in $controller.Drives){
+ $addDriveParam = @{
+ ControllerNumber = $drive.ControllerNumber
+ Path = $image_path
+ }
+ if($drive.PoolName){
+ $addDriveParam.Add("ResourcePoolname",$drive.PoolName)
+ }
+
+ # If the drive path is set, it is a harddisk, only support single harddisk
+ if ($drive.Path) {
+ $addDriveParam.add("ControllerType", $ControllerType)
+ $vm | Add-VMHardDiskDrive @AddDriveparam
+ }
+ }
+}
+
+$vm_id = (Get-VM $vm_name).id.guid
+$resultHash = @{
+ name = $vm_name
+ id = $vm_id
+}
+
+$result = ConvertTo-Json $resultHash
+Write-Output-Message $result
From 1ec1cf8177c8de954711811e085001363323f084 Mon Sep 17 00:00:00 2001
From: Bjorn Brala
Date: Sun, 2 Oct 2016 16:10:58 +0200
Subject: [PATCH 029/205] Update Hyper-V import command and the driver to check
for configuration type and call the correct import script.
---
plugins/providers/hyperv/action/import.rb | 13 +++++++++++--
plugins/providers/hyperv/driver.rb | 7 ++++++-
.../scripts/{import_vm.ps1 => import_vm_xml.ps1} | 4 ++--
3 files changed, 19 insertions(+), 5 deletions(-)
rename plugins/providers/hyperv/scripts/{import_vm.ps1 => import_vm_xml.ps1} (98%)
diff --git a/plugins/providers/hyperv/action/import.rb b/plugins/providers/hyperv/action/import.rb
index 18525543e..97351e12a 100644
--- a/plugins/providers/hyperv/action/import.rb
+++ b/plugins/providers/hyperv/action/import.rb
@@ -35,9 +35,17 @@ module VagrantPlugins
end
config_path = nil
+ config_type = nil
vm_dir.each_child do |f|
- if f.extname.downcase == ".xml"
+
+ if f.extname.downcase == '.xml'
config_path = f
+ config_type = 'xml'
+ break
+ end
+ if f.extname.downcase == '.vmcx'
+ config_path = f
+ config_type = 'vmcx'
break
end
end
@@ -111,7 +119,8 @@ module VagrantPlugins
# We have to normalize the paths to be Windows paths since
# we're executing PowerShell.
options = {
- vm_xml_config: config_path.to_s.gsub("/", "\\"),
+ vm_config: config_path.to_s.gsub("/", "\\"),
+ vm_config_type: config_type,
image_path: image_path.to_s.gsub("/", "\\")
}
options[:switchname] = switch if switch
diff --git a/plugins/providers/hyperv/driver.rb b/plugins/providers/hyperv/driver.rb
index 604c46bbd..73fb2eb74 100644
--- a/plugins/providers/hyperv/driver.rb
+++ b/plugins/providers/hyperv/driver.rb
@@ -74,7 +74,12 @@ module VagrantPlugins
end
def import(options)
- execute('import_vm.ps1', options)
+ config_type = options.delete(:vm_config_type)
+ if config_type === "vmcx"
+ execute('import_vm_vmcx.ps1', options)
+ else
+ execute('import_vm_xml.ps1', options)
+ end
end
def net_set_vlan(vlan_id)
diff --git a/plugins/providers/hyperv/scripts/import_vm.ps1 b/plugins/providers/hyperv/scripts/import_vm_xml.ps1
similarity index 98%
rename from plugins/providers/hyperv/scripts/import_vm.ps1
rename to plugins/providers/hyperv/scripts/import_vm_xml.ps1
index 659eb50aa..18d99d203 100644
--- a/plugins/providers/hyperv/scripts/import_vm.ps1
+++ b/plugins/providers/hyperv/scripts/import_vm_xml.ps1
@@ -1,6 +1,6 @@
Param(
[Parameter(Mandatory=$true)]
- [string]$vm_xml_config,
+ [string]$vm_config,
[Parameter(Mandatory=$true)]
[string]$image_path,
@@ -17,7 +17,7 @@ Param(
$Dir = Split-Path $script:MyInvocation.MyCommand.Path
. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1"))
-[xml]$vmconfig = Get-Content -Path $vm_xml_config
+[xml]$vmconfig = Get-Content -Path $vm_config
$generation = [int]($vmconfig.configuration.properties.subtype.'#text')+1
From 2fc93277fd5a22257cbe70032b2d06a14ccdd49f Mon Sep 17 00:00:00 2001
From: Bjorn Brala
Date: Sun, 2 Oct 2016 18:45:51 +0200
Subject: [PATCH 030/205] change argument to vm_config_file so it isn't the
same as variable in powershell script.
---
plugins/providers/hyperv/action/import.rb | 2 +-
plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 | 2 +-
plugins/providers/hyperv/scripts/import_vm_xml.ps1 | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/plugins/providers/hyperv/action/import.rb b/plugins/providers/hyperv/action/import.rb
index 97351e12a..abc6d02c5 100644
--- a/plugins/providers/hyperv/action/import.rb
+++ b/plugins/providers/hyperv/action/import.rb
@@ -119,7 +119,7 @@ module VagrantPlugins
# We have to normalize the paths to be Windows paths since
# we're executing PowerShell.
options = {
- vm_config: config_path.to_s.gsub("/", "\\"),
+ vm_config_file: config_path.to_s.gsub("/", "\\"),
vm_config_type: config_type,
image_path: image_path.to_s.gsub("/", "\\")
}
diff --git a/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
index 33c961e33..36f7eae69 100644
--- a/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
+++ b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
@@ -1,6 +1,6 @@
Param(
[Parameter(Mandatory=$true)]
- [string]$vm_config,
+ [string]$vm_config_file,
[Parameter(Mandatory=$true)]
[string]$image_path,
diff --git a/plugins/providers/hyperv/scripts/import_vm_xml.ps1 b/plugins/providers/hyperv/scripts/import_vm_xml.ps1
index 18d99d203..89383c254 100644
--- a/plugins/providers/hyperv/scripts/import_vm_xml.ps1
+++ b/plugins/providers/hyperv/scripts/import_vm_xml.ps1
@@ -1,6 +1,6 @@
Param(
[Parameter(Mandatory=$true)]
- [string]$vm_config,
+ [string]$vm_config_file,
[Parameter(Mandatory=$true)]
[string]$image_path,
From 133e2a7b0fd827b1dca683d81ce0b60e662fc639 Mon Sep 17 00:00:00 2001
From: Bjorn Brala
Date: Tue, 4 Oct 2016 20:06:10 +0200
Subject: [PATCH 031/205] Broke Path argument in mini refactor.
---
plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 | 2 +-
plugins/providers/hyperv/scripts/import_vm_xml.ps1 | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
index 36f7eae69..21e3132de 100644
--- a/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
+++ b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
@@ -18,7 +18,7 @@ $Dir = Split-Path $script:MyInvocation.MyCommand.Path
. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1"))
# load the config from the vmcx and make a copy for editing, use TMP path so we are sure there is no vhd at the destination
-$vmConfig = (Compare-VM -Copy -Path $vm_config -GenerateNewID -VhdDestinationPath $env:Temp)
+$vmConfig = (Compare-VM -Copy -Path $vm_config_file -GenerateNewID -VhdDestinationPath $env:Temp)
$generation = $vmConfig.VM.Generation
diff --git a/plugins/providers/hyperv/scripts/import_vm_xml.ps1 b/plugins/providers/hyperv/scripts/import_vm_xml.ps1
index 89383c254..cccb0a75c 100644
--- a/plugins/providers/hyperv/scripts/import_vm_xml.ps1
+++ b/plugins/providers/hyperv/scripts/import_vm_xml.ps1
@@ -17,7 +17,7 @@ Param(
$Dir = Split-Path $script:MyInvocation.MyCommand.Path
. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1"))
-[xml]$vmconfig = Get-Content -Path $vm_config
+[xml]$vmconfig = Get-Content -Path $vm_config_file
$generation = [int]($vmconfig.configuration.properties.subtype.'#text')+1
From e2b18fc65db2e2871afd72ea86ac5f173463e7da Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Tue, 4 Oct 2016 17:25:00 -0700
Subject: [PATCH 032/205] guests/linux: Update network interface sorting
implementation
Always pull ordered ethernet devices to the head of the list. Ensure
aliases are not included.
---
plugins/guests/linux/cap/network_interfaces.rb | 18 +++++++-----------
.../linux/cap/network_interfaces_test.rb | 12 ++++++++++++
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/plugins/guests/linux/cap/network_interfaces.rb b/plugins/guests/linux/cap/network_interfaces.rb
index 6d3ce657c..c66de24c4 100644
--- a/plugins/guests/linux/cap/network_interfaces.rb
+++ b/plugins/guests/linux/cap/network_interfaces.rb
@@ -20,16 +20,10 @@ module VagrantPlugins
s << data if type == :stdout
end
ifaces = s.split("\n")
- eth_prefix = nil
@@logger.debug("Unsorted list: #{ifaces.inspect}")
# Break out integers from strings and sort the arrays to provide
# a natural sort for the interface names
ifaces = ifaces.map do |iface|
- if eth_prefix.nil?
- eth_prefix = POSSIBLE_ETHERNET_PREFIXES.detect do |prefix|
- iface.start_with?(prefix)
- end
- end
iface.scan(/(.+?)(\d+)/).flatten.map do |iface_part|
if iface_part.to_i.to_s == iface_part
iface_part.to_i
@@ -40,12 +34,14 @@ module VagrantPlugins
end.sort.map(&:join)
@@logger.debug("Sorted list: #{ifaces.inspect}")
# Extract ethernet devices and place at start of list
- if eth_prefix
- eth_start = ifaces.index{|iface| iface.start_with?(eth_prefix) }
- eth_end = ifaces.rindex{|iface| iface.start_with?(eth_prefix) }
- ifaces.unshift(*ifaces.slice!(eth_start, eth_end - 1))
- @@logger.debug("Ethernet preferred sorted list: #{ifaces.inspect}")
+ resorted_ifaces = []
+ resorted_ifaces += ifaces.find_all do |iface|
+ POSSIBLE_ETHERNET_PREFIXES.any?{|prefix| iface.start_with?(prefix)} &&
+ !iface.include?(':')
end
+ resorted_ifaces += ifaces - resorted_ifaces
+ ifaces = resorted_ifaces
+ @@logger.debug("Ethernet preferred sorted list: #{ifaces.inspect}")
ifaces
end
end
diff --git a/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb b/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb
index 810606f2a..5c6a36546 100644
--- a/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb
+++ b/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb
@@ -56,5 +56,17 @@ describe "VagrantPlugins::GuestLinux::Cap::NetworkInterfaces" do
result = cap.network_interfaces(machine)
expect(result).to eq(["enp0s3", "enp0s5", "enp0s8", "bridge0", "docker0"])
end
+
+ it "sorts ethernet devices discovered with predictable network interfaces naming first in list with less" do
+ expect(comm).to receive(:sudo).and_yield(:stdout, "enp0s3\nenp0s8\ndocker0")
+ result = cap.network_interfaces(machine)
+ expect(result).to eq(["enp0s3", "enp0s8", "docker0"])
+ end
+
+ it "does not include ethernet devices aliases within prefix device listing" do
+ expect(comm).to receive(:sudo).and_yield(:stdout, "eth1\neth2\ndocker0\nbridge0\neth0\neth0:0")
+ result = cap.network_interfaces(machine)
+ expect(result).to eq(["eth0", "eth1", "eth2", "bridge0", "docker0", "eth0:0"])
+ end
end
end
From d96dc9507645ac49f7a548337be6289dc63f09e3 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Tue, 4 Oct 2016 17:33:48 -0700
Subject: [PATCH 033/205] Update CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4d24283b2..8bafe8399 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ BUG FIXES:
- communicators/winrm: Prevent connection leakage [GH-7712]
- guests/linux: Fix incorrectly configured private network [GH-7844, GH-7848]
+ - guests/redhat: Properly configure network and restart service [GH-7751]
- pushes/atlas: Fix atlas push on Windows platform [GH-6938, GH-7802]
## 1.8.6 (September 27, 2016)
From 391c5be08e3f1f4e72b33a1a1fdbe6e07e67be4c Mon Sep 17 00:00:00 2001
From: Theron Boerner
Date: Sun, 7 Aug 2016 12:37:50 -0500
Subject: [PATCH 034/205] Remove --interactive flag from Docker command
See: GH-7597. Due to the childprocess gem setting STDIN to a pipe,
Docker will fail as it requires STDIN to be a TTY if run with
--interactive.
---
plugins/providers/docker/driver.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/providers/docker/driver.rb b/plugins/providers/docker/driver.rb
index 421369a96..f7a06f195 100644
--- a/plugins/providers/docker/driver.rb
+++ b/plugins/providers/docker/driver.rb
@@ -48,7 +48,7 @@ module VagrantPlugins
run_cmd += volumes.map { |v| ['-v', v.to_s] }
run_cmd += %W(--privileged) if params[:privileged]
run_cmd += %W(-h #{params[:hostname]}) if params[:hostname]
- run_cmd << "-i" << "-t" if params[:pty]
+ run_cmd << "-t" if params[:pty]
run_cmd << "--rm=true" if params[:rm]
run_cmd += params[:extra_args] if params[:extra_args]
run_cmd += [image, cmd]
From 9b8c8dad8cf5507dc505ba952dec8efd230c3a0f Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Thu, 6 Oct 2016 13:01:34 -0700
Subject: [PATCH 035/205] Update CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8bafe8399..c6f6a7356 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ BUG FIXES:
- communicators/winrm: Prevent connection leakage [GH-7712]
- guests/linux: Fix incorrectly configured private network [GH-7844, GH-7848]
+ - guests/linux: Only emit upstart event if initctl is available [GH-7813]
- guests/redhat: Properly configure network and restart service [GH-7751]
- pushes/atlas: Fix atlas push on Windows platform [GH-6938, GH-7802]
From 7db6379d440252b372519ebf1cafd4da86b97e85 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Thu, 6 Oct 2016 15:43:57 -0700
Subject: [PATCH 036/205] Update CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c6f6a7356..3a2618984 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ BUG FIXES:
- guests/linux: Fix incorrectly configured private network [GH-7844, GH-7848]
- guests/linux: Only emit upstart event if initctl is available [GH-7813]
- guests/redhat: Properly configure network and restart service [GH-7751]
+ - providers/docker: Remove --interactive flag when pty is true [GH-7688]
- pushes/atlas: Fix atlas push on Windows platform [GH-6938, GH-7802]
## 1.8.6 (September 27, 2016)
From 26b3a303d2705adf29dc16c3ee56308cd9889f90 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Thu, 6 Oct 2016 16:15:53 -0700
Subject: [PATCH 037/205] config/vm: cast box version to string before string
operations
---
plugins/kernel_v2/config/vm.rb | 2 +-
test/unit/plugins/kernel_v2/config/vm_test.rb | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb
index 0cb7c8b1b..fcd8da3bf 100644
--- a/plugins/kernel_v2/config/vm.rb
+++ b/plugins/kernel_v2/config/vm.rb
@@ -581,7 +581,7 @@ module VagrantPlugins
@hostname && @hostname !~ /^[a-z0-9][-.a-z0-9]*$/i
if @box_version
- @box_version.split(",").each do |v|
+ @box_version.to_s.split(",").each do |v|
begin
Gem::Requirement.new(v.strip)
rescue Gem::Requirement::BadRequirementError
diff --git a/test/unit/plugins/kernel_v2/config/vm_test.rb b/test/unit/plugins/kernel_v2/config/vm_test.rb
index bef729832..b8320cfc7 100644
--- a/test/unit/plugins/kernel_v2/config/vm_test.rb
+++ b/test/unit/plugins/kernel_v2/config/vm_test.rb
@@ -133,6 +133,14 @@ describe VagrantPlugins::Kernel_V2::VMConfig do
assert_valid
end
+
+ ["1", 1, "1.0", 1.0].each do |valid|
+ it "is valid: #{valid}" do
+ subject.box_version = valid
+ subject.finalize!
+ assert_valid
+ end
+ end
end
describe "#communicator" do
From c77326438b86a40bbc0d3ec93bbea7ec520392db Mon Sep 17 00:00:00 2001
From: guessi
Date: Fri, 7 Oct 2016 19:40:36 +0800
Subject: [PATCH 038/205] Fix incorrect ssh-config output when '--host' is
defined
Fixes: #7728
Signed-off-by: guessi
---
plugins/commands/ssh_config/command.rb | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/plugins/commands/ssh_config/command.rb b/plugins/commands/ssh_config/command.rb
index 7df07ff6e..7e8a5ce84 100644
--- a/plugins/commands/ssh_config/command.rb
+++ b/plugins/commands/ssh_config/command.rb
@@ -32,6 +32,10 @@ module VagrantPlugins
ssh_info = machine.ssh_info
raise Vagrant::Errors::SSHNotReady if ssh_info.nil?
+ if options[:host] && options[:host].to_s != machine.name.to_s
+ next
+ end
+
variables = {
host_key: options[:host] || machine.name || "vagrant",
ssh_host: ssh_info[:host],
From a77da314e5fe7054a06a4bb4bf3baf4dd850b609 Mon Sep 17 00:00:00 2001
From: Bjorn Brala
Date: Fri, 7 Oct 2016 20:38:05 +0200
Subject: [PATCH 039/205] Only check for .vmcx if there is no XML found to not
risk breaking older vagrant boxes that added an XML file manually
---
plugins/providers/hyperv/action/import.rb | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/plugins/providers/hyperv/action/import.rb b/plugins/providers/hyperv/action/import.rb
index abc6d02c5..e31949475 100644
--- a/plugins/providers/hyperv/action/import.rb
+++ b/plugins/providers/hyperv/action/import.rb
@@ -37,19 +37,28 @@ module VagrantPlugins
config_path = nil
config_type = nil
vm_dir.each_child do |f|
-
if f.extname.downcase == '.xml'
config_path = f
config_type = 'xml'
break
end
- if f.extname.downcase == '.vmcx'
- config_path = f
- config_type = 'vmcx'
- break
+ end
+
+
+ # Only check for .vmcx if there is no XML found to not
+ # risk breaking older vagrant boxes that added an XML
+ # file manually
+ if config_type == nil
+ vm_dir.each_child do |f|
+ if f.extname.downcase == '.vmcx'
+ config_path = f
+ config_type = 'vmcx'
+ break
+ end
end
end
+
image_path = nil
image_ext = nil
image_filename = nil
From 4bf32e3f6d31ebf557953328a545bcff58680118 Mon Sep 17 00:00:00 2001
From: Mark Peek
Date: Thu, 6 Oct 2016 13:23:13 -0700
Subject: [PATCH 040/205] Fix typo (netmast => netmask) for Photon guest #7808
---
plugins/guests/photon/cap/configure_networks.rb | 2 +-
test/unit/plugins/guests/photon/cap/configure_networks_test.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/guests/photon/cap/configure_networks.rb b/plugins/guests/photon/cap/configure_networks.rb
index c628fe1f5..fa51f863e 100644
--- a/plugins/guests/photon/cap/configure_networks.rb
+++ b/plugins/guests/photon/cap/configure_networks.rb
@@ -18,7 +18,7 @@ module VagrantPlugins
device = interfaces[network[:interface]]
command = "ifconfig #{device}"
command << " #{network[:ip]}" if network[:ip]
- command << " netmast #{network[:netmask]}" if network[:netmask]
+ command << " netmask #{network[:netmask]}" if network[:netmask]
commands << command
end
diff --git a/test/unit/plugins/guests/photon/cap/configure_networks_test.rb b/test/unit/plugins/guests/photon/cap/configure_networks_test.rb
index 97f66a727..bbcc717c7 100644
--- a/test/unit/plugins/guests/photon/cap/configure_networks_test.rb
+++ b/test/unit/plugins/guests/photon/cap/configure_networks_test.rb
@@ -45,7 +45,7 @@ describe "VagrantPlugins::GuestPhoton::Cap:ConfigureNetworks" do
it "creates and starts the networks" do
cap.configure_networks(machine, [network_1, network_2])
expect(comm.received_commands[1]).to match(/ifconfig eth1/)
- expect(comm.received_commands[1]).to match(/ifconfig eth2 33.33.33.10 netmast 255.255.0.0/)
+ expect(comm.received_commands[1]).to match(/ifconfig eth2 33.33.33.10 netmask 255.255.0.0/)
end
end
end
From 3c0162b239208249f0eef1a9cbd7075c1ae6859b Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Fri, 7 Oct 2016 15:17:08 -0700
Subject: [PATCH 041/205] Update CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3a2618984..858ac9392 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,7 @@ BUG FIXES:
- communicators/winrm: Prevent connection leakage [GH-7712]
- guests/linux: Fix incorrectly configured private network [GH-7844, GH-7848]
- guests/linux: Only emit upstart event if initctl is available [GH-7813]
+ - guests/photon: Fix networking setup [GH-7808, GH-7873]
- guests/redhat: Properly configure network and restart service [GH-7751]
- providers/docker: Remove --interactive flag when pty is true [GH-7688]
- pushes/atlas: Fix atlas push on Windows platform [GH-6938, GH-7802]
From 037de8bd6b4e5f1cec4b1264b1d8b4456e905765 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Fri, 7 Oct 2016 15:20:45 -0700
Subject: [PATCH 042/205] Update CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 858ac9392..7243c4a62 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ IMPROVEMENTS:
BUG FIXES:
+ - communicators/ssh: Properly honor --host flag for ssh-config [GH-7728, GH-7877]
- communicators/winrm: Prevent connection leakage [GH-7712]
- guests/linux: Fix incorrectly configured private network [GH-7844, GH-7848]
- guests/linux: Only emit upstart event if initctl is available [GH-7813]
From 703513bd0f77ad9827c5fdd58a0c488e978d9110 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Fri, 7 Oct 2016 16:50:12 -0700
Subject: [PATCH 043/205] Revert "Fix incorrect ssh-config output when '--host'
is defined"
This reverts commit c77326438b86a40bbc0d3ec93bbea7ec520392db.
---
plugins/commands/ssh_config/command.rb | 4 ----
1 file changed, 4 deletions(-)
diff --git a/plugins/commands/ssh_config/command.rb b/plugins/commands/ssh_config/command.rb
index 7e8a5ce84..7df07ff6e 100644
--- a/plugins/commands/ssh_config/command.rb
+++ b/plugins/commands/ssh_config/command.rb
@@ -32,10 +32,6 @@ module VagrantPlugins
ssh_info = machine.ssh_info
raise Vagrant::Errors::SSHNotReady if ssh_info.nil?
- if options[:host] && options[:host].to_s != machine.name.to_s
- next
- end
-
variables = {
host_key: options[:host] || machine.name || "vagrant",
ssh_host: ssh_info[:host],
From 71b078b79f03ca4f628e203ce427b78727f6767c Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Fri, 7 Oct 2016 16:51:05 -0700
Subject: [PATCH 044/205] Update CHANGELOG
---
CHANGELOG.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7243c4a62..858ac9392 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,7 +11,6 @@ IMPROVEMENTS:
BUG FIXES:
- - communicators/ssh: Properly honor --host flag for ssh-config [GH-7728, GH-7877]
- communicators/winrm: Prevent connection leakage [GH-7712]
- guests/linux: Fix incorrectly configured private network [GH-7844, GH-7848]
- guests/linux: Only emit upstart event if initctl is available [GH-7813]
From c6a32042c811502060b1eaa429c2a79c8438ad65 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Fri, 7 Oct 2016 17:16:33 -0700
Subject: [PATCH 045/205] Update CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 858ac9392..f48521c5d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@ IMPROVEMENTS:
BUG FIXES:
- communicators/winrm: Prevent connection leakage [GH-7712]
+ - core: Prevent duplicate provider priorities [GH-7756]
- guests/linux: Fix incorrectly configured private network [GH-7844, GH-7848]
- guests/linux: Only emit upstart event if initctl is available [GH-7813]
- guests/photon: Fix networking setup [GH-7808, GH-7873]
From d178631ff95bc07701fcabcfa33ad11eb9ab7ba3 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Fri, 7 Oct 2016 17:30:27 -0700
Subject: [PATCH 046/205] Generic white space strip from command strings
---
plugins/guests/redhat/cap/configure_networks.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/guests/redhat/cap/configure_networks.rb b/plugins/guests/redhat/cap/configure_networks.rb
index d96e27e20..04b49ab92 100644
--- a/plugins/guests/redhat/cap/configure_networks.rb
+++ b/plugins/guests/redhat/cap/configure_networks.rb
@@ -36,7 +36,7 @@ module VagrantPlugins
# Add the new interface and bring it back up
final_path = "#{network_scripts_dir}/ifcfg-#{network[:device]}"
- commands << <<-EOH.gsub(/^ {14}/, '')
+ commands << <<-EOH.gsub(/^ */, '')
# Down the interface before munging the config file. This might
# fail if the interface is not actually set up yet so ignore
# errors.
@@ -50,7 +50,7 @@ module VagrantPlugins
EOH
end
- commands << <<-EOH.gsub(/^ {14}/, '')
+ commands << <<-EOH.gsub(/^ */, '')
# Restart network
service network restart
EOH
From debe50957b4991cb5d81347a970a3df0d6e43fb6 Mon Sep 17 00:00:00 2001
From: Bjorn Brala
Date: Sat, 8 Oct 2016 16:38:42 +0200
Subject: [PATCH 047/205] Refactor the import script to fully use Compare-VM
for creating the new VM. Implemented the differencing disk for vmcx. This
means the disk is now copied by Hyper-V (Powershell) instead of Ruby for new
machines. This does mean EFI Firmware now does work for machines since it is
quite a feep copy. Compare-VM will report incompatibilities should they be
found.
---
plugins/providers/hyperv/action/import.rb | 23 +++--
plugins/providers/hyperv/driver.rb | 3 +
.../hyperv/scripts/import_vm_vmcx.ps1 | 99 +++++++++----------
.../hyperv/scripts/import_vm_xml.ps1 | 4 +-
4 files changed, 63 insertions(+), 66 deletions(-)
diff --git a/plugins/providers/hyperv/action/import.rb b/plugins/providers/hyperv/action/import.rb
index e31949475..7be7265e0 100644
--- a/plugins/providers/hyperv/action/import.rb
+++ b/plugins/providers/hyperv/action/import.rb
@@ -44,7 +44,6 @@ module VagrantPlugins
end
end
-
# Only check for .vmcx if there is no XML found to not
# risk breaking older vagrant boxes that added an XML
# file manually
@@ -58,7 +57,6 @@ module VagrantPlugins
end
end
-
image_path = nil
image_ext = nil
image_filename = nil
@@ -116,12 +114,16 @@ module VagrantPlugins
end
env[:ui].detail("Cloning virtual hard drive...")
- source_path = image_path.to_s
- dest_path = env[:machine].data_dir.join("#{image_filename}#{image_ext}").to_s
- if differencing_disk
- env[:machine].provider.driver.execute("clone_vhd.ps1", {Source: source_path, Destination: dest_path})
- else
- FileUtils.cp(source_path, dest_path)
+ source_path = image_path.to_s
+ dest_path = env[:machine].data_dir.join("#{image_filename}#{image_ext}").to_s
+
+ # Still hard copy the disk of old XML configurations
+ if config_type == 'xml'
+ if differencing_disk
+ env[:machine].provider.driver.execute("clone_vhd.ps1", {Source: source_path, Destination: dest_path})
+ else
+ FileUtils.cp(source_path, dest_path)
+ end
end
image_path = dest_path
@@ -130,7 +132,9 @@ module VagrantPlugins
options = {
vm_config_file: config_path.to_s.gsub("/", "\\"),
vm_config_type: config_type,
- image_path: image_path.to_s.gsub("/", "\\")
+ source_path: source_path.to_s,
+ dest_path: env[:machine].data_dir.join("Virtual Hard Disks").join("#{image_filename}#{image_ext}").to_s,
+ data_path: env[:machine].data_dir.to_s.gsub("/", "\\")
}
options[:switchname] = switch if switch
options[:memory] = memory if memory
@@ -139,6 +143,7 @@ module VagrantPlugins
options[:vmname] = vmname if vmname
options[:auto_start_action] = auto_start_action if auto_start_action
options[:auto_stop_action] = auto_stop_action if auto_stop_action
+ options[:differencing_disk] = differencing_disk if differencing_disk
env[:ui].detail("Creating and registering the VM...")
server = env[:machine].provider.driver.import(options)
diff --git a/plugins/providers/hyperv/driver.rb b/plugins/providers/hyperv/driver.rb
index 73fb2eb74..d348cb79e 100644
--- a/plugins/providers/hyperv/driver.rb
+++ b/plugins/providers/hyperv/driver.rb
@@ -78,6 +78,9 @@ module VagrantPlugins
if config_type === "vmcx"
execute('import_vm_vmcx.ps1', options)
else
+ option.delete(:data_path)
+ option.delete(:source_path)
+ option.delete(:differencing_disk)
execute('import_vm_xml.ps1', options)
end
end
diff --git a/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
index 21e3132de..b31c1528d 100644
--- a/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
+++ b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
@@ -2,7 +2,11 @@
[Parameter(Mandatory=$true)]
[string]$vm_config_file,
[Parameter(Mandatory=$true)]
- [string]$image_path,
+ [string]$source_path,
+ [Parameter(Mandatory=$true)]
+ [string]$dest_path,
+ [Parameter(Mandatory=$true)]
+ [string]$data_path,
[string]$switchname=$null,
[string]$memory=$null,
@@ -10,15 +14,19 @@
[string]$cpus=$null,
[string]$vmname=$null,
[string]$auto_start_action=$null,
- [string]$auto_stop_action=$null
+ [string]$auto_stop_action=$null,
+ [string]$differencing_disk=$null
)
+"$($data_path)/Snapshots"
+
# Include the following modules
$Dir = Split-Path $script:MyInvocation.MyCommand.Path
. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1"))
# load the config from the vmcx and make a copy for editing, use TMP path so we are sure there is no vhd at the destination
-$vmConfig = (Compare-VM -Copy -Path $vm_config_file -GenerateNewID -VhdDestinationPath $env:Temp)
+$vmConfig = (Compare-VM -Copy -Path $vm_config_file -GenerateNewID -SnapshotFilePath "$($data_path)Snapshots" -VhdDestinationPath "$($data_path)Virtual Hard Disks" -VirtualMachinePath "$($data_path)Virtual Machines")
+
$generation = $vmConfig.VM.Generation
@@ -32,7 +40,6 @@ if (!$vmname) {
if (!$cpus) {
# Get the processorcount of the VM
$processors = (Get-VMProcessor -VM $vmConfig.VM).Count
-
}else {
$processors = $cpus
}
@@ -80,82 +87,64 @@ if (!$switchname) {
$switchname = (Get-VMNetworkAdapter -VM $vmConfig.VM).SwitchName
}
-$vm_params = @{
- Name = $vm_name
- NoVHD = $True
- MemoryStartupBytes = $MemoryStartupBytes
- SwitchName = $switchname
- ErrorAction = "Stop"
-}
-# Generation parameter was added in ps v4
-if((get-command New-VM).Parameters.Keys.Contains("generation")) {
- $vm_params.Generation = $generation
-}
-
-# Create the VM using the values in the hash map
-$vm = New-VM @vm_params
-
-$notes = $vmConfig.VM.Notes
-
-# Set-VM parameters to configure new VM with old values
-
-$more_vm_params = @{
- ProcessorCount = $processors
- MemoryStartupBytes = $MemoryStartupBytes
-}
+Connect-VMNetworkAdapter -VMNetworkAdapter (Get-VMNetworkAdapter -VM $vmConfig.VM) -SwitchName $switchname
+Set-VM -VM $vmConfig.VM -NewVMName $vm_name -MemoryStartupBytes $MemoryStartupBytes
+Set-VM -VM $vmConfig.VM -MemoryMinimumBytes $MemoryMinimumBytes -MemoryMaximumBytes $MemoryMaximumBytes
+Set-VM -VM $vmConfig.VM -ErrorAction "Stop" -ProcessorCount $processors
If ($dynamicmemory) {
- $more_vm_params.Add("DynamicMemory",$True)
- $more_vm_params.Add("MemoryMinimumBytes",$MemoryMinimumBytes)
- $more_vm_params.Add("MemoryMaximumBytes", $MemoryMaximumBytes)
+ Set-VM -VM $vmConfig.VM -DynamicMemory
} else {
- $more_vm_params.Add("StaticMemory",$True)
+ Set-VM -VM $vmConfig.VM -StaticMemory
}
if ($notes) {
- $more_vm_params.Add("Notes",$notes)
+ Set-VM -VM $vmConfig.VM -Notes $notes
}
if ($auto_start_action) {
- $more_vm_params.Add("AutomaticStartAction",$auto_start_action)
+ Set-VM -VM $vmConfig.VM -AutomaticStartAction $auto_start_action
}
if ($auto_stop_action) {
- $more_vm_params.Add("AutomaticStopAction",$auto_stop_action)
+ Set-VM -VM $vmConfig.VM -AutomaticStartAction $auto_stop_action
}
-# Set the values on the VM
-$vm | Set-VM @more_vm_params -Passthru
-
# Only set EFI secure boot for Gen 2 machines, not gen 1
if ($generation -ne 1) {
- Set-VMFirmware -VM $vm -EnableSecureBoot (Get-VMFirmware -VM $vmConfig.VM).SecureBoot
+ Set-VMFirmware -VM $vmConfig.VM -EnableSecureBoot (Get-VMFirmware -VM $vmConfig.VM).SecureBoot
}
-# Get all controller on the VM, first scsi, then IDE if it is a Gen 1 device
-$controllers = Get-VMScsiController -VM $vmConfig.VM
-if($generation -eq 1){
- $controllers = @($controllers) + @(Get-VMIdeController -VM $vmConfig.VM)
+$report = Compare-VM -CompatibilityReport $vmConfig
+if($report.Incompatibilities.Length -gt 0){
+$report.Incompatibilities
+ Write-Error-Message ConvertTo-Json $report.Incompatibilities
}
-foreach($controller in $controllers){
- foreach($drive in $controller.Drives){
- $addDriveParam = @{
- ControllerNumber = $drive.ControllerNumber
- Path = $image_path
- }
- if($drive.PoolName){
- $addDriveParam.Add("ResourcePoolname",$drive.PoolName)
- }
+# Differencing disk
+if($differencing_disk){
+ # Get all controller on the VM, first scsi, then IDE if it is a Gen 1 device
+ $controllers = Get-VMScsiController -VM $vmConfig.VM
+ if($generation -eq 1){
+ $controllers = @($controllers) + @(Get-VMIdeController -VM $vmConfig.VM)
+ }
- # If the drive path is set, it is a harddisk, only support single harddisk
- if ($drive.Path) {
- $addDriveParam.add("ControllerType", $ControllerType)
- $vm | Add-VMHardDiskDrive @AddDriveparam
+ foreach($controller in $controllers){
+ foreach($drive in $controller.Drives){
+ if([System.IO.Path]::GetFileName($drive.Path) -eq [System.IO.Path]::GetFileName($source_path)){
+ # Remove the old disk and replace it with a differencing version
+ $path = $drive.Path
+ Remove-VMHardDiskDrive $drive
+ New-VHD -Path $dest_path -ParentPath $source_path -ErrorAction Stop
+ Add-VMHardDiskDrive -VM $vmConfig.VM -Path $dest_path
+ }
}
}
+
}
+
+Import-VM -CompatibilityReport $vmConfig
$vm_id = (Get-VM $vm_name).id.guid
$resultHash = @{
diff --git a/plugins/providers/hyperv/scripts/import_vm_xml.ps1 b/plugins/providers/hyperv/scripts/import_vm_xml.ps1
index cccb0a75c..16055e135 100644
--- a/plugins/providers/hyperv/scripts/import_vm_xml.ps1
+++ b/plugins/providers/hyperv/scripts/import_vm_xml.ps1
@@ -2,7 +2,7 @@ Param(
[Parameter(Mandatory=$true)]
[string]$vm_config_file,
[Parameter(Mandatory=$true)]
- [string]$image_path,
+ [string]$dest_path,
[string]$switchname=$null,
[string]$memory=$null,
@@ -190,7 +190,7 @@ foreach ($controller in $controllers) {
$addDriveParam = @{
ControllerNumber = $rx.Match($controller.node.name).value
- Path = $image_path
+ Path = $dest_path
}
if ($drive.pool_id."#text") {
From 7b03bf335baa6f50bb48d46e092480ee63d3add0 Mon Sep 17 00:00:00 2001
From: Bjorn Brala
Date: Sat, 8 Oct 2016 16:44:24 +0200
Subject: [PATCH 048/205] Whitespace
---
plugins/providers/hyperv/action/import.rb | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/plugins/providers/hyperv/action/import.rb b/plugins/providers/hyperv/action/import.rb
index 7be7265e0..f2e2bfade 100644
--- a/plugins/providers/hyperv/action/import.rb
+++ b/plugins/providers/hyperv/action/import.rb
@@ -7,7 +7,7 @@ module VagrantPlugins
module Action
class Import
def initialize(app, env)
- @app = app
+ @app = app
@logger = Log4r::Logger.new("vagrant::hyperv::import")
end
@@ -64,7 +64,7 @@ module VagrantPlugins
if %w{.vhd .vhdx}.include?(f.extname.downcase)
image_path = f
image_ext = f.extname.downcase
- image_filename = File.basename(f,image_ext)
+ image_filename = File.basename(f, image_ext)
break
end
end
@@ -114,8 +114,8 @@ module VagrantPlugins
end
env[:ui].detail("Cloning virtual hard drive...")
- source_path = image_path.to_s
- dest_path = env[:machine].data_dir.join("#{image_filename}#{image_ext}").to_s
+ source_path = image_path.to_s
+ dest_path = env[:machine].data_dir.join("#{image_filename}#{image_ext}").to_s
# Still hard copy the disk of old XML configurations
if config_type == 'xml'
@@ -130,11 +130,11 @@ module VagrantPlugins
# We have to normalize the paths to be Windows paths since
# we're executing PowerShell.
options = {
- vm_config_file: config_path.to_s.gsub("/", "\\"),
- vm_config_type: config_type,
- source_path: source_path.to_s,
- dest_path: env[:machine].data_dir.join("Virtual Hard Disks").join("#{image_filename}#{image_ext}").to_s,
- data_path: env[:machine].data_dir.to_s.gsub("/", "\\")
+ vm_config_file: config_path.to_s.gsub("/", "\\"),
+ vm_config_type: config_type,
+ source_path: source_path.to_s,
+ dest_path: env[:machine].data_dir.join("Virtual Hard Disks").join("#{image_filename}#{image_ext}").to_s,
+ data_path: env[:machine].data_dir.to_s.gsub("/", "\\")
}
options[:switchname] = switch if switch
options[:memory] = memory if memory
From c12101b2f8804580fe1a5c9cc4980e50da8e6637 Mon Sep 17 00:00:00 2001
From: Igor Vuk
Date: Sat, 8 Oct 2016 18:37:43 +0200
Subject: [PATCH 049/205] Fix a typo in configuration.html.md
---
website/source/docs/virtualbox/configuration.html.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/website/source/docs/virtualbox/configuration.html.md b/website/source/docs/virtualbox/configuration.html.md
index fe6040d59..bd1845bb1 100644
--- a/website/source/docs/virtualbox/configuration.html.md
+++ b/website/source/docs/virtualbox/configuration.html.md
@@ -67,7 +67,7 @@ config.vm.provider 'virtualbox' do |v|
end
```
-If you do not want backward compatbility and want to force users to
+If you do not want backward compatibility and want to force users to
support linked cloning, you can use `Vagrant.require_version` with 1.8.
From 8744caebcf50095e808233fd7282849115eddacb Mon Sep 17 00:00:00 2001
From: Bjorn Brala
Date: Sun, 9 Oct 2016 20:39:17 +0200
Subject: [PATCH 050/205] Small typo in options
---
plugins/providers/hyperv/driver.rb | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/plugins/providers/hyperv/driver.rb b/plugins/providers/hyperv/driver.rb
index d348cb79e..1a2f1dd39 100644
--- a/plugins/providers/hyperv/driver.rb
+++ b/plugins/providers/hyperv/driver.rb
@@ -78,9 +78,9 @@ module VagrantPlugins
if config_type === "vmcx"
execute('import_vm_vmcx.ps1', options)
else
- option.delete(:data_path)
- option.delete(:source_path)
- option.delete(:differencing_disk)
+ options.delete(:data_path)
+ options.delete(:source_path)
+ options.delete(:differencing_disk)
execute('import_vm_xml.ps1', options)
end
end
From 58f2b0c8c70c2ed7ab244c03fc8a50577fdfc90e Mon Sep 17 00:00:00 2001
From: Daniel Gonzalez
Date: Sun, 9 Oct 2016 20:48:50 +0200
Subject: [PATCH 051/205] Make ansible-playbook command configurable
The ansible-playbook command is currently hardcoded for the ansible and
ansible_local provisioners. This patch adds the config option
playbook_command to allow the user to change the command.
---
plugins/provisioners/ansible/config/base.rb | 38 ++++++++++---------
.../provisioners/ansible/provisioner/base.rb | 2 +-
.../provisioners/ansible/provisioner/host.rb | 2 +-
.../provisioners/ansible/config/guest_test.rb | 1 +
.../provisioners/ansible/config/host_test.rb | 1 +
5 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/plugins/provisioners/ansible/config/base.rb b/plugins/provisioners/ansible/config/base.rb
index 67642467e..6b9e73a40 100644
--- a/plugins/provisioners/ansible/config/base.rb
+++ b/plugins/provisioners/ansible/config/base.rb
@@ -4,6 +4,7 @@ module VagrantPlugins
class Base < Vagrant.plugin("2", :config)
GALAXY_COMMAND_DEFAULT = "ansible-galaxy install --role-file=%{role_file} --roles-path=%{roles_path} --force".freeze
+ PLAYBOOK_COMMAND_DEFAULT = "ansible-playbook".freeze
attr_accessor :extra_vars
attr_accessor :galaxy_role_file
@@ -14,6 +15,7 @@ module VagrantPlugins
attr_accessor :inventory_path
attr_accessor :limit
attr_accessor :playbook
+ attr_accessor :playbook_command
attr_accessor :raw_arguments
attr_accessor :skip_tags
attr_accessor :start_at_task
@@ -33,6 +35,7 @@ module VagrantPlugins
@inventory_path = UNSET_VALUE
@limit = UNSET_VALUE
@playbook = UNSET_VALUE
+ @playbook_command = UNSET_VALUE
@raw_arguments = UNSET_VALUE
@skip_tags = UNSET_VALUE
@start_at_task = UNSET_VALUE
@@ -44,23 +47,24 @@ module VagrantPlugins
end
def finalize!
- @extra_vars = nil if @extra_vars == UNSET_VALUE
- @galaxy_role_file = nil if @galaxy_role_file == UNSET_VALUE
- @galaxy_roles_path = nil if @galaxy_roles_path == UNSET_VALUE
- @galaxy_command = GALAXY_COMMAND_DEFAULT if @galaxy_command == UNSET_VALUE
- @host_vars = {} if @host_vars == UNSET_VALUE
- @groups = {} if @groups == UNSET_VALUE
- @inventory_path = nil if @inventory_path == UNSET_VALUE
- @limit = nil if @limit == UNSET_VALUE
- @playbook = nil if @playbook == UNSET_VALUE
- @raw_arguments = nil if @raw_arguments == UNSET_VALUE
- @skip_tags = nil if @skip_tags == UNSET_VALUE
- @start_at_task = nil if @start_at_task == UNSET_VALUE
- @sudo = false if @sudo != true
- @sudo_user = nil if @sudo_user == UNSET_VALUE
- @tags = nil if @tags == UNSET_VALUE
- @vault_password_file = nil if @vault_password_file == UNSET_VALUE
- @verbose = false if @verbose == UNSET_VALUE
+ @extra_vars = nil if @extra_vars == UNSET_VALUE
+ @galaxy_role_file = nil if @galaxy_role_file == UNSET_VALUE
+ @galaxy_roles_path = nil if @galaxy_roles_path == UNSET_VALUE
+ @galaxy_command = GALAXY_COMMAND_DEFAULT if @galaxy_command == UNSET_VALUE
+ @host_vars = {} if @host_vars == UNSET_VALUE
+ @groups = {} if @groups == UNSET_VALUE
+ @inventory_path = nil if @inventory_path == UNSET_VALUE
+ @limit = nil if @limit == UNSET_VALUE
+ @playbook = nil if @playbook == UNSET_VALUE
+ @playbook_command = PLAYBOOK_COMMAND_DEFAULT if @playbook_command == UNSET_VALUE
+ @raw_arguments = nil if @raw_arguments == UNSET_VALUE
+ @skip_tags = nil if @skip_tags == UNSET_VALUE
+ @start_at_task = nil if @start_at_task == UNSET_VALUE
+ @sudo = false if @sudo != true
+ @sudo_user = nil if @sudo_user == UNSET_VALUE
+ @tags = nil if @tags == UNSET_VALUE
+ @vault_password_file = nil if @vault_password_file == UNSET_VALUE
+ @verbose = false if @verbose == UNSET_VALUE
end
# Just like the normal configuration "validate" method except that
diff --git a/plugins/provisioners/ansible/provisioner/base.rb b/plugins/provisioners/ansible/provisioner/base.rb
index bbfaa5290..e0807ec27 100644
--- a/plugins/provisioners/ansible/provisioner/base.rb
+++ b/plugins/provisioners/ansible/provisioner/base.rb
@@ -44,7 +44,7 @@ module VagrantPlugins
end
end
- shell_command << "ansible-playbook"
+ shell_command << config.playbook_command
shell_args = []
@command_arguments.each do |arg|
diff --git a/plugins/provisioners/ansible/provisioner/host.rb b/plugins/provisioners/ansible/provisioner/host.rb
index 990b730dd..697ad51a8 100644
--- a/plugins/provisioners/ansible/provisioner/host.rb
+++ b/plugins/provisioners/ansible/provisioner/host.rb
@@ -113,7 +113,7 @@ module VagrantPlugins
prepare_environment_variables
# Assemble the full ansible-playbook command
- command = %w(ansible-playbook) << @command_arguments
+ command = [config.playbook_command] << @command_arguments
# Add the raw arguments at the end, to give them the highest precedence
command << config.raw_arguments if config.raw_arguments
diff --git a/test/unit/plugins/provisioners/ansible/config/guest_test.rb b/test/unit/plugins/provisioners/ansible/config/guest_test.rb
index c1c389686..1249bd834 100644
--- a/test/unit/plugins/provisioners/ansible/config/guest_test.rb
+++ b/test/unit/plugins/provisioners/ansible/config/guest_test.rb
@@ -27,6 +27,7 @@ describe VagrantPlugins::Ansible::Config::Guest do
inventory_path
limit
playbook
+ playbook_command
provisioning_path
raw_arguments
skip_tags
diff --git a/test/unit/plugins/provisioners/ansible/config/host_test.rb b/test/unit/plugins/provisioners/ansible/config/host_test.rb
index f6871c209..fefcbfb6a 100644
--- a/test/unit/plugins/provisioners/ansible/config/host_test.rb
+++ b/test/unit/plugins/provisioners/ansible/config/host_test.rb
@@ -26,6 +26,7 @@ describe VagrantPlugins::Ansible::Config::Host, :skip_windows => true do
inventory_path
limit
playbook
+ playbook_command
raw_arguments
raw_ssh_args
skip_tags
From 42efd5c198eda098a7e489db8ac5a1c7289f6bb8 Mon Sep 17 00:00:00 2001
From: Bjorn Brala
Date: Sun, 9 Oct 2016 21:10:56 +0200
Subject: [PATCH 052/205] Make the Virtual Hard Disks directory if importing
from XML to keep it consistant across config types
---
plugins/providers/hyperv/action/import.rb | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/plugins/providers/hyperv/action/import.rb b/plugins/providers/hyperv/action/import.rb
index f2e2bfade..548dbdc39 100644
--- a/plugins/providers/hyperv/action/import.rb
+++ b/plugins/providers/hyperv/action/import.rb
@@ -115,13 +115,14 @@ module VagrantPlugins
env[:ui].detail("Cloning virtual hard drive...")
source_path = image_path.to_s
- dest_path = env[:machine].data_dir.join("#{image_filename}#{image_ext}").to_s
+ dest_path = env[:machine].data_dir.join("Virtual Hard Disks").join("#{image_filename}#{image_ext}").to_s
# Still hard copy the disk of old XML configurations
if config_type == 'xml'
if differencing_disk
env[:machine].provider.driver.execute("clone_vhd.ps1", {Source: source_path, Destination: dest_path})
else
+ FileUtils.mkdir_p(env[:machine].data_dir.join("Virtual Hard Disks"))
FileUtils.cp(source_path, dest_path)
end
end
@@ -133,7 +134,7 @@ module VagrantPlugins
vm_config_file: config_path.to_s.gsub("/", "\\"),
vm_config_type: config_type,
source_path: source_path.to_s,
- dest_path: env[:machine].data_dir.join("Virtual Hard Disks").join("#{image_filename}#{image_ext}").to_s,
+ dest_path: dest_path,
data_path: env[:machine].data_dir.to_s.gsub("/", "\\")
}
options[:switchname] = switch if switch
From 79a3cb8a143ddbe2ba906ccb85907110836ac9c8 Mon Sep 17 00:00:00 2001
From: Daniel Gonzalez
Date: Mon, 10 Oct 2016 16:56:36 +0200
Subject: [PATCH 053/205] Add unit test and documentation for playbook_command
option
---
.../plugins/provisioners/ansible/config/shared.rb | 1 +
.../plugins/provisioners/ansible/provisioner_test.rb | 12 ++++++++++++
.../source/docs/provisioning/ansible_common.html.md | 4 ++++
3 files changed, 17 insertions(+)
diff --git a/test/unit/plugins/provisioners/ansible/config/shared.rb b/test/unit/plugins/provisioners/ansible/config/shared.rb
index 7ff56ee91..c59a31a94 100644
--- a/test/unit/plugins/provisioners/ansible/config/shared.rb
+++ b/test/unit/plugins/provisioners/ansible/config/shared.rb
@@ -12,6 +12,7 @@ shared_examples_for 'options shared by both Ansible provisioners' do
expect(subject.inventory_path).to be_nil
expect(subject.limit).to be_nil
expect(subject.playbook).to be_nil
+ expect(subject.playbook_command).to eql("ansible-playbook")
expect(subject.raw_arguments).to be_nil
expect(subject.skip_tags).to be_nil
expect(subject.start_at_task).to be_nil
diff --git a/test/unit/plugins/provisioners/ansible/provisioner_test.rb b/test/unit/plugins/provisioners/ansible/provisioner_test.rb
index c26cecf8d..64d58d341 100644
--- a/test/unit/plugins/provisioners/ansible/provisioner_test.rb
+++ b/test/unit/plugins/provisioners/ansible/provisioner_test.rb
@@ -273,6 +273,18 @@ VF
end
end
+ describe "with playbook_command option" do
+ before do
+ config.playbook_command = "custom-ansible-playbook"
+ end
+
+ it "uses custom playbook_command to run playbooks" do
+ expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
+ expect(args[0]).to eq("custom-ansible-playbook")
+ }
+ end
+ end
+
describe "with host_vars option" do
it_should_create_and_use_generated_inventory
diff --git a/website/source/docs/provisioning/ansible_common.html.md b/website/source/docs/provisioning/ansible_common.html.md
index 23817b983..81316fa30 100644
--- a/website/source/docs/provisioning/ansible_common.html.md
+++ b/website/source/docs/provisioning/ansible_common.html.md
@@ -78,6 +78,10 @@ Some of these options are for advanced usage only and should not be used unless
By default, this option is disabled and Vagrant generates an inventory based on the `Vagrantfile` information.
+- `playbook_command` (string) - The command used to run playbooks.
+
+ The default value is `ansible-playbook`
+
- `galaxy_command` (template string) - The command pattern used to install Galaxy roles when `galaxy_role_file` is set.
The following (optional) placeholders can be used in this command pattern:
From a8970281ced199a43ca9b0a4d5b0b97aff02a2e2 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Mon, 10 Oct 2016 10:22:07 -0700
Subject: [PATCH 054/205] guests/linux: Properly sort interface name types
Add failing networking interface list sorting test with example
provided by #7883. Update sorting logic to properly handle different
types and differing array lengths.
Fixes #7883
---
.../guests/linux/cap/network_interfaces.rb | 20 ++++++++++++++++++-
.../linux/cap/network_interfaces_test.rb | 10 ++++++++--
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/plugins/guests/linux/cap/network_interfaces.rb b/plugins/guests/linux/cap/network_interfaces.rb
index c66de24c4..9a7db83d1 100644
--- a/plugins/guests/linux/cap/network_interfaces.rb
+++ b/plugins/guests/linux/cap/network_interfaces.rb
@@ -23,6 +23,9 @@ module VagrantPlugins
@@logger.debug("Unsorted list: #{ifaces.inspect}")
# Break out integers from strings and sort the arrays to provide
# a natural sort for the interface names
+ # NOTE: Devices named with a hex value suffix will _not_ be sorted
+ # as expected. This is generally seen with veth* devices, and proper ordering
+ # is currently not required
ifaces = ifaces.map do |iface|
iface.scan(/(.+?)(\d+)/).flatten.map do |iface_part|
if iface_part.to_i.to_s == iface_part
@@ -31,7 +34,22 @@ module VagrantPlugins
iface_part
end
end
- end.sort.map(&:join)
+ end
+ ifaces = ifaces.sort do |lhs, rhs|
+ result = 0
+ slice_length = [rhs.size, lhs.size].min
+ slice_length.times do |idx|
+ if(lhs[idx].is_a?(rhs[idx].class))
+ result = lhs[idx] <=> rhs[idx]
+ elsif(lhs[idx].is_a?(String))
+ result = 1
+ else
+ result = -1
+ end
+ break if result != 0
+ end
+ result
+ end.map(&:join)
@@logger.debug("Sorted list: #{ifaces.inspect}")
# Extract ethernet devices and place at start of list
resorted_ifaces = []
diff --git a/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb b/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb
index 5c6a36546..5142beaa2 100644
--- a/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb
+++ b/test/unit/plugins/guests/linux/cap/network_interfaces_test.rb
@@ -64,9 +64,15 @@ describe "VagrantPlugins::GuestLinux::Cap::NetworkInterfaces" do
end
it "does not include ethernet devices aliases within prefix device listing" do
- expect(comm).to receive(:sudo).and_yield(:stdout, "eth1\neth2\ndocker0\nbridge0\neth0\neth0:0")
+ expect(comm).to receive(:sudo).and_yield(:stdout, "eth1\neth2\ndocker0\nbridge0\neth0\ndocker1\neth0:0")
result = cap.network_interfaces(machine)
- expect(result).to eq(["eth0", "eth1", "eth2", "bridge0", "docker0", "eth0:0"])
+ expect(result).to eq(["eth0", "eth1", "eth2", "bridge0", "docker0", "docker1", "eth0:0"])
+ end
+
+ it "properly sorts non-consistent device name formats" do
+ expect(comm).to receive(:sudo).and_yield(:stdout, "eth0\neth1\ndocker0\nveth437f7f9\nveth06b3e44\nveth8bb7081")
+ result = cap.network_interfaces(machine)
+ expect(result).to eq(["eth0", "eth1", "docker0", "veth8bb7081", "veth437f7f9", "veth06b3e44"])
end
end
end
From 7784d3dab8acced7a0661a84636b3f62622dbb59 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Mon, 10 Oct 2016 10:58:57 -0700
Subject: [PATCH 055/205] Update CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f48521c5d..03da82a87 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ BUG FIXES:
- communicators/winrm: Prevent connection leakage [GH-7712]
- core: Prevent duplicate provider priorities [GH-7756]
+ - core: Allow Numeric type for box version [GH-7874, GH-6960]
- guests/linux: Fix incorrectly configured private network [GH-7844, GH-7848]
- guests/linux: Only emit upstart event if initctl is available [GH-7813]
- guests/photon: Fix networking setup [GH-7808, GH-7873]
From c867a01ebbc8f8cc5b19c37cfa7d6df2b4c06a18 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Mon, 10 Oct 2016 11:02:23 -0700
Subject: [PATCH 056/205] Update CHANGELOG
---
CHANGELOG.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 03da82a87..de580cdac 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,8 @@ BUG FIXES:
- core: Prevent duplicate provider priorities [GH-7756]
- core: Allow Numeric type for box version [GH-7874, GH-6960]
- guests/linux: Fix incorrectly configured private network [GH-7844, GH-7848]
+ - guests/linux: Properly order network interfaces
+ [GH-7866, GH-7876, GH-7858, GH-7876]
- guests/linux: Only emit upstart event if initctl is available [GH-7813]
- guests/photon: Fix networking setup [GH-7808, GH-7873]
- guests/redhat: Properly configure network and restart service [GH-7751]
From a55590b84f53075d30081795087c32459f748166 Mon Sep 17 00:00:00 2001
From: Gilles Cornu
Date: Mon, 10 Oct 2016 21:45:29 +0200
Subject: [PATCH 057/205] provisioners/ansible_local: Change binary detection
- Remove `ansible-galaxy` detection, since this command was introduced
in Ansible 1.4.2 (December 2013). Checking for `ansible-playbook`
presence should therefore be enough for any "modern" Ansible setup.
- Look for the command defined by the new `playbook_command` option.
Related to GH-7881 and GH-7536
---
plugins/provisioners/ansible/provisioner/guest.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/provisioners/ansible/provisioner/guest.rb b/plugins/provisioners/ansible/provisioner/guest.rb
index 66bc063c2..0d165db7e 100644
--- a/plugins/provisioners/ansible/provisioner/guest.rb
+++ b/plugins/provisioners/ansible/provisioner/guest.rb
@@ -52,9 +52,9 @@ module VagrantPlugins
@machine.guest.capability(:ansible_install, config.install_mode, config.version)
end
- # Check that ansible binaries are well installed on the guest,
+ # Check that Ansible Playbook command is available on the guest
@machine.communicate.execute(
- 'test -x "$(command -v ansible-galaxy)" && test -x "$(command -v ansible-playbook)"',
+ "test -x \"$(command -v #{config.playbook_command})\"",
error_class: Ansible::Errors::AnsibleNotFoundOnGuest,
error_key: :ansible_not_found_on_guest
)
From 29b033390f4a10ec21cdd900e99a5925b605843b Mon Sep 17 00:00:00 2001
From: Gilles Cornu
Date: Mon, 10 Oct 2016 23:35:20 +0200
Subject: [PATCH 058/205] Update CHANGELOG
[ci skip]
---
CHANGELOG.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index de580cdac..c0e751685 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,8 @@ IMPROVEMENTS:
- guests/linux: Place ethernet devices at start of network devices list [GH-7848]
- guests/windows: Allow vagrant to start Windows Nano without provisioning [GH-7831]
+ - provisioners/ansible_local: Change the Ansible binary detection mechanism [GH-7536]
+ - provisioners/ansible(both): Add the `playbook_command` option [GH-7881]
- util/safe_exec: Use subprocess for safe_exec on Windows [GH-7802]
- util/subprocess: Allow closing STDIN [GH-7778]
From 6050b13f43430142d54b09c54f2167300c63c9e0 Mon Sep 17 00:00:00 2001
From: Reto Gantenbein
Date: Mon, 26 Sep 2016 12:18:38 +0200
Subject: [PATCH 059/205] Make Debian guest detection more reliable
/etc/issue is far from being a reliable source for OS detection as it
can be changed by a user without affecting any OS functionality. As
newer Debian systems run systemd by default, check for /etc/os-release
and fallback to lsb_release for older Debian versions. Check #7625 for
a similar issue. Even lsb_release is not manatory, therefore keep the
current code of parsing /etc/issue to avoid regressions.
---
plugins/guests/debian/guest.rb | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/plugins/guests/debian/guest.rb b/plugins/guests/debian/guest.rb
index 6631bda6c..7fac75df0 100644
--- a/plugins/guests/debian/guest.rb
+++ b/plugins/guests/debian/guest.rb
@@ -4,7 +4,17 @@ module VagrantPlugins
module GuestDebian
class Guest < Vagrant.plugin("2", :guest)
def detect?(machine)
- machine.communicate.test("cat /etc/issue | grep 'Debian'")
+ machine.communicate.test <<-EOH.gsub(/^ {10}/, "")
+ if test -r /etc/os-release; then
+ source /etc/os-release && test xdebian = x$ID
+ elif test -x /usr/bin/lsb_release; then
+ /usr/bin/lsb_release -i 2>/dev/null | grep -q Debian
+ elif test -r /etc/issue; then
+ cat /etc/issue | grep 'Debian'
+ else
+ exit 1
+ fi
+ EOH
end
end
end
From d0549d6e11e5bc4a5f1dd55872fa1ca2a3fc2a79 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Tue, 11 Oct 2016 07:50:34 -0700
Subject: [PATCH 060/205] guests/linux: Provide common linux detection style
Defines a common and generic linux detection strategy which can be
subclassed and easily reused by providing a custom detection constant.
---
plugins/guests/debian/guest.rb | 19 ++++---------------
plugins/guests/linux/guest.rb | 16 +++++++++++++++-
plugins/guests/mint/guest.rb | 9 +++++----
plugins/guests/tinycore/guest.rb | 9 ++++-----
plugins/guests/ubuntu/guest.rb | 24 +++++-------------------
5 files changed, 33 insertions(+), 44 deletions(-)
diff --git a/plugins/guests/debian/guest.rb b/plugins/guests/debian/guest.rb
index 7fac75df0..9fb54c670 100644
--- a/plugins/guests/debian/guest.rb
+++ b/plugins/guests/debian/guest.rb
@@ -1,21 +1,10 @@
-require "vagrant"
+require_relative '../linux/guest'
module VagrantPlugins
module GuestDebian
- class Guest < Vagrant.plugin("2", :guest)
- def detect?(machine)
- machine.communicate.test <<-EOH.gsub(/^ {10}/, "")
- if test -r /etc/os-release; then
- source /etc/os-release && test xdebian = x$ID
- elif test -x /usr/bin/lsb_release; then
- /usr/bin/lsb_release -i 2>/dev/null | grep -q Debian
- elif test -r /etc/issue; then
- cat /etc/issue | grep 'Debian'
- else
- exit 1
- fi
- EOH
- end
+ class Guest < VagrantPlugins::GuestLinux::Guest
+ # Name used for guest detection
+ GUEST_DETECTION_NAME = "debian".freeze
end
end
end
diff --git a/plugins/guests/linux/guest.rb b/plugins/guests/linux/guest.rb
index 8effae8ad..d86d1daf3 100644
--- a/plugins/guests/linux/guest.rb
+++ b/plugins/guests/linux/guest.rb
@@ -1,8 +1,22 @@
module VagrantPlugins
module GuestLinux
class Guest < Vagrant.plugin("2", :guest)
+ # Name used for guest detection
+ GUEST_DETECTION_NAME = "linux".freeze
+
def detect?(machine)
- machine.communicate.test("uname -s | grep 'Linux'")
+ machine.communicate.test <<-EOH.gsub(/^ */, '')
+ if test -r /etc/os-release; then
+ source /etc/os-release && test x#{self.class.const_get(:GUEST_DETECTION_NAME)} = x$ID && exit
+ fi
+ if test -x /usr/bin/lsb_release; then
+ /usr/bin/lsb_release -i 2>/dev/null | grep -qi #{self.class.const_get(:GUEST_DETECTION_NAME)} && exit
+ fi
+ if test -r /etc/issue; then
+ cat /etc/issue | grep -qi #{self.class.const_get(:GUEST_DETECTION_NAME)} && exit
+ fi
+ exit 1
+ EOH
end
end
end
diff --git a/plugins/guests/mint/guest.rb b/plugins/guests/mint/guest.rb
index d12e42055..b03d43c83 100644
--- a/plugins/guests/mint/guest.rb
+++ b/plugins/guests/mint/guest.rb
@@ -1,9 +1,10 @@
+require_relative '../linux/guest'
+
module VagrantPlugins
module GuestMint
- class Guest < Vagrant.plugin("2", :guest)
- def detect?(machine)
- machine.communicate.test("cat /etc/issue | grep 'Linux Mint'")
- end
+ class Guest < VagrantPlugins::GuestLinux::Guest
+ # Name used for guest detection
+ GUEST_DETECTION_NAME = "Linux Mint".freeze
end
end
end
diff --git a/plugins/guests/tinycore/guest.rb b/plugins/guests/tinycore/guest.rb
index ae24f0066..d1fea1aed 100644
--- a/plugins/guests/tinycore/guest.rb
+++ b/plugins/guests/tinycore/guest.rb
@@ -1,11 +1,10 @@
-require "vagrant"
+require_relative '../linux/guest'
module VagrantPlugins
module GuestTinyCore
- class Guest < Vagrant.plugin("2", :guest)
- def detect?(machine)
- machine.communicate.test("cat /etc/issue | grep 'Core Linux'")
- end
+ class Guest < VagrantPlugins::GuestLinux::Guest
+ # Name used for guest detection
+ GUEST_DETECTION_NAME = "Core Linux".freeze
end
end
end
diff --git a/plugins/guests/ubuntu/guest.rb b/plugins/guests/ubuntu/guest.rb
index f60108eab..09d02b236 100644
--- a/plugins/guests/ubuntu/guest.rb
+++ b/plugins/guests/ubuntu/guest.rb
@@ -1,24 +1,10 @@
+require_relative '../linux/guest'
+
module VagrantPlugins
module GuestUbuntu
- class Guest < Vagrant.plugin("2", :guest)
- def detect?(machine)
- # This command detects if we are running on Ubuntu. /etc/os-release is
- # available on modern Ubuntu versions, but does not exist on 14.04 and
- # previous versions, so we fall back to lsb_release.
- #
- # GH-7524
- # GH-7625
- #
- machine.communicate.test <<-EOH.gsub(/^ {10}/, "")
- if test -r /etc/os-release; then
- source /etc/os-release && test xubuntu = x$ID
- elif test -x /usr/bin/lsb_release; then
- /usr/bin/lsb_release -i 2>/dev/null | grep -q Ubuntu
- else
- exit 1
- fi
- EOH
- end
+ class Guest < VagrantPlugins::GuestLinux::Guest
+ # Name used for guest detection
+ GUEST_DETECTION_NAME = "ubuntu".freeze
end
end
end
From 2c9c458e42084cceedb5e7412d6a96bdaa38bcc5 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Tue, 11 Oct 2016 10:36:26 -0700
Subject: [PATCH 061/205] Update CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c0e751685..542f53413 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@ FEATURES:
IMPROVEMENTS:
- guests/linux: Place ethernet devices at start of network devices list [GH-7848]
+ - guests/redhat: Include Virtuozzo Linux 7 within flavor identification [GH-7818]
- guests/windows: Allow vagrant to start Windows Nano without provisioning [GH-7831]
- provisioners/ansible_local: Change the Ansible binary detection mechanism [GH-7536]
- provisioners/ansible(both): Add the `playbook_command` option [GH-7881]
From 3e46e8bcb7a4a2f3c7dc507da15a384e78f4b695 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Tue, 11 Oct 2016 10:47:08 -0700
Subject: [PATCH 062/205] core: Rescue EINVAL exceptions when loading bundler
---
bin/vagrant | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/bin/vagrant b/bin/vagrant
index b9ef5feee..8319fef1f 100755
--- a/bin/vagrant
+++ b/bin/vagrant
@@ -66,7 +66,22 @@ end
# Setup our dependencies by initializing Bundler. If we're using plugins,
# then also initialize the paths to the plugins.
-require "bundler"
+begin
+ require "bundler"
+rescue Errno::EINVAL
+ # Bundler can generated the EINVAL error during initial require, which means
+ # nothing has yet been setup (so no access to I18n). Note that vagrant has
+ # failed early and copy information related to problem and possible solution.
+ $stderr.puts "Vagrant failed to initialize at a very early stage:\n\n"
+ $stderr.puts "Vagrant received an "EINVAL" error while attempting to set some"
+ $stderr.puts "environment variables. This is usually caused by the total size of your"
+ $stderr.puts "environment variables being too large. Vagrant sets a handful of"
+ $stderr.puts "environment variables to function and requires this to work. Please"
+ $stderr.puts "delete some environment variables prior to executing Vagrant to"
+ $stderr.puts "fix this."
+ exit 255
+end
+
begin
$vagrant_bundler_runtime = Bundler.setup(:default, :plugins)
rescue Bundler::GemNotFound
From cc06644cd029c0f8ede3aaafb943637a629ba931 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Tue, 11 Oct 2016 12:57:13 -0700
Subject: [PATCH 063/205] Update CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 542f53413..af615c231 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@ FEATURES:
IMPROVEMENTS:
- guests/linux: Place ethernet devices at start of network devices list [GH-7848]
+ - guests/linux: Provide more consistent guest detection [GH-7887, GH-7827]
- guests/redhat: Include Virtuozzo Linux 7 within flavor identification [GH-7818]
- guests/windows: Allow vagrant to start Windows Nano without provisioning [GH-7831]
- provisioners/ansible_local: Change the Ansible binary detection mechanism [GH-7536]
From e54bcbb76963e90f274bdb51383e6369f934c45a Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Tue, 11 Oct 2016 12:59:20 -0700
Subject: [PATCH 064/205] Update CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index af615c231..c79e59494 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,6 +18,7 @@ BUG FIXES:
- communicators/winrm: Prevent connection leakage [GH-7712]
- core: Prevent duplicate provider priorities [GH-7756]
- core: Allow Numeric type for box version [GH-7874, GH-6960]
+ - core: Provide friendly error when user environment is too large [GH-7889, GH-7857]
- guests/linux: Fix incorrectly configured private network [GH-7844, GH-7848]
- guests/linux: Properly order network interfaces
[GH-7866, GH-7876, GH-7858, GH-7876]
From 803fff7f0381a1092ab0f20cdd14afb0f424438d Mon Sep 17 00:00:00 2001
From: Jake Ballard
Date: Tue, 11 Oct 2016 15:31:28 -0500
Subject: [PATCH 065/205] Fix issue with missing slash in paths
It was failing to create files below the machines\default\hyperv folder, rather it was creating folders named 'hypervSnapshots', 'hypervVirtual Hard Disks', and 'hypervVirtual Machines'. This was causing the files to not be removed when destroying the vm, and an error when subsequently bringing it up again.
---
plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
index b31c1528d..b87077bdc 100644
--- a/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
+++ b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
@@ -25,7 +25,14 @@ $Dir = Split-Path $script:MyInvocation.MyCommand.Path
. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1"))
# load the config from the vmcx and make a copy for editing, use TMP path so we are sure there is no vhd at the destination
-$vmConfig = (Compare-VM -Copy -Path $vm_config_file -GenerateNewID -SnapshotFilePath "$($data_path)Snapshots" -VhdDestinationPath "$($data_path)Virtual Hard Disks" -VirtualMachinePath "$($data_path)Virtual Machines")
+$VmProperties = @{
+ Path = $vm_config_file
+ SnapshotFilePath = Join-Path $data_path 'Snapshots'
+ VhdDestinationPath = Join-Path $data_path 'Virtual Hard Disks'
+ VirtualMachinePath = Join-Path $data_path 'Virtual Machines'
+}
+
+$vmConfig = (Compare-VM -Copy -GenerateNewID @VmProperties)
$generation = $vmConfig.VM.Generation
From 585ee76a006f78a463650e0d447567fd2fc122f6 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Tue, 11 Oct 2016 15:04:43 -0700
Subject: [PATCH 066/205] Escape nested quotes within error message
---
bin/vagrant | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bin/vagrant b/bin/vagrant
index 8319fef1f..43ec25ba9 100755
--- a/bin/vagrant
+++ b/bin/vagrant
@@ -73,7 +73,7 @@ rescue Errno::EINVAL
# nothing has yet been setup (so no access to I18n). Note that vagrant has
# failed early and copy information related to problem and possible solution.
$stderr.puts "Vagrant failed to initialize at a very early stage:\n\n"
- $stderr.puts "Vagrant received an "EINVAL" error while attempting to set some"
+ $stderr.puts "Vagrant received an \"EINVAL\" error while attempting to set some"
$stderr.puts "environment variables. This is usually caused by the total size of your"
$stderr.puts "environment variables being too large. Vagrant sets a handful of"
$stderr.puts "environment variables to function and requires this to work. Please"
From 1d401ebc95b44695223ca00441c08db02c7d3dda Mon Sep 17 00:00:00 2001
From: Nick Walker
Date: Thu, 13 Oct 2016 13:31:16 -0700
Subject: [PATCH 067/205] Update snapshot save documentation
Prior to this commit, the snapshot save command did not have the vm_name as part of the command.
After this commit, the snapshot save command docs match the CLI --help.
---
website/source/docs/cli/snapshot.html.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/website/source/docs/cli/snapshot.html.md b/website/source/docs/cli/snapshot.html.md
index 432336dea..7c83c3138 100644
--- a/website/source/docs/cli/snapshot.html.md
+++ b/website/source/docs/cli/snapshot.html.md
@@ -58,7 +58,7 @@ the pushed state.
# Snapshot Save
-**Command: `vagrant snapshot save NAME`**
+**Command: `vagrant snapshot save [vm-name] NAME`**
This command saves a new named snapshot. If this command is used, the
`push` and `pop` subcommands cannot be safely used.
From 734fa7bbbb96ba413826f33b5586a6c3d8f6ba05 Mon Sep 17 00:00:00 2001
From: Jon Forrest
Date: Thu, 13 Oct 2016 14:46:43 -0700
Subject: [PATCH 068/205] Update common-issues.html.md
---
website/source/docs/virtualbox/common-issues.html.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/website/source/docs/virtualbox/common-issues.html.md b/website/source/docs/virtualbox/common-issues.html.md
index 6b0778943..30af68cb2 100644
--- a/website/source/docs/virtualbox/common-issues.html.md
+++ b/website/source/docs/virtualbox/common-issues.html.md
@@ -16,7 +16,7 @@ as well as solutions for those issues.
If Vagrant commands are hanging on Windows because they're communicating
to VirtualBox, this may be caused by a permissions issue with VirtualBox.
-This is easy to fix. Start VirtualBox as a normal user or as an
+This is easy to fix. Starting VirtualBox as a normal user or as an
administrator will prevent you from using it in the opposite way. Please keep
in mind that when Vagrant interacts with VirtualBox, it will interact with
it with the same access level as the console running Vagrant.
From 418064519df5ab119f15cf031d1b5e33b1285078 Mon Sep 17 00:00:00 2001
From: Brian Retford
Date: Fri, 14 Oct 2016 18:53:44 -0700
Subject: [PATCH 069/205] Move dynamic memory settings into conditional block
---
plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
index b87077bdc..f66c181f6 100644
--- a/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
+++ b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
@@ -97,11 +97,11 @@ if (!$switchname) {
Connect-VMNetworkAdapter -VMNetworkAdapter (Get-VMNetworkAdapter -VM $vmConfig.VM) -SwitchName $switchname
Set-VM -VM $vmConfig.VM -NewVMName $vm_name -MemoryStartupBytes $MemoryStartupBytes
-Set-VM -VM $vmConfig.VM -MemoryMinimumBytes $MemoryMinimumBytes -MemoryMaximumBytes $MemoryMaximumBytes
Set-VM -VM $vmConfig.VM -ErrorAction "Stop" -ProcessorCount $processors
If ($dynamicmemory) {
Set-VM -VM $vmConfig.VM -DynamicMemory
+ Set-VM -VM $vmConfig.VM -MemoryMinimumBytes $MemoryMinimumBytes -MemoryMaximumBytes $MemoryMaximumBytes
} else {
Set-VM -VM $vmConfig.VM -StaticMemory
}
From fa2a9105f0563664f91f9679a106706aaa976b7d Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Mon, 17 Oct 2016 09:35:05 -0700
Subject: [PATCH 070/205] provisioners/salt: Synchronize config defaults with
documentation
---
plugins/provisioners/salt/config.rb | 19 +++++++-----
plugins/provisioners/salt/provisioner.rb | 31 ++++++++++++++++---
website/source/docs/provisioning/salt.html.md | 10 +++---
3 files changed, 43 insertions(+), 17 deletions(-)
diff --git a/plugins/provisioners/salt/config.rb b/plugins/provisioners/salt/config.rb
index c0e84d932..750ec3579 100644
--- a/plugins/provisioners/salt/config.rb
+++ b/plugins/provisioners/salt/config.rb
@@ -74,12 +74,6 @@ module VagrantPlugins
end
def finalize!
- @minion_config = nil if @minion_config == UNSET_VALUE
- @minion_key = nil if @minion_key == UNSET_VALUE
- @minion_pub = nil if @minion_pub == UNSET_VALUE
- @master_config = nil if @master_config == UNSET_VALUE
- @master_key = nil if @master_key == UNSET_VALUE
- @master_pub = nil if @master_pub == UNSET_VALUE
@grains_config = nil if @grains_config == UNSET_VALUE
@run_highstate = nil if @run_highstate == UNSET_VALUE
@run_overstate = nil if @run_overstate == UNSET_VALUE
@@ -102,6 +96,15 @@ module VagrantPlugins
@version = nil if @version == UNSET_VALUE
@run_service = nil if @run_service == UNSET_VALUE
@master_id = nil if @master_id == UNSET_VALUE
+
+ # NOTE: Optimistic defaults are set in the provisioner. UNSET_VALUEs
+ # are converted there to allow proper detection of unset values.
+ # @minion_config = nil if @minion_config == UNSET_VALUE
+ # @minion_key = nil if @minion_key == UNSET_VALUE
+ # @minion_pub = nil if @minion_pub == UNSET_VALUE
+ # @master_config = nil if @master_config == UNSET_VALUE
+ # @master_key = nil if @master_key == UNSET_VALUE
+ # @master_pub = nil if @master_pub == UNSET_VALUE
end
def pillar(data)
@@ -111,14 +114,14 @@ module VagrantPlugins
def validate(machine)
errors = _detected_errors
- if @minion_config
+ if @minion_config && @minion_config != UNSET_VALUE
expanded = Pathname.new(@minion_config).expand_path(machine.env.root_path)
if !expanded.file?
errors << I18n.t("vagrant.provisioners.salt.minion_config_nonexist", missing_config_file: expanded)
end
end
- if @master_config
+ if @master_config && @master_config != UNSET_VALUE
expanded = Pathname.new(@master_config).expand_path(machine.env.root_path)
if !expanded.file?
errors << I18n.t("vagrant.provisioners.salt.master_config_nonexist", missing_config_file: expanded)
diff --git a/plugins/provisioners/salt/provisioner.rb b/plugins/provisioners/salt/provisioner.rb
index eb9e16887..76ee4c54f 100644
--- a/plugins/provisioners/salt/provisioner.rb
+++ b/plugins/provisioners/salt/provisioner.rb
@@ -3,7 +3,20 @@ require 'json'
module VagrantPlugins
module Salt
class Provisioner < Vagrant.plugin("2", :provisioner)
+
+ # Default path values to set within configuration only
+ # if configuration value is unset and local path exists
+ OPTIMISTIC_PATH_DEFAULTS = Hash[[
+ "minion_config", "salt/minion",
+ "minion_key", "salt/key/minion.key",
+ "minion_pub", "salt/key/minion.pub",
+ "master_config", "salt/master",
+ "master_key", "salt/key/master.key",
+ "master_pub", "salt/key/master.pub"
+ ].map(&:freeze)].freeze
+
def provision
+ set_default_configs
upload_configs
upload_keys
run_bootstrap_script
@@ -238,19 +251,19 @@ module VagrantPlugins
bootstrap_path = get_bootstrap
if @machine.config.vm.communicator == :winrm
if @config.version
- options += " -version %s" % @config.version
+ options += " -version %s" % @config.version
end
if @config.run_service
@machine.env.ui.info "Salt minion will be stopped after installing."
- options += " -runservice %s" % @config.run_service
+ options += " -runservice %s" % @config.run_service
end
if @config.minion_id
@machine.env.ui.info "Setting minion to @config.minion_id."
- options += " -minion %s" % @config.minion_id
+ options += " -minion %s" % @config.minion_id
end
if @config.master_id
@machine.env.ui.info "Setting master to @config.master_id."
- options += " -master %s" % @config.master_id
+ options += " -master %s" % @config.master_id
end
bootstrap_destination = File.join(config_dir, "bootstrap_salt.ps1")
else
@@ -390,6 +403,16 @@ module VagrantPlugins
@machine.communicate.sudo(cmd, &log_output)
end
end
+
+ # Sets optimistic default values into config
+ def set_default_configs
+ OPTIMISTIC_PATH_DEFAULTS.each do |config_key, config_default|
+ if config.send(config_key) == Config::UNSET_VALUE
+ config_value = File.exist?(expanded_path(config_default)) ? config_default : nil
+ config.send("#{config_key}=", config_value)
+ end
+ end
+ end
end
end
end
diff --git a/website/source/docs/provisioning/salt.html.md b/website/source/docs/provisioning/salt.html.md
index 63d1932b5..36416936c 100644
--- a/website/source/docs/provisioning/salt.html.md
+++ b/website/source/docs/provisioning/salt.html.md
@@ -62,7 +62,7 @@ on this machine. Not supported on Windows guest machines.
* `install_type` (stable | git | daily | testing) - Whether to install from a
distribution's stable package manager, git tree-ish, daily ppa, or testing repository.
-* `install_args` (develop) - When performing a git install, you can specify a branch, tag, or any treeish. Not supported on Windows.
+* `install_args` (string, default: "develop") - When performing a git install, you can specify a branch, tag, or any treeish. Not supported on Windows.
* `always_install` (boolean) - Installs salt binaries even
if they are already detected, default `false`
@@ -80,11 +80,11 @@ These only make sense when `no_minion` is `false`.
* `minion_config` (string, default: "salt/minion") - Path to
a custom salt minion config file.
-* `minion_key` (string) - Path to your minion key
+* `minion_key` (string, default: "salt/key/minion.key") - Path to your minion key
* `minion_id` (string) - Unique identifier for minion. Used for masterless and preseeding keys.
-* `minion_pub` (salt/key/minion.pub) - Path to your minion
+* `minion_pub` (string, default: "salt/key/minion.pub") - Path to your minion
public key
* `grains_config` (string) - Path to a custom salt grains file. On Windows, the minion needs `ipc_mode: tcp` set otherwise it will [fail to communicate](https://github.com/saltstack/salt/issues/22796) with the master.
@@ -97,9 +97,9 @@ These only make sense when `install_master` is `true`. Not supported on Windows
* `master_config` (string, default: "salt/master")
Path to a custom salt master config file.
-* `master_key` (salt/key/master.pem) - Path to your master key.
+* `master_key` (string, default: "salt/key/master.pem") - Path to your master key.
-* `master_pub` (salt/key/master.pub) - Path to your master public key.
+* `master_pub` (string, default: "salt/key/master.pub") - Path to your master public key.
* `seed_master` (dictionary) - Upload keys to master, thereby
pre-seeding it before use. Example: `{minion_name:/path/to/key.pub}`
From 80fb6be61f48890c36afb16787fd6e37a88eac82 Mon Sep 17 00:00:00 2001
From: Gilles Cornu
Date: Mon, 17 Oct 2016 21:14:50 +0200
Subject: [PATCH 071/205] docs/ansible: Fix small issues
- fix alpha-order listing of the shared options ansible_common.html.md
- fix two wrong indentations in ansible_intro.html.md
[ci skip]
---
.../docs/provisioning/ansible_common.html.md | 78 +++++++++----------
.../docs/provisioning/ansible_intro.html.md | 11 ++-
2 files changed, 44 insertions(+), 45 deletions(-)
diff --git a/website/source/docs/provisioning/ansible_common.html.md b/website/source/docs/provisioning/ansible_common.html.md
index 81316fa30..0bef8ac50 100644
--- a/website/source/docs/provisioning/ansible_common.html.md
+++ b/website/source/docs/provisioning/ansible_common.html.md
@@ -34,20 +34,27 @@ Some of these options are for advanced usage only and should not be used unless
```
These variables take the highest precedence over any other variables.
-- `host_vars` (hash) - Set of inventory host variables to be included in the [auto-generated inventory file](https://docs.ansible.com/ansible/intro_inventory.html#host-variables).
+- `galaxy_command` (template string) - The command pattern used to install Galaxy roles when `galaxy_role_file` is set.
- Example:
+ The following (optional) placeholders can be used in this command pattern:
+ - `%{role_file}` is replaced by the absolute path to the `galaxy_role_file` option
+ - `%{roles_path}` is
+ - replaced by the absolute path to the `galaxy_roles_path` option when such option is defined, or
+ - replaced by the absolute path to a `roles` subdirectory sitting in the `playbook` parent directory.
- ```ruby
- ansible.host_vars = {
- "host1" => {"http_port" => 80,
- "maxRequestsPerChild" => 808},
- "host2" => {"http_port" => 303,
- "maxRequestsPerChild" => 909}
- }
- ```
+ By default, this option is set to
- Note: This option has no effect when the `inventory_path` option is defined.
+ `ansible-galaxy install --role-file=%{role_file} --roles-path=%{roles_path} --force`
+
+- `galaxy_role_file` (string) - The path to the Ansible Galaxy role file.
+
+ By default, this option is set to `nil` and Galaxy support is then disabled.
+
+ Note: if an absolute path is given, the `ansible_local` provisioner will assume that it corresponds to the exact location on the guest system.
+
+- `galaxy_roles_path` (string) - The path to the directory where Ansible Galaxy roles must be installed
+
+ By default, this option is set to `nil`, which means that the Galaxy roles will be installed in a `roles` subdirectory located in the parent directory of the `playbook` file.
- `groups` (hash) - Set of inventory groups to be included in the [auto-generated inventory file](/docs/provisioning/ansible_intro.html).
@@ -74,42 +81,35 @@ Some of these options are for advanced usage only and should not be used unless
- Alphanumeric patterns are not supported (e.g. `db-[a:f]`, `vm[01:10]`).
- This option has no effect when the `inventory_path` option is defined.
+- `host_vars` (hash) - Set of inventory host variables to be included in the [auto-generated inventory file](https://docs.ansible.com/ansible/intro_inventory.html#host-variables).
+
+ Example:
+
+ ```ruby
+ ansible.host_vars = {
+ "host1" => {"http_port" => 80,
+ "maxRequestsPerChild" => 808},
+ "host2" => {"http_port" => 303,
+ "maxRequestsPerChild" => 909}
+ }
+ ```
+
+ Note: This option has no effect when the `inventory_path` option is defined.
+
- `inventory_path` (string) - The path to an Ansible inventory resource (e.g. a [static inventory file](https://docs.ansible.com/intro_inventory.html), a [dynamic inventory script](https://docs.ansible.com/intro_dynamic_inventory.html) or even [multiple inventories stored in the same directory](https://docs.ansible.com/intro_dynamic_inventory.html#using-multiple-inventory-sources)).
By default, this option is disabled and Vagrant generates an inventory based on the `Vagrantfile` information.
-- `playbook_command` (string) - The command used to run playbooks.
-
- The default value is `ansible-playbook`
-
-- `galaxy_command` (template string) - The command pattern used to install Galaxy roles when `galaxy_role_file` is set.
-
- The following (optional) placeholders can be used in this command pattern:
- - `%{role_file}` is replaced by the absolute path to the `galaxy_role_file` option
- - `%{roles_path}` is
- - replaced by the absolute path to the `galaxy_roles_path` option when such option is defined, or
- - replaced by the absolute path to a `roles` subdirectory sitting in the `playbook` parent directory.
-
- By default, this option is set to
-
- `ansible-galaxy install --role-file=%{role_file} --roles-path=%{roles_path} --force`
-
-- `galaxy_role_file` (string) - The path to the Ansible Galaxy role file.
-
- By default, this option is set to `nil` and Galaxy support is then disabled.
-
- Note: if an absolute path is given, the `ansible_local` provisioner will assume that it corresponds to the exact location on the guest system.
-
-- `galaxy_roles_path` (string) - The path to the directory where Ansible Galaxy roles must be installed
-
- By default, this option is set to `nil`, which means that the Galaxy roles will be installed in a `roles` subdirectory located in the parent directory of the `playbook` file.
-
- `limit` (string or array of strings) - Set of machines or groups from the inventory file to further control which hosts [are affected](https://docs.ansible.com/glossary.html#limit-groups).
The default value is set to the machine name (taken from `Vagrantfile`) to ensure that `vagrant provision` command only affect the expected machine.
Setting `limit = "all"` can be used to make Ansible connect to all machines from the inventory file.
+- `playbook_command` (string) - The command used to run playbooks.
+
+ The default value is `ansible-playbook`
+
- `raw_arguments` (array of strings) - a list of additional `ansible-playbook` arguments.
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.
@@ -128,6 +128,8 @@ Some of these options are for advanced usage only and should not be used unless
- `tags` (string or array of strings) - Only plays, roles and tasks [tagged with these values will be executed](https://docs.ansible.com/playbooks_tags.html) .
+- `vault_password_file` (string) - The path of a file containing the password used by [Ansible Vault](https://docs.ansible.com/playbooks_vault.html#vault).
+
- `verbose` (boolean or string) - Set Ansible's verbosity to obtain detailed logging
Default value is `false` (minimal verbosity).
@@ -135,5 +137,3 @@ Some of these options are for advanced usage only and should not be used unless
Examples: `true` (equivalent to `v`), `-vvv` (equivalent to `vvv`), `vvvv`.
Note that when the `verbose` option is enabled, the `ansible-playbook` command used by Vagrant will be displayed.
-
-- `vault_password_file` (string) - The path of a file containing the password used by [Ansible Vault](https://docs.ansible.com/playbooks_vault.html#vault).
diff --git a/website/source/docs/provisioning/ansible_intro.html.md b/website/source/docs/provisioning/ansible_intro.html.md
index 0210e0e34..ae58b396c 100644
--- a/website/source/docs/provisioning/ansible_intro.html.md
+++ b/website/source/docs/provisioning/ansible_intro.html.md
@@ -11,9 +11,8 @@ description: |-
The information below is applicable to both Vagrant Ansible provisioners:
- - [`ansible`](/docs/provisioning/ansible.html), where Ansible is executed on the **Vagrant host**
-
- - [`ansible_local`](/docs/provisioning/ansible_local.html), where Ansible is executed on the **Vagrant guest**
+ - [`ansible`](/docs/provisioning/ansible.html), where Ansible is executed on the **Vagrant host**
+ - [`ansible_local`](/docs/provisioning/ansible_local.html), where Ansible is executed on the **Vagrant guest**
The list of common options for these two provisioners is documented in a [separate documentation page](/docs/provisioning/ansible_common.html).
@@ -237,9 +236,9 @@ config.vm.network :private_network, ip: "192.168.111.222"
**Notes:**
- - The machine names in `Vagrantfile` and `ansible.inventory_path` files should correspond, unless you use `ansible.limit` option to reference the correct machines.
- - The SSH host addresses (and ports) must obviously be specified twice, in `Vagrantfile` and `ansible.inventory_path` files.
- - Sharing hostnames across Vagrant host and guests might be a good idea (e.g. with some Ansible configuration task, or with a plugin like [`vagrant-hostmanager`](https://github.com/smdahlen/vagrant-hostmanager)).
+ - The machine names in `Vagrantfile` and `ansible.inventory_path` files should correspond, unless you use `ansible.limit` option to reference the correct machines.
+ - The SSH host addresses (and ports) must obviously be specified twice, in `Vagrantfile` and `ansible.inventory_path` files.
+ - Sharing hostnames across Vagrant host and guests might be a good idea (e.g. with some Ansible configuration task, or with a plugin like [`vagrant-hostmanager`](https://github.com/smdahlen/vagrant-hostmanager)).
### The Ansible Configuration File
From 055bed59184700fc27479c11d02c3e7bcd7aa582 Mon Sep 17 00:00:00 2001
From: Bjorn Brala
Date: Wed, 19 Oct 2016 20:55:56 +0200
Subject: [PATCH 072/205] removed an extra echo and added proper error message
when there is incompatibilities. Appearantly importing into a compressed
folder wont work and will result in an error.
---
plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
index f66c181f6..9855763ec 100644
--- a/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
+++ b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
@@ -18,8 +18,6 @@
[string]$differencing_disk=$null
)
-"$($data_path)/Snapshots"
-
# Include the following modules
$Dir = Split-Path $script:MyInvocation.MyCommand.Path
. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1"))
@@ -124,9 +122,11 @@ if ($generation -ne 1) {
}
$report = Compare-VM -CompatibilityReport $vmConfig
+
+£ Stop if there is incomatibilities which would fail anyhow.
if($report.Incompatibilities.Length -gt 0){
-$report.Incompatibilities
- Write-Error-Message ConvertTo-Json $report.Incompatibilities
+ Write-Error-Message $(ConvertTo-Json $($report.Incompatibilities | Select -ExpandProperty Message))
+ exit 0
}
# Differencing disk
@@ -150,7 +150,7 @@ if($differencing_disk){
}
}
-
+
Import-VM -CompatibilityReport $vmConfig
$vm_id = (Get-VM $vm_name).id.guid
From c075c026be75bd78b607700ce9368df51927d752 Mon Sep 17 00:00:00 2001
From: Bjorn Brala
Date: Wed, 19 Oct 2016 20:56:52 +0200
Subject: [PATCH 073/205] Keyboard language setting made my comment bad
---
plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
index 9855763ec..b499285c8 100644
--- a/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
+++ b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
@@ -123,7 +123,7 @@ if ($generation -ne 1) {
$report = Compare-VM -CompatibilityReport $vmConfig
-£ Stop if there is incomatibilities which would fail anyhow.
+# Stop if there is incompatibilities which would fail anyhow.
if($report.Incompatibilities.Length -gt 0){
Write-Error-Message $(ConvertTo-Json $($report.Incompatibilities | Select -ExpandProperty Message))
exit 0
From e6093dd709e303cab081c99b84cf4dd5499984b9 Mon Sep 17 00:00:00 2001
From: Bjorn Brala
Date: Wed, 19 Oct 2016 21:03:48 +0200
Subject: [PATCH 074/205] The virtual machine doesnt need 'Virtual Machines' in
its path, this is created when importing.
---
plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
index b499285c8..55cf9db8e 100644
--- a/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
+++ b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
@@ -27,7 +27,7 @@ $VmProperties = @{
Path = $vm_config_file
SnapshotFilePath = Join-Path $data_path 'Snapshots'
VhdDestinationPath = Join-Path $data_path 'Virtual Hard Disks'
- VirtualMachinePath = Join-Path $data_path 'Virtual Machines'
+ VirtualMachinePath = $data_path
}
$vmConfig = (Compare-VM -Copy -GenerateNewID @VmProperties)
From 37a525fbbcf111cb826c63b1a6cdac2253c5c229 Mon Sep 17 00:00:00 2001
From: Bjorn Brala
Date: Thu, 20 Oct 2016 22:43:00 +0200
Subject: [PATCH 075/205] Little bit of cleanup.
---
.../providers/hyperv/scripts/import_vm_vmcx.ps1 | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
index 55cf9db8e..9554fb91e 100644
--- a/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
+++ b/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1
@@ -22,7 +22,6 @@
$Dir = Split-Path $script:MyInvocation.MyCommand.Path
. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1"))
-# load the config from the vmcx and make a copy for editing, use TMP path so we are sure there is no vhd at the destination
$VmProperties = @{
Path = $vm_config_file
SnapshotFilePath = Join-Path $data_path 'Snapshots'
@@ -32,7 +31,6 @@ $VmProperties = @{
$vmConfig = (Compare-VM -Copy -GenerateNewID @VmProperties)
-
$generation = $vmConfig.VM.Generation
if (!$vmname) {
@@ -67,19 +65,16 @@ if (!$memory) {
$configMemory = Get-VMMemory -VM $vmConfig.VM
$dynamicmemory = $configMemory.DynamicMemoryEnabled
- # Memory values need to be in bytes
$MemoryMaximumBytes = ($configMemory.Maximum)
$MemoryStartupBytes = ($configMemory.Startup)
$MemoryMinimumBytes = ($configMemory.Minimum)
-}
-else {
+} else {
if (!$maxmemory){
$dynamicmemory = $False
$MemoryMaximumBytes = ($memory -as [int]) * 1MB
$MemoryStartupBytes = ($memory -as [int]) * 1MB
$MemoryMinimumBytes = ($memory -as [int]) * 1MB
- }
- else {
+ } else {
$dynamicmemory = $True
$MemoryMaximumBytes = ($maxmemory -as [int]) * 1MB
$MemoryStartupBytes = ($memory -as [int]) * 1MB
@@ -87,12 +82,10 @@ else {
}
}
-
if (!$switchname) {
$switchname = (Get-VMNetworkAdapter -VM $vmConfig.VM).SwitchName
}
-
Connect-VMNetworkAdapter -VMNetworkAdapter (Get-VMNetworkAdapter -VM $vmConfig.VM) -SwitchName $switchname
Set-VM -VM $vmConfig.VM -NewVMName $vm_name -MemoryStartupBytes $MemoryStartupBytes
Set-VM -VM $vmConfig.VM -ErrorAction "Stop" -ProcessorCount $processors
@@ -123,13 +116,12 @@ if ($generation -ne 1) {
$report = Compare-VM -CompatibilityReport $vmConfig
-# Stop if there is incompatibilities which would fail anyhow.
+# Stop if there are incompatibilities
if($report.Incompatibilities.Length -gt 0){
Write-Error-Message $(ConvertTo-Json $($report.Incompatibilities | Select -ExpandProperty Message))
exit 0
}
-# Differencing disk
if($differencing_disk){
# Get all controller on the VM, first scsi, then IDE if it is a Gen 1 device
$controllers = Get-VMScsiController -VM $vmConfig.VM
@@ -148,7 +140,6 @@ if($differencing_disk){
}
}
}
-
}
Import-VM -CompatibilityReport $vmConfig
From 432f79339c1439c900b4f105d6ac18789200ce82 Mon Sep 17 00:00:00 2001
From: Gilles Cornu
Date: Fri, 17 Jun 2016 18:14:29 +0200
Subject: [PATCH 076/205] provisioners/ansible(base): Add parenthesis for
better readability
Make more evident on what the "if modifiers" (aka trailing conditionals) apply.
---
plugins/provisioners/ansible/provisioner/base.rb | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/plugins/provisioners/ansible/provisioner/base.rb b/plugins/provisioners/ansible/provisioner/base.rb
index e0807ec27..ed020b618 100644
--- a/plugins/provisioners/ansible/provisioner/base.rb
+++ b/plugins/provisioners/ansible/provisioner/base.rb
@@ -26,12 +26,12 @@ module VagrantPlugins
end
def check_files_existence
- check_path_is_a_file config.playbook, :playbook
+ check_path_is_a_file(config.playbook, :playbook)
- check_path_exists config.inventory_path, :inventory_path if config.inventory_path
- check_path_is_a_file config.extra_vars[1..-1], :extra_vars if has_an_extra_vars_file_argument
- check_path_is_a_file config.galaxy_role_file, :galaxy_role_file if config.galaxy_role_file
- check_path_is_a_file config.vault_password_file, :vault_password if config.vault_password_file
+ check_path_exists(config.inventory_path, :inventory_path) if config.inventory_path
+ check_path_is_a_file(config.extra_vars[1..-1], :extra_vars) if has_an_extra_vars_file_argument
+ check_path_is_a_file(config.galaxy_role_file, :galaxy_role_file) if config.galaxy_role_file
+ check_path_is_a_file(config.vault_password_file, :vault_password_file) if config.vault_password_file
end
def ansible_playbook_command_for_shell_execution
From d56cf55a89312d76b3f68cb23eb0ee3cd2a4f0f9 Mon Sep 17 00:00:00 2001
From: Gilles Cornu
Date: Fri, 21 Oct 2016 16:38:02 +0200
Subject: [PATCH 077/205] provisioners/ansible_local: Use quotes for path
checking
Without this fix, the ansible_local provisioner fails to check the
existence of a filesystem path that contains a blank/space character.
---
plugins/provisioners/ansible/provisioner/guest.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/provisioners/ansible/provisioner/guest.rb b/plugins/provisioners/ansible/provisioner/guest.rb
index 0d165db7e..2cdbe3004 100644
--- a/plugins/provisioners/ansible/provisioner/guest.rb
+++ b/plugins/provisioners/ansible/provisioner/guest.rb
@@ -156,7 +156,7 @@ module VagrantPlugins
# and error if it doesn't exist.
remote_path = Helpers::expand_path_in_unix_style(path, config.provisioning_path)
- command = "test #{test_args} #{remote_path}"
+ command = "test #{test_args} '#{remote_path}'"
@machine.communicate.execute(
command,
From 219a5ff2efe686f0ce4a8910ba008eec5af566ad Mon Sep 17 00:00:00 2001
From: Gilles Cornu
Date: Fri, 21 Oct 2016 16:58:14 +0200
Subject: [PATCH 078/205] Update CHANGELOG
[ci skip]
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c79e59494..ba517f559 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,7 @@ BUG FIXES:
- guests/photon: Fix networking setup [GH-7808, GH-7873]
- guests/redhat: Properly configure network and restart service [GH-7751]
- providers/docker: Remove --interactive flag when pty is true [GH-7688]
+ - provisioners/ansible_local: Use enquoted path for file/directory existence checks
- pushes/atlas: Fix atlas push on Windows platform [GH-6938, GH-7802]
## 1.8.6 (September 27, 2016)
From 35f7c2c4c984321f5d65a1ad62bd6970d31d162a Mon Sep 17 00:00:00 2001
From: Gilles Cornu
Date: Sat, 22 Oct 2016 00:58:53 +0200
Subject: [PATCH 079/205] provisioners/ansible: Fix raw_arguments documentation
Precise valid and invalid syntax for `raw_arguments` array values,
especially for the `ansible` remote provisioner.
Close GH-7890
[ci skip]
---
website/source/docs/provisioning/ansible_common.html.md | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/website/source/docs/provisioning/ansible_common.html.md b/website/source/docs/provisioning/ansible_common.html.md
index 0bef8ac50..d76d6cfa0 100644
--- a/website/source/docs/provisioning/ansible_common.html.md
+++ b/website/source/docs/provisioning/ansible_common.html.md
@@ -114,7 +114,11 @@ Some of these options are for advanced usage only and should not be used unless
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.
- Example: `['--check', '-M /my/modules']`).
+ Examples:
+ - `['--check', '-M', '/my/modules']`
+ - `["--connection=paramiko", "--forks=10"]`
+
+ **Caveat:** The `ansible` provisioner does not support whitespace characters in `raw_arguments` elements. Therefore **don't write** something like `["-c paramiko"]`, which will result with an invalid `" parmiko"` parameter value.
- `skip_tags` (string or array of strings) - Only plays, roles and tasks that [*do not match* these values will be executed](https://docs.ansible.com/playbooks_tags.html).
From 9d95eb821c01acd95a8a8d7ad9d8b948194f0fbc Mon Sep 17 00:00:00 2001
From: Gilles Cornu
Date: Sat, 22 Oct 2016 01:05:50 +0200
Subject: [PATCH 080/205] provisioners/ansible: Minor documentation
improvements
- Try to make more visible the options shared by both provisioners
- Update some internal links to directly reach the mentioned option
[ci skip]
---
website/source/docs/provisioning/ansible.html.md | 2 +-
website/source/docs/provisioning/ansible_intro.html.md | 6 +++---
website/source/docs/provisioning/ansible_local.html.md | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/website/source/docs/provisioning/ansible.html.md b/website/source/docs/provisioning/ansible.html.md
index 12eeef8ba..3dda49b31 100644
--- a/website/source/docs/provisioning/ansible.html.md
+++ b/website/source/docs/provisioning/ansible.html.md
@@ -51,7 +51,7 @@ end
## Options
-This section lists the specific options for the Ansible (remote) provisioner. In addition to the options listed below, this provisioner supports the [common options for both Ansible provisioners](/docs/provisioning/ansible_common.html).
+This section lists the _specific_ options for the Ansible (remote) provisioner. In addition to the options listed below, this provisioner supports the [**common options** for both Ansible provisioners](/docs/provisioning/ansible_common.html).
- `ask_sudo_pass` (boolean) - require Ansible to [prompt for a sudo password](https://docs.ansible.com/intro_getting_started.html#remote-connection-information).
diff --git a/website/source/docs/provisioning/ansible_intro.html.md b/website/source/docs/provisioning/ansible_intro.html.md
index ae58b396c..de9c07697 100644
--- a/website/source/docs/provisioning/ansible_intro.html.md
+++ b/website/source/docs/provisioning/ansible_intro.html.md
@@ -112,7 +112,7 @@ Note that the generated inventory file is uploaded to the guest VM in a subdirec
**Host variables:**
-As of Vagrant 1.8.0, the [`host_vars`](/docs/provisioning/ansible_common.html) option can be used to set [variables for individual hosts](https://docs.ansible.com/ansible/intro_inventory.html#host-variables) in the generated inventory file (see also the notes on group variables below).
+As of Vagrant 1.8.0, the [`host_vars`](/docs/provisioning/ansible_common.html#host_vars) option can be used to set [variables for individual hosts](https://docs.ansible.com/ansible/intro_inventory.html#host-variables) in the generated inventory file (see also the notes on group variables below).
```
Vagrant.configure("2") do |config|
@@ -141,7 +141,7 @@ host2 ansible_ssh_host=... http_port=303 maxRequestsPerChild=909
**How to generate Inventory Groups:**
-The [`groups`](/docs/provisioning/ansible_common.html) option can be used to pass a hash of group names and group members to be included in the generated inventory file.
+The [`groups`](/docs/provisioning/ansible_common.html#groups) option can be used to pass a hash of group names and group members to be included in the generated inventory file.
As of Vagrant 1.8.0, it is also possible to specify [group variables](https://docs.ansible.com/ansible/intro_inventory.html#group-variables), and group members as [host ranges (with numeric or alphabetic patterns)](https://docs.ansible.com/ansible/intro_inventory.html#hosts-and-groups).
@@ -220,7 +220,7 @@ variable2=example
The second option is for situations where you would like to have more control over the inventory management.
-With the `inventory_path` option, you can reference a specific inventory resource (e.g. a static inventory file, a [dynamic inventory script](https://docs.ansible.com/intro_dynamic_inventory.html) or even [multiple inventories stored in the same directory](https://docs.ansible.com/intro_dynamic_inventory.html#using-multiple-inventory-sources)). Vagrant will then use this inventory information instead of generating it.
+With the [`inventory_path`](/docs/provisioning/ansible_common.html#inventory_path) option, you can reference a specific inventory resource (e.g. a static inventory file, a [dynamic inventory script](https://docs.ansible.com/intro_dynamic_inventory.html) or even [multiple inventories stored in the same directory](https://docs.ansible.com/intro_dynamic_inventory.html#using-multiple-inventory-sources)). Vagrant will then use this inventory information instead of generating it.
A very simple inventory file for use with Vagrant might look like:
diff --git a/website/source/docs/provisioning/ansible_local.html.md b/website/source/docs/provisioning/ansible_local.html.md
index 44e8cc7a6..0efdcb3d8 100644
--- a/website/source/docs/provisioning/ansible_local.html.md
+++ b/website/source/docs/provisioning/ansible_local.html.md
@@ -55,7 +55,7 @@ end
## Options
-This section lists the specific options for the Ansible Local provisioner. In addition to the options listed below, this provisioner supports the [common options for both Ansible provisioners](/docs/provisioning/ansible_common.html).
+This section lists the _specific_ options for the Ansible Local provisioner. In addition to the options listed below, this provisioner supports the [**common options** for both Ansible provisioners](/docs/provisioning/ansible_common.html).
- `install` (boolean) - Try to automatically install Ansible on the guest system.
From a842abbc38e415a5aa8459f4641ee48a02e4eaee Mon Sep 17 00:00:00 2001
From: Gilles Cornu
Date: Tue, 20 Sep 2016 22:58:41 +0200
Subject: [PATCH 081/205] provisioners/ansible(both): Add config_file option
With this new option defined, the `ansible-galaxy` and
`ansible-playbook` commands generated by the Ansible provisioners will
be executed with the ANSIBLE_CONFIG environment variable set
accordingly.
Resolve GH-7195
This commit also fix the following open issues:
- Implement the pending RSpec examples about path existence checks
performed by the ansible (remote) provisioner.
- In verbose mode, the ansible remote provisioner now correctly displays
the Ansible Galaxy parameters ("role_file" and "roles_path") with
single quotes (which is safer for potential copy-paste usage).
Additional Notes:
- Test coverage for `ansible_local` provisioner is still not
implemented. See GH-6633.
- Test coverage for galaxy from host is not implemented yet (due to
general issue with mocking both command executions, see
https://github.com/mitchellh/vagrant/pull/6529#r45278451
---
plugins/provisioners/ansible/config/base.rb | 3 +
.../provisioners/ansible/provisioner/base.rb | 35 ++++++--
.../provisioners/ansible/provisioner/guest.rb | 9 +--
.../provisioners/ansible/provisioner/host.rb | 10 ++-
.../provisioners/ansible/config/guest_test.rb | 3 +-
.../provisioners/ansible/config/host_test.rb | 1 +
.../provisioners/ansible/config/shared.rb | 1 +
.../provisioners/ansible/provisioner_test.rb | 81 ++++++++++++-------
.../docs/provisioning/ansible_common.html.md | 4 +
.../docs/provisioning/ansible_intro.html.md | 17 ++--
10 files changed, 108 insertions(+), 56 deletions(-)
diff --git a/plugins/provisioners/ansible/config/base.rb b/plugins/provisioners/ansible/config/base.rb
index 6b9e73a40..1e74e84da 100644
--- a/plugins/provisioners/ansible/config/base.rb
+++ b/plugins/provisioners/ansible/config/base.rb
@@ -6,6 +6,7 @@ module VagrantPlugins
GALAXY_COMMAND_DEFAULT = "ansible-galaxy install --role-file=%{role_file} --roles-path=%{roles_path} --force".freeze
PLAYBOOK_COMMAND_DEFAULT = "ansible-playbook".freeze
+ attr_accessor :config_file
attr_accessor :extra_vars
attr_accessor :galaxy_role_file
attr_accessor :galaxy_roles_path
@@ -26,6 +27,7 @@ module VagrantPlugins
attr_accessor :verbose
def initialize
+ @config_file = UNSET_VALUE
@extra_vars = UNSET_VALUE
@galaxy_role_file = UNSET_VALUE
@galaxy_roles_path = UNSET_VALUE
@@ -47,6 +49,7 @@ module VagrantPlugins
end
def finalize!
+ @config_file = nil if @config_file == UNSET_VALUE
@extra_vars = nil if @extra_vars == UNSET_VALUE
@galaxy_role_file = nil if @galaxy_role_file == UNSET_VALUE
@galaxy_roles_path = nil if @galaxy_roles_path == UNSET_VALUE
diff --git a/plugins/provisioners/ansible/provisioner/base.rb b/plugins/provisioners/ansible/provisioner/base.rb
index ed020b618..8e52d751f 100644
--- a/plugins/provisioners/ansible/provisioner/base.rb
+++ b/plugins/provisioners/ansible/provisioner/base.rb
@@ -29,20 +29,39 @@ module VagrantPlugins
check_path_is_a_file(config.playbook, :playbook)
check_path_exists(config.inventory_path, :inventory_path) if config.inventory_path
+ check_path_is_a_file(config.config_file, :config_file) if config.config_file
check_path_is_a_file(config.extra_vars[1..-1], :extra_vars) if has_an_extra_vars_file_argument
check_path_is_a_file(config.galaxy_role_file, :galaxy_role_file) if config.galaxy_role_file
check_path_is_a_file(config.vault_password_file, :vault_password_file) if config.vault_password_file
end
- def ansible_playbook_command_for_shell_execution
- shell_command = []
+ def get_environment_variables_for_shell_execution
+ shell_env_vars = []
@environment_variables.each_pair do |k, v|
- if k =~ /ANSIBLE_SSH_ARGS|ANSIBLE_ROLES_PATH/
- shell_command << "#{k}='#{v}'"
+ if k =~ /ANSIBLE_SSH_ARGS|ANSIBLE_ROLES_PATH|ANSIBLE_CONFIG/
+ shell_env_vars << "#{k}='#{v}'"
else
- shell_command << "#{k}=#{v}"
+ shell_env_vars << "#{k}=#{v}"
end
end
+ shell_env_vars
+ end
+
+ def ansible_galaxy_command_for_shell_execution
+ command_values = {
+ role_file: "'#{get_galaxy_role_file}'",
+ roles_path: "'#{get_galaxy_roles_path}'"
+ }
+
+ shell_command = get_environment_variables_for_shell_execution
+
+ shell_command << config.galaxy_command % command_values
+
+ shell_command.flatten.join(' ')
+ end
+
+ def ansible_playbook_command_for_shell_execution
+ shell_command = get_environment_variables_for_shell_execution
shell_command << config.playbook_command
@@ -102,6 +121,12 @@ module VagrantPlugins
# Use ANSIBLE_ROLES_PATH to tell ansible-playbook where to look for roles
# (there is no equivalent command line argument in ansible-playbook)
@environment_variables["ANSIBLE_ROLES_PATH"] = get_galaxy_roles_path if config.galaxy_roles_path
+
+ prepare_ansible_config_environment_variable
+ end
+
+ def prepare_ansible_config_environment_variable
+ @environment_variables["ANSIBLE_CONFIG"] = config.config_file if config.config_file
end
# Auto-generate "safe" inventory file based on Vagrantfile,
diff --git a/plugins/provisioners/ansible/provisioner/guest.rb b/plugins/provisioners/ansible/provisioner/guest.rb
index 2cdbe3004..ef4287650 100644
--- a/plugins/provisioners/ansible/provisioner/guest.rb
+++ b/plugins/provisioners/ansible/provisioner/guest.rb
@@ -72,14 +72,9 @@ module VagrantPlugins
end
def execute_ansible_galaxy_on_guest
- command_values = {
- role_file: "'#{get_galaxy_role_file}'",
- roles_path: "'#{get_galaxy_roles_path}'"
- }
+ prepare_ansible_config_environment_variable
- remote_command = config.galaxy_command % command_values
-
- execute_ansible_command_on_guest "galaxy", remote_command
+ execute_ansible_command_on_guest "galaxy", ansible_galaxy_command_for_shell_execution
end
def execute_ansible_playbook_on_guest
diff --git a/plugins/provisioners/ansible/provisioner/host.rb b/plugins/provisioners/ansible/provisioner/host.rb
index 697ad51a8..e0fc70f0b 100644
--- a/plugins/provisioners/ansible/provisioner/host.rb
+++ b/plugins/provisioners/ansible/provisioner/host.rb
@@ -20,6 +20,7 @@ module VagrantPlugins
check_files_existence
warn_for_unsupported_platform
+
execute_ansible_galaxy_from_host if config.galaxy_role_file
execute_ansible_playbook_from_host
end
@@ -88,6 +89,8 @@ module VagrantPlugins
end
def execute_ansible_galaxy_from_host
+ prepare_ansible_config_environment_variable
+
command_values = {
role_file: get_galaxy_role_file,
roles_path: get_galaxy_roles_path
@@ -97,20 +100,20 @@ module VagrantPlugins
command = str_command.split(VAGRANT_ARG_SEPARATOR)
command << {
+ env: @environment_variables,
# Write stdout and stderr data, since it's the regular Ansible output
notify: [:stdout, :stderr],
workdir: @machine.env.root_path.to_s
}
- # FIXME: role_file and roles_path arguments should be quoted in the console output
- ui_running_ansible_command "galaxy", str_command.gsub(VAGRANT_ARG_SEPARATOR, ' ')
+ ui_running_ansible_command "galaxy", ansible_galaxy_command_for_shell_execution
execute_command_from_host command
end
def execute_ansible_playbook_from_host
- prepare_command_arguments
prepare_environment_variables
+ prepare_command_arguments
# Assemble the full ansible-playbook command
command = [config.playbook_command] << @command_arguments
@@ -234,6 +237,7 @@ module VagrantPlugins
proxy_cmd += " exec nc %h %p 2>/dev/null"
ssh_options << "-o ProxyCommand='#{ proxy_cmd }'"
+ # TODO ssh_options << "-o ProxyCommand=\"#{ proxy_cmd }\""
end
# Use an SSH ProxyCommand when corresponding Vagrant setting is defined
diff --git a/test/unit/plugins/provisioners/ansible/config/guest_test.rb b/test/unit/plugins/provisioners/ansible/config/guest_test.rb
index 1249bd834..a2b44a57b 100644
--- a/test/unit/plugins/provisioners/ansible/config/guest_test.rb
+++ b/test/unit/plugins/provisioners/ansible/config/guest_test.rb
@@ -16,7 +16,8 @@ describe VagrantPlugins::Ansible::Config::Guest do
let(:existing_file) { "this/path/is/a/stub" }
it "supports a list of options" do
- supported_options = %w( extra_vars
+ supported_options = %w( config_file
+ extra_vars
galaxy_command
galaxy_role_file
galaxy_roles_path
diff --git a/test/unit/plugins/provisioners/ansible/config/host_test.rb b/test/unit/plugins/provisioners/ansible/config/host_test.rb
index fefcbfb6a..a3a439ac1 100644
--- a/test/unit/plugins/provisioners/ansible/config/host_test.rb
+++ b/test/unit/plugins/provisioners/ansible/config/host_test.rb
@@ -15,6 +15,7 @@ describe VagrantPlugins::Ansible::Config::Host, :skip_windows => true do
it "supports a list of options" do
supported_options = %w( ask_sudo_pass
ask_vault_pass
+ config_file
extra_vars
force_remote_user
galaxy_command
diff --git a/test/unit/plugins/provisioners/ansible/config/shared.rb b/test/unit/plugins/provisioners/ansible/config/shared.rb
index c59a31a94..92b2e0d90 100644
--- a/test/unit/plugins/provisioners/ansible/config/shared.rb
+++ b/test/unit/plugins/provisioners/ansible/config/shared.rb
@@ -3,6 +3,7 @@ shared_examples_for 'options shared by both Ansible provisioners' do
it "assigns default values to unset common options" do
subject.finalize!
+ expect(subject.config_file).to be_nil
expect(subject.extra_vars).to be_nil
expect(subject.galaxy_command).to eql("ansible-galaxy install --role-file=%{role_file} --roles-path=%{roles_path} --force")
expect(subject.galaxy_role_file).to be_nil
diff --git a/test/unit/plugins/provisioners/ansible/provisioner_test.rb b/test/unit/plugins/provisioners/ansible/provisioner_test.rb
index 64d58d341..db562201d 100644
--- a/test/unit/plugins/provisioners/ansible/provisioner_test.rb
+++ b/test/unit/plugins/provisioners/ansible/provisioner_test.rb
@@ -59,8 +59,6 @@ VF
stubbed_ui.stub(detail: "")
machine.env.stub(ui: stubbed_ui)
- subject.stub(:check_path)
-
config.playbook = 'playbook.yml'
end
@@ -195,7 +193,9 @@ VF
before do
unless example.metadata[:skip_before]
config.finalize!
+
Vagrant::Util::Subprocess.stub(execute: Vagrant::Util::Subprocess::Result.new(0, "", ""))
+ subject.stub(:check_path)
end
end
@@ -207,44 +207,46 @@ VF
describe 'checking existence of Ansible configuration files' do
- describe 'when the playbook file does not exist' do
- it "raises an error", skip_before: true, skip_after: true do
+ STUBBED_INVALID_PATH = "/test/239nfmd/invalid_path".freeze
- subject.stub(:check_path).and_raise(VagrantPlugins::Ansible::Errors::AnsibleError,
- _key: :config_file_not_found,
- config_option: "playbook",
- path: "/home/wip/test/invalid_path.yml",
- system: "host")
+ it 'raises an error when the `playbook` file does not exist', skip_before: true, skip_after: true do
+ subject.stub(:check_path).and_raise(VagrantPlugins::Ansible::Errors::AnsibleError,
+ _key: :config_file_not_found,
+ config_option: "playbook",
+ path: STUBBED_INVALID_PATH,
+ system: "host")
- config.playbook = "/home/wip/test/invalid_path.yml"
- config.finalize!
+ config.playbook = STUBBED_INVALID_PATH
+ config.finalize!
- expect {subject.provision}.to raise_error(VagrantPlugins::Ansible::Errors::AnsibleError,
- "`playbook` does not exist on the host: /home/wip/test/invalid_path.yml")
+ expect {subject.provision}.to raise_error(VagrantPlugins::Ansible::Errors::AnsibleError,
+ "`playbook` does not exist on the host: #{STUBBED_INVALID_PATH}")
+ end
+
+ %w(config_file extra_vars inventory_path galaxy_role_file vault_password_file).each do |option_name|
+ it "raises an error when the '#{option_name}' does not exist", skip_before: true, skip_after: true do
+ Vagrant::Util::Subprocess.stub(execute: Vagrant::Util::Subprocess::Result.new(0, "", ""))
+
+ config.playbook = existing_file
+ config.send(option_name + '=', STUBBED_INVALID_PATH)
+ if option_name == 'extra_vars'
+ # little trick to auto-append the '@' prefix, which is a duty of the config validator...
+ config.validate(machine)
+ end
+ config.finalize!
+
+ expect {subject.provision}.to raise_error(VagrantPlugins::Ansible::Errors::AnsibleError,
+ "`#{option_name}` does not exist on the host: #{STUBBED_INVALID_PATH}")
end
end
- describe 'when the inventory path does not exist' do
- it "raises an error"
- end
-
- describe 'when the extra_vars file does not exist' do
- it "raises an error"
- end
-
- describe 'when the galaxy_role_file does not exist' do
- it "raises an error"
- end
-
- describe 'when the vault_password_file does not exist' do
- it "raises an error"
- end
-
end
describe 'when ansible-playbook fails' do
it "raises an error", skip_before: true, skip_after: true do
config.finalize!
+
+ subject.stub(:check_path)
Vagrant::Util::Subprocess.stub(execute: Vagrant::Util::Subprocess::Result.new(1, "", ""))
expect {subject.provision}.to raise_error(VagrantPlugins::Ansible::Errors::AnsibleCommandFailed)
@@ -582,6 +584,20 @@ VF
end
end
+ context "with config_file option defined" do
+ before do
+ config.config_file = existing_file
+ end
+
+ it "sets ANSIBLE_CONFIG environment variable" do
+ expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
+ cmd_opts = args.last
+ expect(cmd_opts[:env]).to include("ANSIBLE_CONFIG")
+ expect(cmd_opts[:env]['ANSIBLE_CONFIG']).to eql(existing_file)
+ }
+ end
+ end
+
describe "with ask_vault_pass option" do
before do
config.ask_vault_pass = true
@@ -777,6 +793,8 @@ VF
it "raises an error when ansible-galaxy command fails", skip_before: true, skip_after: true do
config.finalize!
+
+ subject.stub(:check_path)
Vagrant::Util::Subprocess.stub(execute: Vagrant::Util::Subprocess::Result.new(1, "", ""))
expect {subject.provision}.to raise_error(VagrantPlugins::Ansible::Errors::AnsibleCommandFailed)
@@ -852,11 +870,12 @@ VF
config.raw_arguments = ["--why-not", "--su-user=foot", "--ask-su-pass", "--limit=all", "--private-key=./myself.key", "--extra-vars='{\"var3\":\"foo\"}'"]
# environment variables
+ config.config_file = existing_file
config.host_key_checking = true
config.raw_ssh_args = ['-o ControlMaster=no']
end
- it_should_set_arguments_and_environment_variables 21, 5, true
+ it_should_set_arguments_and_environment_variables 21, 6, true
it_should_explicitly_enable_ansible_ssh_control_persist_defaults
it_should_set_optional_arguments({ "extra_vars" => "--extra-vars={\"var1\":\"string with 'apostrophes', \\\\, \\\" and =\",\"var2\":{\"x\":42}}",
"sudo" => "--sudo",
@@ -883,7 +902,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(%Q(PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_ROLES_PATH='/up/to the stars' ANSIBLE_HOST_KEY_CHECKING=true ANSIBLE_SSH_ARGS='-o IdentitiesOnly=yes -i '/my/key1' -i '/my/key2' -o ForwardAgent=yes -o ControlMaster=no -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --connection=ssh --timeout=30 --ask-sudo-pass --ask-vault-pass --limit="machine*:&vagrant:!that_one" --inventory-file=#{generated_inventory_dir} --extra-vars="{\\"var1\\":\\"string with 'apostrophes', \\\\\\\\, \\\\\\" and =\\",\\"var2\\":{\\"x\\":42}}" --sudo --sudo-user=deployer -vvv --vault-password-file=#{File.expand_path(__FILE__)} --tags=db,www --skip-tags=foo,bar --start-at-task="joe's awesome task" --why-not --su-user=foot --ask-su-pass --limit=all --private-key=./myself.key --extra-vars='{\"var3\":\"foo\"}' playbook.yml))
+ expect(full_command).to eq(%Q(PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_ROLES_PATH='/up/to the stars' ANSIBLE_CONFIG='#{existing_file}' ANSIBLE_HOST_KEY_CHECKING=true ANSIBLE_SSH_ARGS='-o IdentitiesOnly=yes -i '/my/key1' -i '/my/key2' -o ForwardAgent=yes -o ControlMaster=no -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --connection=ssh --timeout=30 --ask-sudo-pass --ask-vault-pass --limit="machine*:&vagrant:!that_one" --inventory-file=#{generated_inventory_dir} --extra-vars="{\\"var1\\":\\"string with 'apostrophes', \\\\\\\\, \\\\\\" and =\\",\\"var2\\":{\\"x\\":42}}" --sudo --sudo-user=deployer -vvv --vault-password-file=#{existing_file} --tags=db,www --skip-tags=foo,bar --start-at-task="joe's awesome task" --why-not --su-user=foot --ask-su-pass --limit=all --private-key=./myself.key --extra-vars='{\"var3\":\"foo\"}' playbook.yml))
}
end
end
diff --git a/website/source/docs/provisioning/ansible_common.html.md b/website/source/docs/provisioning/ansible_common.html.md
index d76d6cfa0..2ed3b4e72 100644
--- a/website/source/docs/provisioning/ansible_common.html.md
+++ b/website/source/docs/provisioning/ansible_common.html.md
@@ -17,6 +17,10 @@ These options get passed to the `ansible-playbook` command that ships with Ansib
Some of these options are for advanced usage only and should not be used unless you understand their purpose.
+- `config_file` (string) - The path to an [Ansible Configuration file](https://docs.ansible.com/intro_configuration.html).
+
+ By default, this option is not set, and Ansible will [search for a possible configuration file in some default locations](/docs/provisioning/ansible_intro.html#ANSIBLE_CONFIG).
+
- `extra_vars` (string or hash) - Pass additional variables (with highest priority) to the playbook.
This parameter can be a path to a JSON or YAML file, or a hash.
diff --git a/website/source/docs/provisioning/ansible_intro.html.md b/website/source/docs/provisioning/ansible_intro.html.md
index de9c07697..be3ef1ec0 100644
--- a/website/source/docs/provisioning/ansible_intro.html.md
+++ b/website/source/docs/provisioning/ansible_intro.html.md
@@ -246,12 +246,11 @@ Certain settings in Ansible are (only) adjustable via a [configuration file](htt
When shipping an Ansible configuration file it is good to know that:
- - it is possible to reference an Ansible configuration file via `ANSIBLE_CONFIG` environment variable, if you want to be flexible about the location of this file.
- - as of Ansible 1.5, the lookup order is the following:
-
- - `ANSIBLE_CONFIG` an environment variable
- - `ansible.cfg` in the runtime working directory
- - `.ansible.cfg` in the user home directory
- - `/etc/ansible/ansible.cfg`
-
- - `ansible-playbook` doesn't look for a configuration file relative to the playbook file location (e.g. in the same directory)
+ - as of Ansible 1.5, the lookup order is the following:
+ - any path set as `ANSIBLE_CONFIG` environment variable
+ - `ansible.cfg` in the runtime working directory
+ - `.ansible.cfg` in the user home directory
+ - `/etc/ansible/ansible.cfg`
+ - Ansible commands don't look for a configuration file relative to the playbook file location (e.g. in the same directory)
+ - an `ansible.cfg` file located in the same directory as your `Vagrantfile` will be used by default.
+ - it is also possible to reference any other location with the [config_file](/docs/provisioning/ansible_common.html#config_file) provisioner option. In this case, Vagrant will set the `ANSIBLE_CONFIG` environment variable accordingly.
From ed09558fd71f5e5f12609c8c0b976e07ef8824ce Mon Sep 17 00:00:00 2001
From: Seth Vargo
Date: Fri, 21 Oct 2016 21:38:53 -0700
Subject: [PATCH 082/205] Fix website descriptions
---
website/config.rb | 9 +++++++++
website/source/layouts/_header.erb | 2 +-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/website/config.rb b/website/config.rb
index e9b2dfba3..5ff2e35bb 100644
--- a/website/config.rb
+++ b/website/config.rb
@@ -56,4 +56,13 @@ helpers do
"Vagrant by HashiCorp"
end
+
+ # Get the description for the page
+ #
+ # @param [Middleman::Page] page
+ #
+ # @return [String]
+ def description_for(page)
+ return escape_html(current_page.data.description || "")
+ end
end
diff --git a/website/source/layouts/_header.erb b/website/source/layouts/_header.erb
index 84d5e9a27..d3a9dec1c 100644
--- a/website/source/layouts/_header.erb
+++ b/website/source/layouts/_header.erb
@@ -5,7 +5,7 @@
<%= title_for(current_page) %>
-
+
<%= stylesheet_link_tag "application" %>
From b9174895a50f69d62b6b981428b680cf53a89f66 Mon Sep 17 00:00:00 2001
From: Gilles Cornu
Date: Sun, 23 Oct 2016 20:46:30 +0200
Subject: [PATCH 083/205] provisioners/ansible (minor): Fix alphabetical order
of base attributes
This point was missed in #6627.
---
plugins/provisioners/ansible/config/base.rb | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/plugins/provisioners/ansible/config/base.rb b/plugins/provisioners/ansible/config/base.rb
index 6b9e73a40..ae643591f 100644
--- a/plugins/provisioners/ansible/config/base.rb
+++ b/plugins/provisioners/ansible/config/base.rb
@@ -10,8 +10,8 @@ module VagrantPlugins
attr_accessor :galaxy_role_file
attr_accessor :galaxy_roles_path
attr_accessor :galaxy_command
- attr_accessor :host_vars
attr_accessor :groups
+ attr_accessor :host_vars
attr_accessor :inventory_path
attr_accessor :limit
attr_accessor :playbook
@@ -30,8 +30,8 @@ module VagrantPlugins
@galaxy_role_file = UNSET_VALUE
@galaxy_roles_path = UNSET_VALUE
@galaxy_command = UNSET_VALUE
- @host_vars = UNSET_VALUE
@groups = UNSET_VALUE
+ @host_vars = UNSET_VALUE
@inventory_path = UNSET_VALUE
@limit = UNSET_VALUE
@playbook = UNSET_VALUE
@@ -51,8 +51,8 @@ module VagrantPlugins
@galaxy_role_file = nil if @galaxy_role_file == UNSET_VALUE
@galaxy_roles_path = nil if @galaxy_roles_path == UNSET_VALUE
@galaxy_command = GALAXY_COMMAND_DEFAULT if @galaxy_command == UNSET_VALUE
- @host_vars = {} if @host_vars == UNSET_VALUE
@groups = {} if @groups == UNSET_VALUE
+ @host_vars = {} if @host_vars == UNSET_VALUE
@inventory_path = nil if @inventory_path == UNSET_VALUE
@limit = nil if @limit == UNSET_VALUE
@playbook = nil if @playbook == UNSET_VALUE
From fb4e4320b2d2f8261855dfd9b8c8a5221db3c717 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Mon, 24 Oct 2016 10:06:59 -0700
Subject: [PATCH 084/205] Remove `set -e` usage for better shell compatibility
---
plugins/guests/arch/cap/change_host_name.rb | 10 +++----
plugins/guests/arch/cap/configure_networks.rb | 11 ++++----
plugins/guests/arch/cap/nfs.rb | 6 ++---
plugins/guests/arch/cap/rsync.rb | 2 +-
plugins/guests/atomic/cap/change_host_name.rb | 10 +++----
plugins/guests/bsd/cap/nfs.rb | 10 +++----
plugins/guests/bsd/cap/public_key.rb | 22 ++++++++--------
plugins/guests/darwin/cap/change_host_name.rb | 23 ++++++++--------
plugins/guests/debian/cap/change_host_name.rb | 3 ---
.../guests/debian/cap/configure_networks.rb | 2 +-
plugins/guests/debian/cap/nfs.rb | 2 +-
plugins/guests/debian/cap/rsync.rb | 1 -
plugins/guests/gentoo/cap/change_host_name.rb | 6 ++---
plugins/guests/linux/cap/nfs.rb | 26 +++++++++----------
plugins/guests/linux/cap/public_key.rb | 20 ++++++--------
plugins/guests/netbsd/cap/change_host_name.rb | 5 ++--
test/unit/plugins/guests/bsd/cap/nfs_test.rb | 11 ++++----
.../guests/linux/cap/mount_nfs_test.rb | 10 +++----
18 files changed, 80 insertions(+), 100 deletions(-)
diff --git a/plugins/guests/arch/cap/change_host_name.rb b/plugins/guests/arch/cap/change_host_name.rb
index 0b10112e1..39bc5e586 100644
--- a/plugins/guests/arch/cap/change_host_name.rb
+++ b/plugins/guests/arch/cap/change_host_name.rb
@@ -8,18 +8,16 @@ module VagrantPlugins
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
basename = name.split(".", 2)[0]
comm.sudo <<-EOH.gsub(/^ {14}/, "")
- set -e
+ # Remove comments and blank lines from /etc/hosts
+ sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts
# Set hostname
hostnamectl set-hostname '#{basename}'
- # Remove comments and blank lines from /etc/hosts
- sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts
-
# Prepend ourselves to /etc/hosts
- grep -w '#{name}' /etc/hosts || {
+ test $? -eq 0 && (grep -w '#{name}' /etc/hosts || {
sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts
- }
+ })
EOH
end
end
diff --git a/plugins/guests/arch/cap/configure_networks.rb b/plugins/guests/arch/cap/configure_networks.rb
index 2fa9c8017..0c748b3d8 100644
--- a/plugins/guests/arch/cap/configure_networks.rb
+++ b/plugins/guests/arch/cap/configure_networks.rb
@@ -12,10 +12,9 @@ module VagrantPlugins
def self.configure_networks(machine, networks)
comm = machine.communicate
+ commands = []
- commands = ["set -e"]
interfaces = machine.guest.capability(:network_interfaces)
-
networks.each.with_index do |network, i|
network[:device] = interfaces[network[:interface]]
@@ -42,15 +41,15 @@ module VagrantPlugins
commands << <<-EOH.gsub(/^ {14}/, '')
# Configure #{network[:device]}
- mv '#{remote_path}' '/etc/netctl/#{network[:device]}'
- ip link set '#{network[:device]}' down
- netctl restart '#{network[:device]}'
+ mv '#{remote_path}' '/etc/netctl/#{network[:device]}' &&
+ ip link set '#{network[:device]}' down &&
+ netctl restart '#{network[:device]}' &&
netctl enable '#{network[:device]}'
EOH
end
# Run all the network modification commands in one communicator call.
- comm.sudo(commands.join("\n"))
+ comm.sudo(commands.join(" && \n"))
end
end
end
diff --git a/plugins/guests/arch/cap/nfs.rb b/plugins/guests/arch/cap/nfs.rb
index 116256ed2..5ac5dfe67 100644
--- a/plugins/guests/arch/cap/nfs.rb
+++ b/plugins/guests/arch/cap/nfs.rb
@@ -15,8 +15,7 @@ module VagrantPlugins
# https://bbs.archlinux.org/viewtopic.php?id=193410
#
comm.sudo <<-EOH.gsub(/^ {12}/, "")
- set -e
- systemctl enable rpcbind
+ systemctl enable rpcbind &&
systemctl start rpcbind
EOH
end
@@ -24,8 +23,7 @@ module VagrantPlugins
def self.nfs_client_install(machine)
comm = machine.communicate
comm.sudo <<-EOH.gsub(/^ {12}/, "")
- set -e
- pacman --noconfirm -Syy
+ pacman --noconfirm -Syy &&
pacman --noconfirm -S nfs-utils ntp
EOH
end
diff --git a/plugins/guests/arch/cap/rsync.rb b/plugins/guests/arch/cap/rsync.rb
index 99aefa208..991a19478 100644
--- a/plugins/guests/arch/cap/rsync.rb
+++ b/plugins/guests/arch/cap/rsync.rb
@@ -5,9 +5,9 @@ module VagrantPlugins
def self.rsync_install(machine)
comm = machine.communicate
comm.sudo <<-EOH.gsub(/^ {12}/, '')
- set -e
pacman -Sy --noconfirm
pacman -S --noconfirm rsync
+ exit $?
EOH
end
end
diff --git a/plugins/guests/atomic/cap/change_host_name.rb b/plugins/guests/atomic/cap/change_host_name.rb
index 2c501c8dd..1833cf32a 100644
--- a/plugins/guests/atomic/cap/change_host_name.rb
+++ b/plugins/guests/atomic/cap/change_host_name.rb
@@ -8,18 +8,16 @@ module VagrantPlugins
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
basename = name.split(".", 2)[0]
comm.sudo <<-EOH.gsub(/^ {14}/, "")
- set -e
+ # Remove comments and blank lines from /etc/hosts
+ sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts
# Set hostname
hostnamectl set-hostname '#{basename}'
- # Remove comments and blank lines from /etc/hosts
- sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts
-
# Prepend ourselves to /etc/hosts
- grep -w '#{name}' /etc/hosts || {
+ test $? -eq 0 && (grep -w '#{name}' /etc/hosts || {
sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts
- }
+ })
EOH
end
end
diff --git a/plugins/guests/bsd/cap/nfs.rb b/plugins/guests/bsd/cap/nfs.rb
index a54835e89..458ebcfbe 100644
--- a/plugins/guests/bsd/cap/nfs.rb
+++ b/plugins/guests/bsd/cap/nfs.rb
@@ -11,10 +11,8 @@ module VagrantPlugins
def self.mount_nfs_folder(machine, ip, folders)
comm = machine.communicate
+ # Mount each folder separately so we can retry.
folders.each do |name, opts|
- # Mount each folder separately so we can retry.
- commands = ["set -e"]
-
# Shellescape the paths in case they do not have special characters.
guest_path = Shellwords.escape(opts[:guestpath])
host_path = Shellwords.escape(opts[:hostpath])
@@ -29,14 +27,14 @@ module VagrantPlugins
mount_opts = mount_opts.join(",")
# Make the directory on the guest.
- commands << "mkdir -p #{guest_path}"
+ machine.communicate.sudo("mkdir -p #{guest_path}")
# Perform the mount operation.
- commands << "/sbin/mount -t nfs -o '#{mount_opts}' #{ip}:#{host_path} #{guest_path}"
+ command = "/sbin/mount -t nfs -o '#{mount_opts}' #{ip}:#{host_path} #{guest_path}"
# Run the command, raising a specific error.
retryable(on: Vagrant::Errors::NFSMountFailed, tries: 3, sleep: 5) do
- machine.communicate.sudo(commands.join("\n"),
+ machine.communicate.sudo(command,
error_class: Vagrant::Errors::NFSMountFailed,
shell: "sh",
)
diff --git a/plugins/guests/bsd/cap/public_key.rb b/plugins/guests/bsd/cap/public_key.rb
index 8e84c0204..4f25aa967 100644
--- a/plugins/guests/bsd/cap/public_key.rb
+++ b/plugins/guests/bsd/cap/public_key.rb
@@ -22,14 +22,13 @@ module VagrantPlugins
# Use execute (not sudo) because we want to execute this as the SSH
# user (which is "vagrant" by default).
comm.execute <<-EOH.gsub(/^ {12}/, "")
- set -e
-
mkdir -p ~/.ssh
- chmod 0700 ~/.ssh
- cat '#{remote_path}' >> ~/.ssh/authorized_keys
- chmod 0600 ~/.ssh/authorized_keys
-
+ chmod 0700 ~/.ssh &&
+ cat '#{remote_path}' >> ~/.ssh/authorized_keys &&
+ chmod 0600 ~/.ssh/authorized_keys
+ result=$?
rm -f '#{remote_path}'
+ exit $result
EOH
end
@@ -49,15 +48,16 @@ module VagrantPlugins
# Use execute (not sudo) because we want to execute this as the SSH
# user (which is "vagrant" by default).
comm.execute <<-EOH.sub(/^ {12}/, "")
- set -e
-
+ result=0
if test -f ~/.ssh/authorized_keys; then
- grep -v -x -f '#{remote_path}' ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.tmp
- mv ~/.ssh/authorized_keys.tmp ~/.ssh/authorized_keys
- chmod 0600 ~/.ssh/authorized_keys
+ grep -v -x -f '#{remote_path}' ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.tmp &&
+ mv ~/.ssh/authorized_keys.tmp ~/.ssh/authorized_keys &&
+ chmod 0600 ~/.ssh/authorized_keys
+ result=$?
fi
rm -f '#{remote_path}'
+ exit $result
EOH
end
end
diff --git a/plugins/guests/darwin/cap/change_host_name.rb b/plugins/guests/darwin/cap/change_host_name.rb
index 5d5902d9e..03bc70840 100644
--- a/plugins/guests/darwin/cap/change_host_name.rb
+++ b/plugins/guests/darwin/cap/change_host_name.rb
@@ -8,16 +8,17 @@ module VagrantPlugins
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
basename = name.split(".", 2)[0]
- comm.sudo <<-EOH.gsub(/^ {14}/, '')
- set -e
-
+ # LocalHostName should not contain dots - it is used by Bonjour and
+ # visible through file sharing services.
+ comm.sudo <<-EOH.gsub(/^ */, '')
# Set hostname
- scutil --set ComputerName '#{name}'
- scutil --set HostName '#{name}'
-
- # LocalHostName should not contain dots - it is used by Bonjour and
- # visible through file sharing services.
- scutil --set LocalHostName '#{basename}'
+ scutil --set ComputerName '#{name}' &&
+ scutil --set HostName '#{name}' &&
+ scutil --set LocalHostName '#{basename}'
+ result=$?
+ if [ $result -ne 0 ]; then
+ exit $result
+ fi
hostname '#{name}'
@@ -27,8 +28,8 @@ module VagrantPlugins
# Prepend ourselves to /etc/hosts - sed on bsd is sad
grep -w '#{name}' /etc/hosts || {
- echo -e '127.0.0.1\\t#{name}\\t#{basename}' | cat - /etc/hosts > /tmp/tmp-hosts
- mv /tmp/tmp-hosts /etc/hosts
+ echo -e '127.0.0.1\\t#{name}\\t#{basename}' | cat - /etc/hosts > /tmp/tmp-hosts &&
+ mv /tmp/tmp-hosts /etc/hosts
}
EOH
end
diff --git a/plugins/guests/debian/cap/change_host_name.rb b/plugins/guests/debian/cap/change_host_name.rb
index a1ce9195a..e496004ad 100644
--- a/plugins/guests/debian/cap/change_host_name.rb
+++ b/plugins/guests/debian/cap/change_host_name.rb
@@ -8,9 +8,6 @@ module VagrantPlugins
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
basename = name.split(".", 2)[0]
comm.sudo <<-EOH.gsub(/^ {14}/, '')
- # Ensure exit on command error
- set -e
-
# Set the hostname
echo '#{basename}' > /etc/hostname
hostname -F /etc/hostname
diff --git a/plugins/guests/debian/cap/configure_networks.rb b/plugins/guests/debian/cap/configure_networks.rb
index 2553516a8..263fe924a 100644
--- a/plugins/guests/debian/cap/configure_networks.rb
+++ b/plugins/guests/debian/cap/configure_networks.rb
@@ -11,7 +11,7 @@ module VagrantPlugins
def self.configure_networks(machine, networks)
comm = machine.communicate
- commands = ["set -e"]
+ commands = []
entries = []
interfaces = machine.guest.capability(:network_interfaces)
diff --git a/plugins/guests/debian/cap/nfs.rb b/plugins/guests/debian/cap/nfs.rb
index 881469906..de9da6667 100644
--- a/plugins/guests/debian/cap/nfs.rb
+++ b/plugins/guests/debian/cap/nfs.rb
@@ -5,9 +5,9 @@ module VagrantPlugins
def self.nfs_client_install(machine)
comm = machine.communicate
comm.sudo <<-EOH.gsub(/^ {12}/, '')
- set -e
apt-get -yqq update
apt-get -yqq install nfs-common portmap
+ exit $?
EOH
end
end
diff --git a/plugins/guests/debian/cap/rsync.rb b/plugins/guests/debian/cap/rsync.rb
index b503f8cf3..6fca5d4f1 100644
--- a/plugins/guests/debian/cap/rsync.rb
+++ b/plugins/guests/debian/cap/rsync.rb
@@ -5,7 +5,6 @@ module VagrantPlugins
def self.rsync_install(machine)
comm = machine.communicate
comm.sudo <<-EOH.gsub(/^ {14}/, '')
- set -e
apt-get -yqq update
apt-get -yqq install rsync
EOH
diff --git a/plugins/guests/gentoo/cap/change_host_name.rb b/plugins/guests/gentoo/cap/change_host_name.rb
index 7d8ca3ac5..36377e077 100644
--- a/plugins/guests/gentoo/cap/change_host_name.rb
+++ b/plugins/guests/gentoo/cap/change_host_name.rb
@@ -8,8 +8,6 @@ module VagrantPlugins
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
basename = name.split(".", 2)[0]
comm.sudo <<-EOH.gsub(/^ {14}/, "")
- set -e
-
# Set the hostname
hostname '#{basename}'
echo "hostname=#{basename}" > /etc/conf.d/hostname
@@ -20,8 +18,8 @@ module VagrantPlugins
# Prepend ourselves to /etc/hosts
grep -w '#{name}' /etc/hosts || {
- echo -e '127.0.0.1\\t#{name}\\t#{basename}' | cat - /etc/hosts > /tmp/tmp-hosts
- mv /tmp/tmp-hosts /etc/hosts
+ echo -e '127.0.0.1\\t#{name}\\t#{basename}' | cat - /etc/hosts > /tmp/tmp-hosts &&
+ mv /tmp/tmp-hosts /etc/hosts
}
EOH
end
diff --git a/plugins/guests/linux/cap/nfs.rb b/plugins/guests/linux/cap/nfs.rb
index f017499aa..28e25c461 100644
--- a/plugins/guests/linux/cap/nfs.rb
+++ b/plugins/guests/linux/cap/nfs.rb
@@ -13,10 +13,8 @@ module VagrantPlugins
def self.mount_nfs_folder(machine, ip, folders)
comm = machine.communicate
+ # Mount each folder separately so we can retry.
folders.each do |name, opts|
- # Mount each folder separately so we can retry.
- commands = ["set -e"]
-
# Shellescape the paths in case they do not have special characters.
guest_path = Shellwords.escape(opts[:guestpath])
host_path = Shellwords.escape(opts[:hostpath])
@@ -30,22 +28,24 @@ module VagrantPlugins
end
mount_opts = mount_opts.join(",")
- # Make the directory on the guest.
- commands << "mkdir -p #{guest_path}"
+ machine.communicate.sudo("mkdir -p #{guest_path}")
- # Perform the mount operation.
- commands << "mount -o #{mount_opts} #{ip}:#{host_path} #{guest_path}"
-
- # Emit a mount event
- commands << <<-EOH.gsub(/^ {14}/, '')
- if test -x /sbin/initctl && command -v /sbin/init && /sbin/init --version | grep upstart; then
- /sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=#{guest_path}
+ # Perform the mount operation and emit mount event if applicable
+ command = <<-EOH.gsub(/^ */, '')
+ mount -o #{mount_opts} #{ip}:#{host_path} #{guest_path}
+ result=$?
+ if test $result -eq 0; then
+ if test -x /sbin/initctl && command -v /sbin/init && /sbin/init --version | grep upstart; then
+ /sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=#{guest_path}
+ fi
+ else
+ exit $result
fi
EOH
# Run the command, raising a specific error.
retryable(on: Vagrant::Errors::NFSMountFailed, tries: 3, sleep: 5) do
- machine.communicate.sudo(commands.join("\n"),
+ machine.communicate.sudo(command,
error_class: Vagrant::Errors::NFSMountFailed,
)
end
diff --git a/plugins/guests/linux/cap/public_key.rb b/plugins/guests/linux/cap/public_key.rb
index c75251dd3..fb8301cae 100644
--- a/plugins/guests/linux/cap/public_key.rb
+++ b/plugins/guests/linux/cap/public_key.rb
@@ -21,15 +21,13 @@ module VagrantPlugins
# Use execute (not sudo) because we want to execute this as the SSH
# user (which is "vagrant" by default).
- comm.execute <<-EOH.gsub(/^ {12}/, "")
- set -e
-
+ comm.execute <<-EOH.gsub(/^ */, "")
mkdir -p ~/.ssh
chmod 0700 ~/.ssh
- cat '#{remote_path}' >> ~/.ssh/authorized_keys
- chmod 0600 ~/.ssh/authorized_keys
-
+ cat '#{remote_path}' >> ~/.ssh/authorized_keys && chmod 0600 ~/.ssh/authorized_keys
+ result=$?
rm -f '#{remote_path}'
+ exit $result
EOH
end
@@ -48,16 +46,14 @@ module VagrantPlugins
# Use execute (not sudo) because we want to execute this as the SSH
# user (which is "vagrant" by default).
- comm.execute <<-EOH.sub(/^ {12}/, "")
- set -e
-
+ comm.execute <<-EOH.sub(/^ */, "")
if test -f ~/.ssh/authorized_keys; then
grep -v -x -f '#{remote_path}' ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.tmp
- mv ~/.ssh/authorized_keys.tmp ~/.ssh/authorized_keys
- chmod 0600 ~/.ssh/authorized_keys
+ mv ~/.ssh/authorized_keys.tmp ~/.ssh/authorized_keys && chmod 0600 ~/.ssh/authorized_keys
+ result=$?
fi
-
rm -f '#{remote_path}'
+ exit $result
EOH
end
end
diff --git a/plugins/guests/netbsd/cap/change_host_name.rb b/plugins/guests/netbsd/cap/change_host_name.rb
index 60a142399..226ee8d8b 100644
--- a/plugins/guests/netbsd/cap/change_host_name.rb
+++ b/plugins/guests/netbsd/cap/change_host_name.rb
@@ -5,9 +5,8 @@ module VagrantPlugins
def self.change_host_name(machine, name)
if !machine.communicate.test("hostname -s | grep '^#{name}$'")
machine.communicate.sudo(< /tmp/rc.conf.vagrant_changehostname_#{name}
-mv /tmp/rc.conf.vagrant_changehostname_#{name} /etc/rc.conf
+sed -e 's/^hostname=.*$/hostname=#{name}/' /etc/rc.conf > /tmp/rc.conf.vagrant_changehostname_#{name} &&
+mv /tmp/rc.conf.vagrant_changehostname_#{name} /etc/rc.conf &&
hostname #{name}
CMDS
end
diff --git a/test/unit/plugins/guests/bsd/cap/nfs_test.rb b/test/unit/plugins/guests/bsd/cap/nfs_test.rb
index 66b1adde2..aec465b9d 100644
--- a/test/unit/plugins/guests/bsd/cap/nfs_test.rb
+++ b/test/unit/plugins/guests/bsd/cap/nfs_test.rb
@@ -31,10 +31,9 @@ describe "VagrantPlugins::GuestBSD::Cap::NFS" do
}
cap.mount_nfs_folder(machine, ip, folders)
- expect(comm.received_commands[0]).to match(/set -e/)
expect(comm.received_commands[0]).to match(/mkdir -p \/guest/)
- expect(comm.received_commands[0]).to match(/mount -t nfs/)
- expect(comm.received_commands[0]).to match(/1.2.3.4:\/host \/guest/)
+ expect(comm.received_commands[1]).to match(/mount -t nfs/)
+ expect(comm.received_commands[1]).to match(/1.2.3.4:\/host \/guest/)
end
it "mounts with options" do
@@ -49,7 +48,7 @@ describe "VagrantPlugins::GuestBSD::Cap::NFS" do
}
cap.mount_nfs_folder(machine, ip, folders)
- expect(comm.received_commands[0]).to match(/mount -t nfs -o 'nfsv2,mntudp,banana'/)
+ expect(comm.received_commands[1]).to match(/mount -t nfs -o 'nfsv2,mntudp,banana'/)
end
it "escapes host and guest paths" do
@@ -61,8 +60,8 @@ describe "VagrantPlugins::GuestBSD::Cap::NFS" do
}
cap.mount_nfs_folder(machine, ip, folders)
- expect(comm.received_commands[0]).to match(/host\\\'s/)
- expect(comm.received_commands[0]).to match(/guest\\\ with\\\ spaces/)
+ expect(comm.received_commands[1]).to match(/host\\\'s/)
+ expect(comm.received_commands[1]).to match(/guest\\\ with\\\ spaces/)
end
end
end
diff --git a/test/unit/plugins/guests/linux/cap/mount_nfs_test.rb b/test/unit/plugins/guests/linux/cap/mount_nfs_test.rb
index 5fcd55de4..7cec549f2 100644
--- a/test/unit/plugins/guests/linux/cap/mount_nfs_test.rb
+++ b/test/unit/plugins/guests/linux/cap/mount_nfs_test.rb
@@ -43,7 +43,7 @@ describe "VagrantPlugins::GuestLinux::Cap::MountNFS" do
cap.mount_nfs_folder(machine, ip, folders)
expect(comm.received_commands[0]).to match(/mkdir -p #{guestpath}/)
- expect(comm.received_commands[0]).to match(/1.2.3.4:#{hostpath} #{guestpath}/)
+ expect(comm.received_commands[1]).to match(/1.2.3.4:#{hostpath} #{guestpath}/)
end
it "mounts with options" do
@@ -58,7 +58,7 @@ describe "VagrantPlugins::GuestLinux::Cap::MountNFS" do
}
cap.mount_nfs_folder(machine, ip, folders)
- expect(comm.received_commands[0]).to match(/mount -o vers=2,udp/)
+ expect(comm.received_commands[1]).to match(/mount -o vers=2,udp/)
end
it "emits an event" do
@@ -71,7 +71,7 @@ describe "VagrantPlugins::GuestLinux::Cap::MountNFS" do
}
cap.mount_nfs_folder(machine, ip, folders)
- expect(comm.received_commands[0]).to include(
+ expect(comm.received_commands[1]).to include(
"/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=#{guestpath}")
end
@@ -84,8 +84,8 @@ describe "VagrantPlugins::GuestLinux::Cap::MountNFS" do
}
cap.mount_nfs_folder(machine, ip, folders)
- expect(comm.received_commands[0]).to match(/host\\\'s/)
- expect(comm.received_commands[0]).to match(/guest\\\ with\\\ spaces/)
+ expect(comm.received_commands[1]).to match(/host\\\'s/)
+ expect(comm.received_commands[1]).to match(/guest\\\ with\\\ spaces/)
end
end
end
From 88d094505bd432e7bc9e55715bfcba0bae9f00ab Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Mon, 24 Oct 2016 12:48:43 -0700
Subject: [PATCH 085/205] Update CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ba517f559..698dcf078 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -27,6 +27,7 @@ BUG FIXES:
- guests/redhat: Properly configure network and restart service [GH-7751]
- providers/docker: Remove --interactive flag when pty is true [GH-7688]
- provisioners/ansible_local: Use enquoted path for file/directory existence checks
+ - provisioners/salt: Synchronize configuration defaults with documentation [GH-7907, GH-6624]
- pushes/atlas: Fix atlas push on Windows platform [GH-6938, GH-7802]
## 1.8.6 (September 27, 2016)
From 67f3c8b48cc51c2489d0d9258b778be7355804c2 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Tue, 25 Oct 2016 07:45:38 -0700
Subject: [PATCH 086/205] guests/redhat: Force NetworkManager to reload device
configurations
When configuring network devices force NetworkManager to reload new
configuration files as they appear. This prevents NetworkManager from
attempting to continue managing devices on initial start up.
---
plugins/guests/redhat/cap/configure_networks.rb | 8 +++-----
.../plugins/guests/redhat/cap/configure_networks_test.rb | 5 +++--
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/plugins/guests/redhat/cap/configure_networks.rb b/plugins/guests/redhat/cap/configure_networks.rb
index 04b49ab92..6749f1bdc 100644
--- a/plugins/guests/redhat/cap/configure_networks.rb
+++ b/plugins/guests/redhat/cap/configure_networks.rb
@@ -40,13 +40,11 @@ module VagrantPlugins
# Down the interface before munging the config file. This might
# fail if the interface is not actually set up yet so ignore
# errors.
- /sbin/ifdown '#{network[:device]}' || true
-
+ /sbin/ifdown '#{network[:device]}'
# Move new config into place
mv -f '#{remote_path}' '#{final_path}'
-
- # Bring the interface up
- ARPCHECK=no /sbin/ifup '#{network[:device]}'
+ # attempt to force network manager to reload configurations
+ nmcli c reload || true
EOH
end
diff --git a/test/unit/plugins/guests/redhat/cap/configure_networks_test.rb b/test/unit/plugins/guests/redhat/cap/configure_networks_test.rb
index 1da032e88..926713298 100644
--- a/test/unit/plugins/guests/redhat/cap/configure_networks_test.rb
+++ b/test/unit/plugins/guests/redhat/cap/configure_networks_test.rb
@@ -56,9 +56,10 @@ describe "VagrantPlugins::GuestRedHat::Cap::ConfigureNetworks" do
cap.configure_networks(machine, [network_1, network_2])
expect(comm.received_commands[0]).to match(/\/sbin\/ifdown 'eth1'/)
- expect(comm.received_commands[0]).to match(/\/sbin\/ifup 'eth1'/)
+ expect(comm.received_commands[0]).to match(/ifcfg-eth1/)
expect(comm.received_commands[0]).to match(/\/sbin\/ifdown 'eth2'/)
- expect(comm.received_commands[0]).to match(/\/sbin\/ifup 'eth2'/)
+ expect(comm.received_commands[0]).to match(/ifcfg-eth2/)
+ expect(comm.received_commands[0]).to match(/nmcli c reload/)
end
end
end
From c39b3fbb76ddd1e751976de4cf2e514c89a5ef19 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Tue, 25 Oct 2016 12:16:52 -0700
Subject: [PATCH 087/205] guests/openbsd: Check package installation after
installing package
The `pkg_add` command will return `0` when a package requested for
installation is not found. This adds a validation check to ensure
the rsync package is actually installed on the guest.
---
lib/vagrant/errors.rb | 4 ++
plugins/guests/openbsd/cap/rsync.rb | 17 +++++-
templates/locales/en.yml | 9 +++
.../plugins/guests/openbsd/cap/rsync_test.rb | 59 +++++++++++++++++++
4 files changed, 86 insertions(+), 3 deletions(-)
create mode 100644 test/unit/plugins/guests/openbsd/cap/rsync_test.rb
diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb
index a557f88d8..fd289eef6 100644
--- a/lib/vagrant/errors.rb
+++ b/lib/vagrant/errors.rb
@@ -608,6 +608,10 @@ module Vagrant
error_key(:rsync_not_installed_in_guest)
end
+ class RSyncGuestInstallError < VagrantError
+ error_key(:rsync_guest_install_error)
+ end
+
class SCPPermissionDenied < VagrantError
error_key(:scp_permission_denied)
end
diff --git a/plugins/guests/openbsd/cap/rsync.rb b/plugins/guests/openbsd/cap/rsync.rb
index 54663ef6a..ac1e17a1a 100644
--- a/plugins/guests/openbsd/cap/rsync.rb
+++ b/plugins/guests/openbsd/cap/rsync.rb
@@ -7,10 +7,21 @@ module VagrantPlugins
extend VagrantPlugins::SyncedFolderRSync::DefaultUnixCap
def self.rsync_install(machine)
- machine.communicate.sudo(
- 'PKG_PATH="http://ftp.openbsd.org/pub/OpenBSD/' \
+ install_output = {:stderr => '', :stdout => ''}
+ command = 'PKG_PATH="http://ftp.openbsd.org/pub/OpenBSD/' \
'`uname -r`/packages/`arch -s`/" ' \
- 'pkg_add -I rsync--')
+ 'pkg_add -I rsync--'
+ machine.communicate.sudo(command) do |type, data|
+ install_output[type] << data if install_output.key?(type)
+ end
+ # pkg_add returns 0 even if package was not found, so
+ # validate package is actually installed
+ machine.communicate.sudo('pkg_info -cA | grep inst:rsync-[[:digit:]]',
+ error_class: Vagrant::Errors::RSyncNotInstalledInGuest,
+ command: command,
+ stderr: install_output[:stderr],
+ stdout: install_output[:stdout]
+ )
end
end
end
diff --git a/templates/locales/en.yml b/templates/locales/en.yml
index 75db2d500..cfb067cc5 100644
--- a/templates/locales/en.yml
+++ b/templates/locales/en.yml
@@ -1065,6 +1065,15 @@ en:
Guest path: %{guestpath}
Command: %{command}
Error: %{stderr}
+ rsync_guest_install_error: |-
+ Installation of rsync into the guest has failed! The stdout
+ and stderr are shown below. Please read the error output, resolve
+ it and try again. If the problem persists, please install rsync
+ manually within the guest.
+
+ Command: %{command}
+ Stdout: %{stdout}
+ Stderr: %{stderr}
rsync_not_found: |-
"rsync" could not be found on your PATH. Make sure that rsync
is properly installed on your system and available on the PATH.
diff --git a/test/unit/plugins/guests/openbsd/cap/rsync_test.rb b/test/unit/plugins/guests/openbsd/cap/rsync_test.rb
new file mode 100644
index 000000000..68874b18f
--- /dev/null
+++ b/test/unit/plugins/guests/openbsd/cap/rsync_test.rb
@@ -0,0 +1,59 @@
+require_relative "../../../../base"
+
+describe "VagrantPlugins::GuestOpenBSD::Cap::RSync" do
+ let(:caps) do
+ VagrantPlugins::GuestOpenBSD::Plugin
+ .components
+ .guest_capabilities[:openbsd]
+ end
+
+ let(:machine) { double("machine") }
+ let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
+
+ before do
+ allow(machine).to receive(:communicate).and_return(comm)
+ end
+
+ after do
+ comm.verify_expectations!
+ end
+
+ describe ".rsync_install" do
+ let(:cap) { caps.get(:rsync_install) }
+
+ describe "successful installation" do
+ it "installs rsync" do
+ cap.rsync_install(machine)
+ expect(comm.received_commands[0]).to match(/pkg_add -I rsync/)
+ expect(comm.received_commands[1]).to match(/pkg_info/)
+ end
+ end
+
+ describe "failure installation" do
+ before do
+ expect(comm).to receive(:execute).and_raise(Vagrant::Errors::RSyncNotInstalledInGuest, {command: '', output: ''})
+ end
+
+ it "raises custom exception" do
+ expect{ cap.rsync_install(machine) }.to raise_error(Vagrant::Errors::RSyncNotInstalledInGuest)
+ end
+ end
+ end
+
+ describe ".rsync_installed" do
+ let(:cap) { caps.get(:rsync_installed) }
+
+ it "checks if rsync is installed" do
+ comm.expect_command("which rsync")
+ cap.rsync_installed(machine)
+ end
+ end
+
+ describe ".rsync_command" do
+ let(:cap) { caps.get(:rsync_command) }
+
+ it "defaults to 'sudo rsync'" do
+ expect(cap.rsync_command(machine)).to eq("sudo rsync")
+ end
+ end
+end
From 05c5aab92acac045503140ab3fdf98ff6519379b Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Tue, 25 Oct 2016 09:27:21 -0700
Subject: [PATCH 088/205] synced_folders/rsync: Escape exclude paths
---
.../synced_folders/rsync/default_unix_cap.rb | 2 +-
.../plugins/guests/linux/cap/rsync_test.rb | 24 ++++++++++++++-----
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/plugins/synced_folders/rsync/default_unix_cap.rb b/plugins/synced_folders/rsync/default_unix_cap.rb
index 6e073fde5..dcf4b5a34 100644
--- a/plugins/synced_folders/rsync/default_unix_cap.rb
+++ b/plugins/synced_folders/rsync/default_unix_cap.rb
@@ -32,7 +32,7 @@ module VagrantPlugins
exclude_base = Pathname.new(opts[:guestpath])
exclusions = Array(opts[:exclude]).map do |ex_path|
ex_path = ex_path.slice(1, ex_path.size) if ex_path.start_with?(File::SEPARATOR)
- "-path #{exclude_base.join(ex_path)} -prune"
+ "-path #{Shellwords.escape(exclude_base.join(ex_path))} -prune"
end.join(" -o ") + " -o "
end
"find #{guest_path} #{exclusions}" \
diff --git a/test/unit/plugins/guests/linux/cap/rsync_test.rb b/test/unit/plugins/guests/linux/cap/rsync_test.rb
index 4676cdf04..01f4e6156 100644
--- a/test/unit/plugins/guests/linux/cap/rsync_test.rb
+++ b/test/unit/plugins/guests/linux/cap/rsync_test.rb
@@ -70,15 +70,27 @@ describe "VagrantPlugins::GuestLinux::Cap::Rsync" do
end
context "with excludes provided" do
- let(:excludes){ ["tmp", "state/*"] }
+ let(:excludes){ ["tmp", "state/*", "path/with a/space"] }
it "ignores files that are excluded" do
- comm.expect_command(
- "find #{guest_directory} -path #{File.join(guest_directory, excludes.first)} -prune -o " \
- "-path #{File.join(guest_directory, excludes.last)} -prune -o '!' -type l -a '(' ! -user " \
- "#{owner} -or ! -group #{group} ')' -exec chown #{owner}:#{group} '{}' +"
- )
+ # comm.expect_command(
+ # "find #{guest_directory} -path #{Shellwords.escape(File.join(guest_directory, excludes.first))} -prune -o " \
+ # "-path #{Shellwords.escape(File.join(guest_directory, excludes.last))} -prune -o '!' " \
+ # "-path -type l -a '(' ! -user " \
+ # "#{owner} -or ! -group #{group} ')' -exec chown #{owner}:#{group} '{}' +"
+ # )
cap.rsync_post(machine, options)
+ excludes.each do |ex_path|
+ expect(comm.received_commands.first).to include("-path #{Shellwords.escape(File.join(guest_directory, ex_path))} -prune")
+ end
+ end
+
+ it "properly escapes excluded directories" do
+ cap.rsync_post(machine, options)
+ exclude_with_space = excludes.detect{|ex| ex.include?(' ')}
+ escaped_exclude_with_space = Shellwords.escape(exclude_with_space)
+ expect(comm.received_commands.first).not_to include(exclude_with_space)
+ expect(comm.received_commands.first).to include(escaped_exclude_with_space)
end
end
end
From fc6824e79ce86c5d61c515039ecab3e6ec1b98f0 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Mon, 24 Oct 2016 12:46:44 -0700
Subject: [PATCH 089/205] guests/netbsd: Include /usr/sbin in PATH for pkg_add
command
---
plugins/guests/netbsd/cap/rsync.rb | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/plugins/guests/netbsd/cap/rsync.rb b/plugins/guests/netbsd/cap/rsync.rb
index e88a0ceb4..9f9337645 100644
--- a/plugins/guests/netbsd/cap/rsync.rb
+++ b/plugins/guests/netbsd/cap/rsync.rb
@@ -8,9 +8,11 @@ module VagrantPlugins
def self.rsync_install(machine)
machine.communicate.sudo(
- 'PKG_PATH="http://ftp.NetBSD.org/pub/pkgsrc/packages/NetBSD/' \
- '`uname -m`/`uname -r | cut -d. -f1-2`/All" ' \
- 'pkg_add rsync')
+ 'PATH=$PATH:/usr/sbin '\
+ 'PKG_PATH="http://ftp.NetBSD.org/pub/pkgsrc/packages/NetBSD/' \
+ '`uname -m`/`uname -r | cut -d. -f1-2`/All" ' \
+ 'pkg_add rsync'
+ )
end
end
end
From 486960d6767932ffb7fdcc04e75639ebd3827d84 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Tue, 25 Oct 2016 14:40:29 -0700
Subject: [PATCH 090/205] Update CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 698dcf078..1389fa38a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@ IMPROVEMENTS:
- guests/linux: Place ethernet devices at start of network devices list [GH-7848]
- guests/linux: Provide more consistent guest detection [GH-7887, GH-7827]
+ - guests/openbsd: Validate guest rsync installation success [GH-7929, GH-7898]
- guests/redhat: Include Virtuozzo Linux 7 within flavor identification [GH-7818]
- guests/windows: Allow vagrant to start Windows Nano without provisioning [GH-7831]
- provisioners/ansible_local: Change the Ansible binary detection mechanism [GH-7536]
From 460ce45fb754e0033ec825600ca10daa6c051169 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Tue, 25 Oct 2016 14:42:33 -0700
Subject: [PATCH 091/205] Update CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1389fa38a..ca53b6b17 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,7 @@ BUG FIXES:
- guests/linux: Only emit upstart event if initctl is available [GH-7813]
- guests/photon: Fix networking setup [GH-7808, GH-7873]
- guests/redhat: Properly configure network and restart service [GH-7751]
+ - guests/redhat: Prevent NetworkManager from managing devices on initial start [GH-7926]
- providers/docker: Remove --interactive flag when pty is true [GH-7688]
- provisioners/ansible_local: Use enquoted path for file/directory existence checks
- provisioners/salt: Synchronize configuration defaults with documentation [GH-7907, GH-6624]
From 8732ac646745c816705c23eb92377506eff52fb8 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Tue, 25 Oct 2016 14:43:53 -0700
Subject: [PATCH 092/205] Update CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ca53b6b17..e6af87869 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,6 +20,7 @@ BUG FIXES:
- core: Prevent duplicate provider priorities [GH-7756]
- core: Allow Numeric type for box version [GH-7874, GH-6960]
- core: Provide friendly error when user environment is too large [GH-7889, GH-7857]
+ - guests: Remove `set -e` usage for better shell compatibility [GH-7921, GH-7739]
- guests/linux: Fix incorrectly configured private network [GH-7844, GH-7848]
- guests/linux: Properly order network interfaces
[GH-7866, GH-7876, GH-7858, GH-7876]
From f8c444de921b726b28691b65239fbf5e30ff3ad7 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Tue, 25 Oct 2016 18:52:37 -0700
Subject: [PATCH 093/205] Update CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e6af87869..2bcf91cb8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,6 +25,7 @@ BUG FIXES:
- guests/linux: Properly order network interfaces
[GH-7866, GH-7876, GH-7858, GH-7876]
- guests/linux: Only emit upstart event if initctl is available [GH-7813]
+ - guests/netbsd: Fix rsync installation [GH-7922, GH-7901]
- guests/photon: Fix networking setup [GH-7808, GH-7873]
- guests/redhat: Properly configure network and restart service [GH-7751]
- guests/redhat: Prevent NetworkManager from managing devices on initial start [GH-7926]
From fff1c7268406a1e59991afeabe2527eaaea547a0 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Wed, 26 Oct 2016 07:17:13 -0700
Subject: [PATCH 094/205] Update CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2bcf91cb8..9bb334faa 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -29,6 +29,7 @@ BUG FIXES:
- guests/photon: Fix networking setup [GH-7808, GH-7873]
- guests/redhat: Properly configure network and restart service [GH-7751]
- guests/redhat: Prevent NetworkManager from managing devices on initial start [GH-7926]
+ - plugins/rsync: Escape exclude paths [GH-7928, GH-7910]
- providers/docker: Remove --interactive flag when pty is true [GH-7688]
- provisioners/ansible_local: Use enquoted path for file/directory existence checks
- provisioners/salt: Synchronize configuration defaults with documentation [GH-7907, GH-6624]
From a4408037ba42ff700305c094562b18898a677c9c Mon Sep 17 00:00:00 2001
From: Azul
Date: Sat, 23 Apr 2016 18:12:52 +0100
Subject: [PATCH 095/205] add support for environment variables on a puppet
apply run
---
plugins/provisioners/puppet/config/puppet.rb | 29 +++++++++++--------
.../docs/provisioning/puppet_apply.html.md | 3 ++
2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/plugins/provisioners/puppet/config/puppet.rb b/plugins/provisioners/puppet/config/puppet.rb
index 47215ca92..fe7275636 100644
--- a/plugins/provisioners/puppet/config/puppet.rb
+++ b/plugins/provisioners/puppet/config/puppet.rb
@@ -13,6 +13,7 @@ module VagrantPlugins
attr_accessor :manifests_path
attr_accessor :environment
attr_accessor :environment_path
+ attr_accessor :environment_variables
attr_accessor :module_path
attr_accessor :options
attr_accessor :synced_folder_type
@@ -23,18 +24,19 @@ module VagrantPlugins
def initialize
super
- @binary_path = UNSET_VALUE
- @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
+ @binary_path = UNSET_VALUE
+ @hiera_config_path = UNSET_VALUE
+ @manifest_file = UNSET_VALUE
+ @manifests_path = UNSET_VALUE
+ @environment = UNSET_VALUE
+ @environment_path = UNSET_VALUE
+ @environment_variables = UNSET_VALUE
+ @module_path = UNSET_VALUE
+ @options = []
+ @facter = {}
+ @synced_folder_type = UNSET_VALUE
+ @temp_dir = UNSET_VALUE
+ @working_directory = UNSET_VALUE
end
def nfs=(value)
@@ -85,6 +87,9 @@ module VagrantPlugins
if @manifest_file == UNSET_VALUE
@manifest_file = nil
end
+ if @environment_variables == UNSET_VALUE
+ @environment_variables = nil
+ end
end
@binary_path = nil if @binary_path == UNSET_VALUE
diff --git a/website/source/docs/provisioning/puppet_apply.html.md b/website/source/docs/provisioning/puppet_apply.html.md
index 2de1c1542..ba3413c6a 100644
--- a/website/source/docs/provisioning/puppet_apply.html.md
+++ b/website/source/docs/provisioning/puppet_apply.html.md
@@ -52,6 +52,9 @@ available below this section.
* `environment_path` (string) - Path to the directory that contains environment
files on the host disk.
+* `environment_variables` (hash) - A hash of data to be set as environment
+ variables before the puppet apply run.
+
* `options` (array of strings) - Additionally options to pass to the
Puppet executable when running Puppet.
From 9b12d4db4899346e6ebd4580f22d7c27eacf956a Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Wed, 26 Oct 2016 09:51:56 -0700
Subject: [PATCH 096/205] Pass configuration environment variables to apply
command
---
.../provisioners/puppet/provisioner/puppet.rb | 27 ++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/plugins/provisioners/puppet/provisioner/puppet.rb b/plugins/provisioners/puppet/provisioner/puppet.rb
index dcf6863aa..9f8912b7b 100644
--- a/plugins/provisioners/puppet/provisioner/puppet.rb
+++ b/plugins/provisioners/puppet/provisioner/puppet.rb
@@ -207,7 +207,7 @@ module VagrantPlugins
options = options.join(" ")
# Build up the custom facts if we have any
- facter = ""
+ facter = nil
if !config.facter.empty?
facts = []
config.facter.each do |key, value|
@@ -219,7 +219,7 @@ module VagrantPlugins
facts.map! { |v| "$env:#{v};" }
end
- facter = "#{facts.join(" ")} "
+ facter = facts.join(" ")
end
puppet_bin = "puppet"
@@ -227,7 +227,28 @@ module VagrantPlugins
puppet_bin = File.join(@config.binary_path, puppet_bin)
end
- command = "#{facter} #{puppet_bin} apply #{options}"
+ env_vars = nil
+ if !config.environment_variables.nil? && !config.environment_variables.empty?
+ env_vars = config.environment_variables.map do |env_key, env_value|
+ "#{env_key}=\"#{env_value}\""
+ end
+
+ if windows?
+ env_vars.map! do |env_var_string|
+ "$env:#{env_var_string}"
+ end
+ end
+
+ env_vars = env_vars.join(" ")
+ end
+
+ command = [
+ env_vars,
+ facter,
+ puppet_bin,
+ "apply",
+ options
+ ].compact.map(&:to_s).join(" ")
if config.working_directory
if windows?
command = "cd #{config.working_directory}; if ($?) \{ #{command} \}"
From 58c3be9344ac0543242b169e8621faf998322af0 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Thu, 27 Oct 2016 15:14:13 -0700
Subject: [PATCH 097/205] Default the puppet config environment variables to an
empty hash
---
plugins/provisioners/puppet/config/puppet.rb | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/plugins/provisioners/puppet/config/puppet.rb b/plugins/provisioners/puppet/config/puppet.rb
index fe7275636..568de5fdb 100644
--- a/plugins/provisioners/puppet/config/puppet.rb
+++ b/plugins/provisioners/puppet/config/puppet.rb
@@ -87,9 +87,10 @@ module VagrantPlugins
if @manifest_file == UNSET_VALUE
@manifest_file = nil
end
- if @environment_variables == UNSET_VALUE
- @environment_variables = nil
- end
+ end
+
+ if @environment_variables == UNSET_VALUE
+ @environment_variables = {}
end
@binary_path = nil if @binary_path == UNSET_VALUE
From 4595082a23c80cdfee1f0cabb7e6a33bc6134877 Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Thu, 27 Oct 2016 15:15:03 -0700
Subject: [PATCH 098/205] Include hash data types within puppet apply
documentation
---
website/source/docs/provisioning/puppet_apply.html.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/website/source/docs/provisioning/puppet_apply.html.md b/website/source/docs/provisioning/puppet_apply.html.md
index ba3413c6a..cf1a69461 100644
--- a/website/source/docs/provisioning/puppet_apply.html.md
+++ b/website/source/docs/provisioning/puppet_apply.html.md
@@ -52,8 +52,8 @@ available below this section.
* `environment_path` (string) - Path to the directory that contains environment
files on the host disk.
-* `environment_variables` (hash) - A hash of data to be set as environment
- variables before the puppet apply run.
+* `environment_variables` (hash) - A hash of string key/value pairs to be set as
+ environment variables before the puppet apply run.
* `options` (array of strings) - Additionally options to pass to the
Puppet executable when running Puppet.
From 91723e08efef896b18f972f64b5061497c36cb6c Mon Sep 17 00:00:00 2001
From: Chris Roberts
Date: Fri, 28 Oct 2016 12:48:20 -0700
Subject: [PATCH 099/205] Update CHANGELOG
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9bb334faa..2a1824fd1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ IMPROVEMENTS:
- guests/windows: Allow vagrant to start Windows Nano without provisioning [GH-7831]
- provisioners/ansible_local: Change the Ansible binary detection mechanism [GH-7536]
- provisioners/ansible(both): Add the `playbook_command` option [GH-7881]
+ - provisioners/puppet: Support custom environment variables [GH-7931, GH-7252, GH-2270]
- util/safe_exec: Use subprocess for safe_exec on Windows [GH-7802]
- util/subprocess: Allow closing STDIN [GH-7778]
From 32784082f998ecb27887a2e2bef19d8aff88ee78 Mon Sep 17 00:00:00 2001
From: Seth Vargo
Date: Sat, 29 Oct 2016 14:00:40 -0400
Subject: [PATCH 100/205] Add security page
---
website/source/layouts/_footer.erb | 1 +
website/source/layouts/about.erb | 3 +++
website/source/security.html.erb | 33 ++++++++++++++++++++++++++++++
3 files changed, 37 insertions(+)
create mode 100644 website/source/security.html.erb
diff --git a/website/source/layouts/_footer.erb b/website/source/layouts/_footer.erb
index 29da13f4c..fecd485bc 100644
--- a/website/source/layouts/_footer.erb
+++ b/website/source/layouts/_footer.erb
@@ -12,6 +12,7 @@
VMware
Boxes
Support
+ Security
Book
diff --git a/website/source/layouts/about.erb b/website/source/layouts/about.erb
index 9ee1e5011..2bdec11fb 100644
--- a/website/source/layouts/about.erb
+++ b/website/source/layouts/about.erb
@@ -14,6 +14,9 @@
>
Sponsors
+ >
+ Security
+
<% end %>
diff --git a/website/source/security.html.erb b/website/source/security.html.erb
new file mode 100644
index 000000000..858e14bf8
--- /dev/null
+++ b/website/source/security.html.erb
@@ -0,0 +1,33 @@
+---
+layout: "about"
+sidebar_current: "about-security"
+page_title: "Security"
+description: |-
+ Vagrant takes security very seriously. Please responsibly disclose any security vulnerabilities found and we'll handle it quickly.
+---
+
+Vagrant Security
+
+
+ We understand that many users place a high level of trust in HashiCorp
+ and the tools we build. We apply best practices and focus on security to
+ make sure we can maintain the trust of the community.
+
+
+
+ We deeply appreciate any effort to disclose vulnerabilities responsibly.
+
+
+
+ If you would like to report a vulnerability, please see the HashiCorp security
+ page, which has the proper email to communicate with as well as our
+ PGP key. Please do not create an GitHub issue for security
+ concerns.
+
+
+
+ If you need to report a non-security related bug, please open and issue
+ on the Vagrant
+ GitHub repository.
+
From cff330f05657a0be4d596bb2e7edf1bdf2ecfa05 Mon Sep 17 00:00:00 2001
From: Seth Vargo
Date: Sat, 29 Oct 2016 16:46:32 -0400
Subject: [PATCH 101/205] Capital C
---
website/source/layouts/_header.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/website/source/layouts/_header.erb b/website/source/layouts/_header.erb
index d3a9dec1c..42a3ddc94 100644
--- a/website/source/layouts/_header.erb
+++ b/website/source/layouts/_header.erb
@@ -32,7 +32,7 @@