Merge remote-tracking branch 'origin/master' into hyperv-plugin

This commit is contained in:
Zhongcheng Lao 2019-06-29 16:10:54 +08:00
commit 9c09b1c736
23 changed files with 454 additions and 68 deletions

View File

@ -1,5 +1,133 @@
version: 2
reference:
environment: &ENVIRONMENT
SLACK_TITLE: Vagrant CI
RELEASE_TARGET_REPONAME: vagrant-installers
images:
ruby23: &ruby23
docker:
- image: circleci/ruby:2.3
ruby24: &ruby24
docker:
- image: circleci/ruby:2.4
ruby25: &ruby25
docker:
- image: circleci/ruby:2.5
ruby26: &ruby26
docker:
- image: circleci/ruby:2.6
builder: &builder
environment:
<<: *ENVIRONMENT
docker:
- image: $BUILDER_IMAGE
auth:
username: $BUILDER_USERNAME
password: $BUILDER_PASSWORD
workflows:
public: &PUBLIC_WORKFLOW
filters:
branches:
only: /^pull\/.*/
master: &MASTER_WORKFLOW
filters:
branches:
only: master
private_build: &PRIVATE_WORKFLOW_BUILD
context: vagrant
filters:
branches:
only:
- /^build-.*/
tags:
only: /.*/
jobs:
private_failure: &PRIVATE_FAILURE
run:
name: Failure handler
command: |
if [ -f .output ]; then
slack -m "Vagrant job has failed: *${CIRCLE_JOB}*" -s error -f .output -T 5
else
slack -m "Vagrant job has failed: *${CIRCLE_JOB}*" -s error
fi
when: on_fail
unit_tests: &unit_tests
steps:
- run: sudo apt-get update ; sudo apt-get -yq install bsdtar
- checkout
- restore_cache:
key: static-site-gems-v1-{{ checksum "Gemfile.lock" }}
- run:
command: bundle check || bundle install --path vendor/bundle
- save_cache:
key: static-site-gems-v1-{{ checksum "Gemfile.lock" }}
paths:
- ./vendor/bundle
- run: bundle exec rake test:unit
jobs:
build:
<<: *builder
steps:
- checkout
- run: gem build vagrant.gemspec
- *PRIVATE_FAILURE
- persist_to_workspace:
root: .
paths:
- ./*.gem
store:
<<: *builder
steps:
- attach_workspace:
at: .
- run: |
gem_name=(vagrant-*.gem)
if [ "${CIRCLE_TAG}" == "" ]; then
remote_gem_name="vagrant-master.gem"
else
remote_gem_name="vagrant.gem"
fi
if [[ "${CIRCLE_BRANCH}" = "build-"* ]]; then
s3_dst="${ASSETS_PRIVATE_LONGTERM}/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/${CIRCLE_BRANCH##build-}/"
else
s3_dst="${ASSETS_PRIVATE_BUCKET}/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/"
fi
aws s3 cp "${gem_name}" "${s3_dst}${remote_gem_name}" > .output 2>&1
- *PRIVATE_FAILURE
release:
<<: *builder
steps:
- checkout
- attach_workspace:
at: .
- run: |
set +e
gem=(vagrant-*.gem)
gem_version="${gem##vagrant-}"
gem_version="${gem_version%%.gem}"
export GITHUB_TOKEN="${HASHIBOT_TOKEN}"
if [ "${CIRCLE_TAG}" = "" ]; then
version="v${gem_version}+$(git rev-parse --short "${CIRCLE_SHA1}")"
ghr -u ${CIRCLE_PROJECT_USERNAME} -r ${RELEASE_TARGET_REPONAME} -c master -prerelease -delete -replace ${version} ${gem} > .output 2>&1
else
version="${CIRCLE_TAG}"
ghr -u ${CIRCLE_PROJECT_USERNAME} -r ${RELEASE_TARGET_REPONAME} -c master -delete -replace ${version} ${gem} > .output 2>&1
fi
slack -m "New Vagrant installers release triggered: *${version}*"
- *PRIVATE_FAILURE
test_ruby23:
<<: *ruby23
<<: *unit_tests
test_ruby24:
<<: *ruby24
<<: *unit_tests
test_ruby25:
<<: *ruby25
<<: *unit_tests
test_ruby26:
<<: *ruby26
<<: *unit_tests
build-website:
# setting the working_directory along with the checkout path allows us to not have
# to cd into the website/ directory for commands
@ -9,30 +137,65 @@ jobs:
steps:
- checkout:
path: ~/project
# restores gem cache
- restore_cache:
key: static-site-gems-v1-{{ checksum "Gemfile.lock" }}
- run:
command: bundle check || bundle install --path vendor/bundle
# saves gem cache if we have changed the Gemfile
- save_cache:
key: static-site-gems-v1-{{ checksum "Gemfile.lock" }}
paths:
- ~/project/website/vendor/bundle
# middleman build
- run:
command: bundle exec middleman build
# website deploy
- run:
command: ./scripts/deploy.sh
workflows:
version: 2
builds:
jobs:
- build:
<<: *PRIVATE_WORKFLOW_BUILD
- store:
<<: *PRIVATE_WORKFLOW_BUILD
requires:
- build
- release:
<<: *PRIVATE_WORKFLOW_BUILD
requires:
- build
pull_requests:
jobs:
- test_ruby23:
<<: *PUBLIC_WORKFLOW
- test_ruby24:
<<: *PUBLIC_WORKFLOW
- test_ruby25:
<<: *PUBLIC_WORKFLOW
- test_ruby26:
<<: *PUBLIC_WORKFLOW
master:
jobs:
- test_ruby23:
<<: *MASTER_WORKFLOW
- test_ruby24:
<<: *MASTER_WORKFLOW
- test_ruby25:
<<: *MASTER_WORKFLOW
- test_ruby26:
<<: *MASTER_WORKFLOW
- build:
<<: *MASTER_WORKFLOW
context: vagrant
requires:
- test_ruby23
- test_ruby24
- test_ruby25
- test_ruby26
- store:
<<: *MASTER_WORKFLOW
context: vagrant
requires:
- build
website:
jobs:
- build-website:

View File

@ -2,6 +2,14 @@
FEATURES:
IMPROVEMENTS:
BUG FIXES:
## 2.2.5 (June 19, 2019)
FEATURES:
- providers/docker: Private and Public networking support [GH-10702]
IMPROVEMENTS:
@ -39,6 +47,7 @@ BUG FIXES:
- provider/virtualbox: Ensure non-existent machines do not attempt to list snapshots [GH-10784]
- provider/docker: Properly set docker-compose config file with volume names [GH-10820]
- provisioner/ansible: Fix pip installer hardcoded curl get_pip.py piped to python [GH-10625]
- provisioner/chef: Update chef install check for guests [GH-10917]
- synced_folders/rsync: Remove rsync__excludes from command if array is empty [GH-10901]
## 2.2.4 (February 27, 2019)

View File

@ -15,34 +15,20 @@ targeted at Vagrant core members who have the ability to cut a release.
$ git push --tags
```
1. Trigger an installer creation run within the HashiCorp Bamboo installation.
This will take around 45 minutes.
1. This will automatically trigger an installer creation, upload the artifacts,
and publish the release.
1. Download all the resulting artifacts into the `pkg/dist` folder relative to
the Vagrant repository on your local machine.
1. After the release has been published update the `website/config.rb` to point
to the latest version, commit, and push.
1. Run `./scripts/sign.sh` with the version that is being created. This must be
run from the Vagrant repo root. This will GPG sign and checksum the files.
1. Publish the webiste by deleting the `stable-website` branch, recreate the branch,
and force push. From the `master` branch, run:
1. Run the following command to upload the binaries to the releases site:
```
$ hc-releases upload pkg/dist
```
1. Publish the new index files to the releases site:
```
$ hc-releases publish
```
1. Update `website/config.rb` to point to the latest version, commit, and push.
1. Tell HashiBot to deploy in `#deploys`
```
hashibot deploy vagrant
```
```
$ git branch -D stable-website
$ git branch -b stable-website
$ git push -f origin stable-website
```
1. Update `version.txt` to append `.dev` and add a new blank entry in the
CHANGELOG, commit, and push.

View File

@ -938,7 +938,7 @@ module Vagrant
break
end
end
return gp if gp
return gp.to_sym if gp
begin
default_provider
rescue Errors::NoDefaultProvider
@ -955,7 +955,7 @@ module Vagrant
provider = guess_provider
vagrantfile.machine_names.each do |mname|
ldp = @local_data_path.join("machines/#{mname}/#{provider}") if @local_data_path
plugins << vagrantfile.machine_config(mname, guess_provider, boxes, ldp)[:config]
plugins << vagrantfile.machine_config(mname, guess_provider, boxes, ldp, false)[:config]
end
result = plugins.reverse.inject(Vagrant::Util::HashWithIndifferentAccess.new) do |memo, val|
Vagrant::Util::DeepMerge.deep_merge(memo, val.vagrant.plugins)
@ -1021,7 +1021,11 @@ module Vagrant
ui.warn(I18n.t("vagrant.plugins.local.install_rerun_command"))
exit(-1)
end
Vagrant::Plugin::Manager.instance.local_file.installed_plugins
if Vagrant::Plugin::Manager.instance.local_file
Vagrant::Plugin::Manager.instance.local_file.installed_plugins
else
{}
end
end
# This method copies the private key into the home directory if it

View File

@ -112,7 +112,7 @@ module Vagrant
# @param [Pathname] data_path Machine data path
# @return [Hash<Symbol, Object>] Various configuration parameters for a
# machine. See the main documentation body for more info.
def machine_config(name, provider, boxes, data_path=nil)
def machine_config(name, provider, boxes, data_path=nil, validate_provider=true)
keys = @keys.dup
sub_machine = @config.vm.defined_vms[name]
@ -127,7 +127,7 @@ module Vagrant
box_formats = nil
if provider != nil
provider_plugin = Vagrant.plugin("2").manager.providers[provider]
if !provider_plugin
if !provider_plugin && validate_provider
providers = Vagrant.plugin("2").manager.providers.to_hash.keys
if providers
providers_str = providers.join(', ')
@ -145,18 +145,22 @@ module Vagrant
machine: name, provider: provider, providers: providers_str
end
provider_cls = provider_plugin[0]
provider_options = provider_plugin[1]
box_formats = provider_options[:box_format] || provider
if validate_provider
provider_cls = provider_plugin[0]
provider_options = provider_plugin[1]
box_formats = provider_options[:box_format] || provider
# Test if the provider is usable or not
begin
provider_cls.usable?(true)
rescue Errors::VagrantError => e
raise Errors::ProviderNotUsable,
machine: name.to_s,
provider: provider.to_s,
message: e.to_s
# Test if the provider is usable or not
begin
provider_cls.usable?(true)
rescue Errors::VagrantError => e
raise Errors::ProviderNotUsable,
machine: name.to_s,
provider: provider.to_s,
message: e.to_s
end
else
box_formats = provider
end
end

View File

@ -10,7 +10,7 @@ module VagrantPlugins
command = "test -x #{knife}"
if version != :latest
command << "&& #{knife} --version | grep 'Chef: #{version}'"
command << "&& #{knife} --version | grep '#{version}'"
end
machine.communicate.test(command, sudo: true)

View File

@ -10,7 +10,7 @@ module VagrantPlugins
command = "test -x #{knife}"
if version != :latest
command << "&& #{knife} --version | grep 'Chef: #{version}'"
command << "&& #{knife} --version | grep '#{version}'"
end
machine.communicate.test(command, sudo: true)

View File

@ -11,7 +11,7 @@ module VagrantPlugins
command = "test -x #{knife}"
if version != :latest
command << "&& #{knife} --version | grep 'Chef: #{version}'"
command << "&& #{knife} --version | grep '#{version}'"
end
machine.communicate.test(command, sudo: true)

View File

@ -7,9 +7,9 @@ module VagrantPlugins
# @return [true, false]
def self.chef_installed(machine, product, version)
if version != :latest
command = 'if ((&knife --version) -Match "Chef: ' + version.to_s + '"){ exit 0 } else { exit 1 }'
command = 'if ((&knife --version) -Match "' + version.to_s + '"){ exit 0 } else { exit 1 }'
else
command = 'if ((&knife --version) -Match "Chef: *"){ exit 0 } else { exit 1 }'
command = 'if ((&knife --version) -Match "Chef*"){ exit 0 } else { exit 1 }'
end
machine.communicate.test(command, sudo: true)
end

View File

@ -69,7 +69,7 @@ module VagrantPlugins
# Checks for the existence of chef binary and error if it
# doesn't exist.
if windows?
command = "if ((&'#{binary}' -v) -Match 'Chef: *'){ exit 0 } else { exit 1 }"
command = "if ((&'#{binary}' -v) -Match 'Chef*'){ exit 0 } else { exit 1 }"
else
command = "sh -c 'command -v #{binary}'"
end

View File

@ -41,6 +41,10 @@ RSpec.configure do |c|
c.filter_run_excluding :windows
end
if !Vagrant::Util::Which.which("bsdtar")
c.filter_run_excluding :bsdtar
end
c.after(:suite) do
FileUtils.rm_rf(VAGRANT_TEST_CWD)
end

View File

@ -21,8 +21,6 @@ describe VagrantPlugins::DockerProvider::Provider do
end
describe ".usable?" do
subject { described_class.new(machine) }
it "returns true if usable" do
allow(provider_config).to receive(:compose).and_return(false)
allow(subject.driver).to receive(:execute).with("docker", "version").and_return(true)
@ -53,9 +51,10 @@ describe VagrantPlugins::DockerProvider::Provider do
end
describe "#state" do
before { allow(subject).to receive(:driver).and_return(driver_obj) }
it "returns not_created if no ID" do
allow(machine).to receive(:id).and_return(nil)
expect(subject.state.id).to eq(:not_created)
end
@ -63,7 +62,8 @@ describe VagrantPlugins::DockerProvider::Provider do
allow(provider_config).to receive(:compose).and_return(false)
allow(platform).to receive(:windows?).and_return(false)
allow(platform).to receive(:darwin?).and_return(false)
allow(machine).to receive(:id).and_return("foo")
expect(machine).to receive(:id).and_return("foo")
expect(driver_obj).to receive(:created?).with("foo").and_return(false)
expect(subject.state.id).to eq(:not_created)
end

View File

@ -0,0 +1,41 @@
require_relative "../../../../../base"
require Vagrant.source_root.join("plugins/provisioners/chef/cap/freebsd/chef_installed")
describe VagrantPlugins::Chef::Cap::FreeBSD::ChefInstalled do
include_context "unit"
let(:iso_env) do
# We have to create a Vagrantfile so there is a root path
env = isolated_environment
env.vagrantfile("")
env.create_vagrant_env
end
let(:machine) { iso_env.machine(iso_env.machine_names[0], :dummy) }
let(:communicator) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
let(:config) { double("config") }
subject { described_class }
before do
allow(machine).to receive(:communicate).and_return(communicator)
end
describe "#chef_installed" do
let(:version) { "15.0.0" }
let(:command) { "test -x /opt/chef_solo/bin/knife&& /opt/chef_solo/bin/knife --version | grep '15.0.0'" }
it "returns true if installed" do
expect(machine.communicate).to receive(:test).
with(command, sudo: true).and_return(true)
subject.chef_installed(machine, "chef_solo", version)
end
it "returns false if not installed" do
expect(machine.communicate).to receive(:test).
with(command, sudo: true).and_return(false)
expect(subject.chef_installed(machine, "chef_solo", version)).to be_falsey
end
end
end

View File

@ -0,0 +1,41 @@
require_relative "../../../../../base"
require Vagrant.source_root.join("plugins/provisioners/chef/cap/linux/chef_installed")
describe VagrantPlugins::Chef::Cap::Linux::ChefInstalled do
include_context "unit"
let(:iso_env) do
# We have to create a Vagrantfile so there is a root path
env = isolated_environment
env.vagrantfile("")
env.create_vagrant_env
end
let(:machine) { iso_env.machine(iso_env.machine_names[0], :dummy) }
let(:communicator) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
let(:config) { double("config") }
subject { described_class }
before do
allow(machine).to receive(:communicate).and_return(communicator)
end
describe "#chef_installed" do
let(:version) { "15.0.0" }
let(:command) { "test -x /opt/chef_solo/bin/knife&& /opt/chef_solo/bin/knife --version | grep '15.0.0'" }
it "returns true if installed" do
expect(machine.communicate).to receive(:test).
with(command, sudo: true).and_return(true)
subject.chef_installed(machine, "chef_solo", version)
end
it "returns false if not installed" do
expect(machine.communicate).to receive(:test).
with(command, sudo: true).and_return(false)
expect(subject.chef_installed(machine, "chef_solo", version)).to be_falsey
end
end
end

View File

@ -0,0 +1,41 @@
require_relative "../../../../../base"
require Vagrant.source_root.join("plugins/provisioners/chef/cap/omnios/chef_installed")
describe VagrantPlugins::Chef::Cap::OmniOS::ChefInstalled do
include_context "unit"
let(:iso_env) do
# We have to create a Vagrantfile so there is a root path
env = isolated_environment
env.vagrantfile("")
env.create_vagrant_env
end
let(:machine) { iso_env.machine(iso_env.machine_names[0], :dummy) }
let(:communicator) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
let(:config) { double("config") }
subject { described_class }
before do
allow(machine).to receive(:communicate).and_return(communicator)
end
describe "#chef_installed" do
let(:version) { "15.0.0" }
let(:command) { "test -x /opt/chef_solo/bin/knife&& /opt/chef_solo/bin/knife --version | grep '15.0.0'" }
it "returns true if installed" do
expect(machine.communicate).to receive(:test).
with(command, sudo: true).and_return(true)
subject.chef_installed(machine, "chef_solo", version)
end
it "returns false if not installed" do
expect(machine.communicate).to receive(:test).
with(command, sudo: true).and_return(false)
expect(subject.chef_installed(machine, "chef_solo", version)).to be_falsey
end
end
end

View File

@ -0,0 +1,41 @@
require_relative "../../../../../base"
require Vagrant.source_root.join("plugins/provisioners/chef/cap/windows/chef_installed")
describe VagrantPlugins::Chef::Cap::Windows::ChefInstalled do
include_context "unit"
let(:iso_env) do
# We have to create a Vagrantfile so there is a root path
env = isolated_environment
env.vagrantfile("")
env.create_vagrant_env
end
let(:machine) { iso_env.machine(iso_env.machine_names[0], :dummy) }
let(:communicator) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
let(:config) { double("config") }
subject { described_class }
before do
allow(machine).to receive(:communicate).and_return(communicator)
end
describe "#chef_installed" do
let(:version) { "15.0.0" }
let(:command) { "if ((&knife --version) -Match \"15.0.0\"){ exit 0 } else { exit 1 }" }
it "returns true if installed" do
expect(machine.communicate).to receive(:test).
with(command, sudo: true).and_return(true)
subject.chef_installed(machine, "chef_solo", version)
end
it "returns false if not installed" do
expect(machine.communicate).to receive(:test).
with(command, sudo: true).and_return(false)
expect(subject.chef_installed(machine, "chef_solo", version)).to be_falsey
end
end
end

View File

@ -10,7 +10,7 @@ require File.expand_path("../../../../base", __FILE__)
require "vagrant/util/file_checksum"
describe Vagrant::Action::Builtin::BoxAdd, :skip_windows do
describe Vagrant::Action::Builtin::BoxAdd, :skip_windows, :bsdtar do
include_context "unit"
let(:app) { lambda { |env| } }

View File

@ -320,7 +320,7 @@ describe Vagrant::Box, :skip_windows do
FileUtils.rm_rf(scratch)
end
it "should repackage the box" do
it "should repackage the box", :bsdtar do
test_file_contents = "hello, world!"
# Put a file in the box directory to verify it is packaged properly

View File

@ -1447,7 +1447,7 @@ VF
let(:argv) { ["--provider=single_arg"] }
it "should return the provider name" do
expect(subject.send(:guess_provider)).to eq("single_arg")
expect(subject.send(:guess_provider)).to eq(:single_arg)
end
end
@ -1455,7 +1455,7 @@ VF
let(:argv) { ["--provider", "double_arg"] }
it "should return the provider name" do
expect(subject.send(:guess_provider)).to eq("double_arg")
expect(subject.send(:guess_provider)).to eq(:double_arg)
end
end
end
@ -1561,10 +1561,18 @@ VF
allow(plugin_manager).to receive(:load_plugins)
end
context "when local data directory does not exist" do
let(:local_file) { nil }
it "should properly return empty result" do
expect(instance.send(:process_configured_plugins)).to be_empty
end
end
context "plugins are disabled" do
before{ allow(Vagrant).to receive(:plugins_enabled?).and_return(false) }
it "should return nil" do
it "should return empty result" do
expect(instance.send(:process_configured_plugins)).to be_nil
end
end

View File

@ -368,6 +368,38 @@ describe Vagrant::Vagrantfile do
to raise_error(Vagrant::Errors::ProviderNotUsable)
end
context "when provider validation is ignored" do
before do
configure do |config|
config.vm.box = "base"
config.vm.box_version = "1.0"
config.vm.define :guest1
config.vm.define :guest2
config.vm.provider "custom" do |_, c|
c.ssh.port = 123
end
end
iso_env.box3("base", "1.0", :custom, vagrantfile: <<-VF)
Vagrant.configure("2") do |config|
config.vagrant.plugins = "vagrant-custom"
end
VF
end
it "should not raise an error if provider is not found" do
expect { subject.machine_config(:guest1, :custom, boxes, nil, false) }.
not_to raise_error
end
it "should return configuration from box Vagrantfile" do
config = subject.machine_config(:guest1, :custom, boxes, nil, false)[:config]
expect(config.vagrant.plugins).to be_a(Hash)
expect(config.vagrant.plugins.keys).to include("vagrant-custom")
end
end
context "local box metadata file" do
let(:data_path) { double(:data_path) }
let(:meta_file) { double(:meta_file) }

View File

@ -1 +1 @@
2.2.5.dev
2.2.6.dev

View File

@ -5,7 +5,7 @@ set :vmware_utility_version, "1.0.7"
activate :hashicorp do |h|
h.name = "vagrant"
h.version = "2.2.4"
h.version = "2.2.5"
h.github_slug = "hashicorp/vagrant"
h.website_root = "website"
end

View File

@ -182,6 +182,18 @@ Cmnd_Alias VAGRANT_NFSD_APPLY = /usr/sbin/exportfs -ar
%vagrant ALL=(root) NOPASSWD: VAGRANT_EXPORTS_CHOWN, VAGRANT_EXPORTS_MV, VAGRANT_NFSD_CHECK, VAGRANT_NFSD_START, VAGRANT_NFSD_APPLY
```
For SUSE Linux, sudoers might look like this (given your user
belongs to the vagrant group):
```
Cmnd_Alias VAGRANT_CHOWN = /usr/bin/chown 0\:0 /tmp/vagrant[a-z0-9-]*
Cmnd_Alias VAGRANT_MV = /usr/bin/mv -f /tmp/vagrant[a-z0-9-]* /etc/exports
Cmnd_Alias VAGRANT_START = /sbin/service nfsserver start
Cmnd_Alias VAGRANT_STATUS = /sbin/service nfsserver status
Cmnd_Alias VAGRANT_APPLY = /usr/sbin/exportfs -ar
%vagrant ALL=(root) NOPASSWD: VAGRANT_CHOWN, VAGRANT_MV, VAGRANT_START, VAGRANT_STATUS, VAGRANT_APPLY
```
If you don't want to edit `/etc/sudoers` directly, you can create
`/etc/sudoers.d/vagrant-syncedfolders` with the appropriate entries,
assuming `/etc/sudoers.d` has been enabled.