Skip to content

Commit

Permalink
Merge commit '07a51906769ad1d717e9246a67d3dc4fc57e84a9'
Browse files Browse the repository at this point in the history
* commit '07a51906769ad1d717e9246a67d3dc4fc57e84a9':
  Update CHANGELOG
  Update CHANGELOG
  Update CHANGELOG
  Fixes hashicorp#10950: Ensure pip_install_cmd is finalized
  Fixes hashicorp#11027: Ensure VM id is passed to list snapshots
  Update CHANGELOG
  Move around example mention in docs
  Docs: Add note about running bash with the `run` option for triggers
  Fixes hashicorp#10966: Ensure all subdirectory files are watched
  Fixes issue hashicorp#10973: checks that VMMS WMI reference is null & throws appropriately
  ansible_ssh_host in the example is deprecated
  • Loading branch information
jojohans committed Oct 4, 2019
2 parents b47b29c + 07a5190 commit d41852b
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -12,12 +12,16 @@ IMPROVEMENTS:
- guest/suse: Add ipv6 network config templates for SUSE based distributions [GH-11013]
- dev: Fixed Vagrantfile for Vagrant development [GH-11012]
- provisioners/chef: Update pkg install flags for chef on FreeBSD guests [GH-11075]
- provider/hyperv: Improve error message when VMMS is not running [GH-10978]

BUG FIXES:

- provider/docker: Fix default provider validation if password is used [GH-11053]
- provider/docker: Fix Docker providers usable? check [GH-11068]
- core: Ensure proper paths are shown in config loading exceptions [GH-11056]
- command/rsync-auto: Fix path watcher bug so that all subdirectories are synced when changed [GH-11089]
- command/snapshot/save: Ensure VM id is passed to list snapshots for hyper-v provider [GH-11097]
- provisioner/ansible_local: Ensure pip_install_cmd is finalized to emptry string [GH-11098]

## 2.2.5 (June 19, 2019)

Expand Down
10 changes: 9 additions & 1 deletion plugins/commands/snapshot/command/save.rb
Expand Up @@ -31,7 +31,15 @@ def execute
help: opts.help.chomp
end

name = argv.pop
# If no snapshot name is given, the backup name is the same as the machine name.
# If there is a name given, we need to remove it and save it as `name`. Otherwise
# `with_target_vms` will treat the snapshot name as a guest name.
if argv.size < 2
name = argv.first
else
name = argv.pop
end

with_target_vms(argv) do |vm|
if !vm.provider.capability?(:snapshot_list)
raise Vagrant::Errors::SnapshotNotSupported
Expand Down
Expand Up @@ -355,6 +355,9 @@ function Report-ErrorVagrantVMImport {
)

$ManagementService = Get-WmiObject -Namespace 'root\virtualization\v2' -Class 'Msvm_VirtualSystemManagementService'
if($null -eq $ManagementService) {
throw 'The Hyper-V Virtual Machine Management Service (VMMS) is not running.'
}

# Relative path names will fail when attempting to import a system
# definition so always ensure we are using the full path to the
Expand Down
1 change: 0 additions & 1 deletion plugins/provisioners/ansible/cap/guest/pip/pip.rb
Expand Up @@ -21,7 +21,6 @@ def self.pip_install(machine, package = "", version = "", pip_args = "", upgrade
end

def self.get_pip(machine, pip_install_cmd=DEFAULT_PIP_INSTALL_CMD)

# The objective here is to get pip either by default
# or by the argument passed in. The objective is not
# to circumvent the pip setup by passing in nothing.
Expand Down
4 changes: 2 additions & 2 deletions plugins/provisioners/ansible/config/guest.rb
Expand Up @@ -19,7 +19,7 @@ def initialize
@install = UNSET_VALUE
@install_mode = UNSET_VALUE
@pip_args = UNSET_VALUE
@pip_install_cmd = UNSET_VALUE
@pip_install_cmd = UNSET_VALUE
@provisioning_path = UNSET_VALUE
@tmp_path = UNSET_VALUE
end
Expand All @@ -30,7 +30,7 @@ def finalize!
@install = true if @install == UNSET_VALUE
@install_mode = :default if @install_mode == UNSET_VALUE
@pip_args = "" if @pip_args == UNSET_VALUE
@pip_install_cmd = "" if @pip_args == UNSET_VALUE
@pip_install_cmd = "" if @pip_install_cmd == UNSET_VALUE
@provisioning_path = "/vagrant" if provisioning_path == UNSET_VALUE
@tmp_path = "/tmp/vagrant-ansible" if tmp_path == UNSET_VALUE
end
Expand Down
2 changes: 1 addition & 1 deletion plugins/provisioners/ansible/provisioner/guest.rb
Expand Up @@ -33,7 +33,7 @@ def provision
# Current limitations:
# - The installation of a specific Ansible version is only supported by
# the "pip" install_mode. Note that "pip" installation also takes place
# via a default command. If pip needs to be installed differently then
# via a default command. If pip needs to be installed differently then
# the command can be overwritten by supplying "pip_install_cmd" in the
# config settings.
# - There is no absolute guarantee that the automated installation will replace
Expand Down
4 changes: 4 additions & 0 deletions plugins/synced_folders/rsync/helper.rb
Expand Up @@ -30,6 +30,10 @@ def self.exclude_to_regexp(exclude)
exclude = exclude[1..-1]
end

exclude = "#{exclude}/" if !exclude.end_with?("/")
exclude = "^#{exclude}"
exclude += ".*" if !start_anchor

# This is not an ideal solution, but it's a start. We can improve and
# keep unit tests passing in the future.
exclude = exclude.gsub("**", "|||GLOBAL|||")
Expand Down
23 changes: 23 additions & 0 deletions test/unit/plugins/commands/snapshot/command/save_test.rb
Expand Up @@ -76,6 +76,29 @@
end
end

context "with a snapshot guest and name given" do
let(:argv) { ["foo", "backup"] }
it "calls snapshot_save with a snapshot name" do
machine.id = "foo"

expect(machine).to receive(:action) do |name, opts|
expect(name).to eq(:snapshot_save)
expect(opts[:snapshot_name]).to eq("backup")
end

expect(subject.execute).to eq(0)
end

it "doesn't snapshot a non-existent machine" do
machine.id = nil

expect(subject).to receive(:with_target_vms){}

expect(machine).to_not receive(:action)
expect(subject.execute).to eq(0)
end
end

context "with a duplicate snapshot name given and no force flag" do
let(:argv) { ["test"] }

Expand Down
Expand Up @@ -61,6 +61,7 @@
expect(subject.install_mode).to eql(:default)
expect(subject.provisioning_path).to eql("/vagrant")
expect(subject.tmp_path).to eql("/tmp/vagrant-ansible")
expect(subject.pip_install_cmd).to eql("")
end
end

Expand Down
8 changes: 4 additions & 4 deletions test/unit/plugins/synced_folders/rsync/helper_test.rb
Expand Up @@ -33,22 +33,22 @@

it "converts a directory match" do
expect(described_class.exclude_to_regexp("foo/")).
to eq(/foo\//)
to eq(/^foo\/.[^\/]*/)
end

it "converts the start anchor" do
expect(described_class.exclude_to_regexp("/foo")).
to eq(/foo/)
to eq(/^foo\//)
end

it "converts the **" do
expect(described_class.exclude_to_regexp("fo**o")).
to eq(/fo.*o/)
to eq(/^fo.*o\/.[^\/]*/)
end

it "converts the *" do
expect(described_class.exclude_to_regexp("fo*o")).
to eq(/fo[^\/]*o/)
to eq(/^fo[^\/]*o\/.[^\/]*/)
end
end

Expand Down
4 changes: 2 additions & 2 deletions website/source/docs/provisioning/ansible_local.html.md
Expand Up @@ -227,8 +227,8 @@ You need to create a static `inventory` file that corresponds to your `Vagrantfi

```
controller ansible_connection=local
node1 ansible_ssh_host=172.17.177.21 ansible_ssh_private_key_file=/vagrant/.vagrant/machines/node1/virtualbox/private_key
node2 ansible_ssh_host=172.17.177.22 ansible_ssh_private_key_file=/vagrant/.vagrant/machines/node2/virtualbox/private_key
node1 ansible_host=172.17.177.21 ansible_ssh_private_key_file=/vagrant/.vagrant/machines/node1/virtualbox/private_key
node2 ansible_host=172.17.177.22 ansible_ssh_private_key_file=/vagrant/.vagrant/machines/node2/virtualbox/private_key
[nodes]
node[1:2]
Expand Down
12 changes: 12 additions & 0 deletions website/source/docs/triggers/configuration.html.md
Expand Up @@ -74,6 +74,18 @@ The trigger class takes various options.
+ `inline`
+ `path`

**Note:** The `run` option with `inline` is not entirely like a shell provisioner that runs bash.
It executes binaries on your machine rather than a bash script. For example:
If you wish you use bash to pipe some text to a file in your `run` option with `inline`, wrap
your inline script with _`bash -c "<script goes here>"`_.:

```ruby
config.trigger.after :up do |trigger|
trigger.info = "More information"
trigger.run = {inline: "bash -c 'echo \"hey there!!\" > file.txt'"}
end
```

* `warn` (string) - A warning message that will be printed at the beginning of a trigger.

* `exit_codes` (integer, array) - A set of acceptable exit codes to continue on. Defaults to `0` if option is absent. For now only valid with the `run` option.
Expand Down

0 comments on commit d41852b

Please sign in to comment.