Compare commits

..

1158 Commits

Author SHA1 Message Date
Brian Cain 5cc06bde64
Merge pull request #11341 from hjung4/spell
Fix spelling errors
2020-01-27 15:29:24 -08:00
comet fa43afb57b
update 2020-01-27 17:04:23 -06:00
Chris Roberts b231abe114 Update version and changelog for new development 2020-01-27 12:31:15 -08:00
Chris Roberts ac268e2638 Release v2.2.7 2020-01-27 12:29:18 -08:00
Jeff Bonhag db316a396f
Lock closed issues after 30 days (#11332)
This commit adds Hashibot support to lock closed issues after 30 days.
It also will automatically remove the `waiting-reply` tag if a user
replies to an issue with that tag.
2020-01-27 09:58:50 -05:00
Jeff Bonhag a1abc177bd
Merge pull request #11328 from Lin-Buo-Ren/patch-1
Fix missing quoting for `VagrantFile`
2020-01-21 09:27:16 -05:00
林博仁(Buo-ren Lin) 8ac6403bcc
Fix missing quoting for `VagrantFile`
Signed-off-by: 林博仁(Buo-ren, Lin) <Buo.Ren.Lin@gmail.com>
2020-01-21 16:56:14 +08:00
Chris Roberts 02c157e427 Fix environment variable value 2020-01-16 14:46:50 -08:00
Chris Roberts d8d24f4d6e
Merge pull request #11320 from chrisroberts/e-ci-updates
Add CI scripts and configuration
2020-01-16 14:24:50 -08:00
Chris Roberts ee302f3a9b Add CI scripts and configuration
Provides scripts for building, storing, and releasing Vagrant
via builders. Includes updates for testing and removal of
deprecated CI configuration.
2020-01-15 17:16:54 -08:00
Brian Cain 054f4def5c
Merge pull request #11319 from briancain/fix/typo-on-website-docs
Fix typo in CLI upload docs
2020-01-13 12:56:14 -08:00
Brian Cain 0077d7955d
Fix typo in CLI upload docs 2020-01-13 11:23:06 -08:00
Brian Cain f886184011
Merge pull request #11314 from imechemi/patch-1
Minor doc update
2020-01-13 09:32:50 -08:00
Tenzin Chemi e864605879
Update public_network.html.md 2020-01-11 23:21:30 +05:30
Brian Cain 7f09202571
Merge pull request #11300 from briancain/bug/check-respond-to-for-name-option
Check name config option with respond_to?
2020-01-09 14:59:41 -08:00
Brian Cain 2ae6b37c9a
Merge pull request #11304 from nepella/fix-typo
Ansible docs: Fix misplaced brace in example.
2020-01-08 14:21:30 -08:00
Renee Margaret McConahy 1c6ac924c5
Ansible docs: Fix misplaced brace in example. 2020-01-08 16:42:42 -05:00
Brian Cain 6855dd8c74
Check name config option with respond_to?
Prior to this commit, the check used to look for the config option
`name` in a provisioner config would accidentally create a "DummyConfig"
based on how vagrant handles missing config options. This commit fixes
that by instead using the `respond_to?` method to check for the
existance of the config option name.
2020-01-07 11:10:02 -08:00
Brian Cain dd5d73e8a9
Update CHANGELOG 2020-01-07 09:19:30 -08:00
Brian Cain 3d1f1d2422
Merge pull request #11295 from briancain/fixup/provision-with-name-shell
Fixes #11287: Set top level provisioner name if set in provisioner config
2020-01-07 09:18:19 -08:00
Brian Cain ee8b38d47a
Set provisioner names to symbol
Because Vagrant is handling provisioner names to be symbols more
uniformly now, update the mocked tests to reflect this change. Otherwise
these provisioners will be ignored and not run.
2020-01-06 13:25:31 -08:00
Brian Cain b4c302a74c
Set shell provisioner name in provision_test 2020-01-06 12:48:33 -08:00
Brian Cain 711270b90a
Fixes #11287: Set top level provisioner name if set in provisioner
config

Prior to this commit, if a user had configured a provisioner that had a
config with a `name` option, it would not properly set the top level
provisioner classes name config option which would lead to some
understanibly confusing results when trying to `--provision-with`. This
commit fixes that by checking to see if the top level name isn't set,
look to see if that provisioners config defines a name, and use that
instead.
2020-01-06 11:10:28 -08:00
Jeff Bonhag 58687e6c44
Update CHANGELOG 2019-12-20 13:14:46 -05:00
Jeff Bonhag 7fb7dd8608
Enable WinSSH shell for `vagrant ssh -c` (#11258)
This commit changes the behavior of the builtin SSHRun action to use a Windows
shell if the WinSSH communicator is active.  This allows for running one-off SSH
commands with Windows Command Prompt or PowerShell.  By default, this will not
allocate a TTY for any SSH commands.

Example usage:

```
vagrant ssh -c 'dir "c:\program files"'
```

Updates docs to reflect a change made in
a55a53e6a4.
2019-12-20 13:10:11 -05:00
Jeff Bonhag f0b8c0737f
Fixes #11269: enable_checkpoints default is true (#11272)
Update docs to reflect change made in
8aa74a03a0.
2019-12-20 12:59:51 -05:00
Jeff Bonhag 88d2077cb8
Update CHANGELOG 2019-12-19 14:49:30 -05:00
Jeff Bonhag ade076cabb
Fixes #11236: Windows port detection (#11244)
This reverts commit 81553263ab.

This fixes a regression with Windows port detection which led to port
collisions not being fixed on `vagrant up`.

PR #8517 changed `IsPortOpen#is_port_open?` to rescue
Errno::EADDRNOTAVAIL, but when we merged it into master, there was code
in `HandleForwardedPortCollisions#port_check` that depended on that
error bubbling up.
2019-12-19 14:46:13 -05:00
Chris Roberts 85065c3746 Update CHANGELOG 2019-12-18 16:50:24 -08:00
Chris Roberts 923ecc0943
Merge pull request #11267 from chrisroberts/e-catalina-synced-folders
Update synced folder setup in darwin cap for vmware
2019-12-18 16:48:05 -08:00
Chris Roberts 25659a6f6b Support properly setting up synced folders on Catalina
Since the root file system is marked as read-only, attempting to
link the shared directory to `/vagrant` will fail. If the guest
path is on the root file system and APFS is used, create the
link as a firmlink instead.
2019-12-18 13:11:30 -08:00
Chris Roberts 80c05460ab Call hooks before and after each action if they are available 2019-12-18 13:11:30 -08:00
Brian Cain 8c137e2bba
Update CHANGELOG 2019-12-18 08:24:22 -08:00
Brian Cain 4e58dfed2b
Merge pull request #11265 from briancain/LOCAL-ANSIBLE-BUG-PLUS-RSPEC
Fixup: ansible_local: Add `cap` bug fixes and related RSpec coverage
2019-12-18 08:20:59 -08:00
Brian Cain 61ee42976b
Merge pull request #11262 from briancain/return-if-no-disk-config
Return if no disk config
2019-12-17 13:55:08 -08:00
Brian Cain 7d667c9dea
Update ansible install tests 2019-12-17 13:34:52 -08:00
Jose Luis Duran 582f46231b
FreeBSD: Update Ansible's package name
The Ansible package in FreeBSD is now `py36-ansible`.

If `pkg` itself needs updating, passing only one 'yes' is not enough to
confirm the installation of the package.  Use the `-y` option,
specifically made for this purpose.  Also add `-q` to force a quiet
output, inline with other guests.

References:

- [`pkg-install(8)`](https://www.freebsd.org/cgi/man.cgi?query=pkg-install&sektion=8)
- freebsd/freebsd-ports@cbf5576945
2019-12-17 12:53:24 -08:00
Brian Cain 0c0352201d
Update ansible_install_test.rb
Remove extra whitespace
2019-12-17 12:51:39 -08:00
Gilles Cornu bcdda99dfa
ansible_local: Fix pip setup on Arch Linux guest
Add 'python' package requirement. Tested against `archlinux/archlinux`
box, at version "2019.11.24".
2019-12-17 12:51:39 -08:00
Gilles Cornu 069122f42c
[minor] Align Ruby formatting across ansible_local files
GH-11148: Remove unwanted formatting changes proposed in 920361150f.
2019-12-17 12:51:39 -08:00
Gilles Cornu a2b87eace4
Fix broken 'ansible_install' methods signature
- By the way: Trim the generate 'pip install' command in Ansible::Cap::Guest::Pip::pip_install
- GH-11048: Fix same regression for FreeBSD and SuSE guests.
- GH-6633:  Add RSpec examples to cover ansible_local 'cap' code.

Note: RedHat/Fedora guests are not covered yet by unit tests.
2019-12-17 12:51:39 -08:00
Gilles Cornu 113a0a7aaa
[minor] Use the correct "pip_install_cmd" name
There is no such thing like 'pip_install_command' option in the
Ansible Local provision, so let's avoid any misunderstanding ;-)
2019-12-17 12:51:39 -08:00
Stefan Koenen 04aeff4cc6
FIX #11048, add parameter `pip_install_cmd` to `ansible_install.rb` for arch guest.
ADD: Handling of `pip_install_cmd` in `ansible_install.rb` for arch guest.
2019-12-17 12:51:39 -08:00
Brian Cain 11c667a81d
Update CHANGELOG 2019-12-17 11:31:32 -08:00
Brian Cain aecd354c57
Merge pull request #11191 from samdbmg/fix-10914-ansible_local-hang
Don't prompt for input when installing Ansible
2019-12-17 11:30:48 -08:00
Brian Cain 9f2261a6fc
Add test for builtin disk action 2019-12-17 10:56:48 -08:00
Brian Cain de61b307aa
Only run disk action if disk config present 2019-12-17 10:45:33 -08:00
Jeff Bonhag 320b166c31
Update CHANGELOG 2019-12-17 12:43:53 -05:00
Jeff Bonhag d7a5f74897
Fixes #11128: Error if machine folder inaccessible (#11239)
This commit catches the Errno::EPERM raised by the operating system if
the machine folder is inaccessible and displays it as a more friendly
error message.

This can be an issue on macOS Catalina if virtual machine files are kept
in a special directory (Documents/Downloads/Desktop) that Vagrant's
embedded Ruby is not allowed to access.
2019-12-17 12:41:12 -05:00
Jeff Bonhag 4059758e00
Update CHANGELOG 2019-12-17 12:36:38 -05:00
Jeff Bonhag 2fa44f5b8f
Fixes #11218: Update apk cache when installing rsync (#11220)
This ensures that rsync can be installed on an Alpine Linux machine where the
apk cache may not be current.

Display a warning if the vagrant-alpine plugin is installed, since Alpine guest
support has been merged into Vagrant core.
2019-12-17 12:34:53 -05:00
Brian Cain 55994824a4
Update CHANGELOG 2019-12-17 08:45:17 -08:00
Jeff Bonhag df9df5c250
Wrap all environment variables headers with <code> (#11261)
This commit adds the <code> backticks to a few headers that didn't have
them.
2019-12-17 11:43:30 -05:00
Brian Cain 0b71991902
Merge pull request #11231 from briancain/add-force-option-for-box-outdated
Fixes #11228: Allow to force check for box updates
2019-12-17 08:42:51 -08:00
Brian Cain 8dae01e9c7
Update CHANGELOG 2019-12-16 08:52:10 -08:00
Brian Cain 20ccf46fb1
Merge pull request #11250 from briancain/update-virtualbox-with-6.1
Fixes #11249: Add VirtualBox provider support for version 6.1.x
2019-12-16 08:51:28 -08:00
Brian Cain 4cdf2cdd8f
Merge pull request #11251 from jjasghar/jjasghar/alpabitize
Alphabiztize the Website and template
2019-12-11 16:33:25 -08:00
JJ Asghar 9adf855f31 Alphabiztize the Website and template
Having these provisioners not alphabitized on the website and
Vagrantfile, seemed odd. This reorders them to be consistent.

Signed-off-by: JJ Asghar <jjasghar@gmail.com>
Signed-off-by: JJ Asghar <awesome@ibm.com>
2019-12-11 17:55:51 -06:00
Brian Cain fb4e6985e1
Fixes #11249: Add VirtualBox provider support for version 6.1.x
This commit adds support for VirtualBox version 6.1.x. It simply
inherits from the base 6.0.x provider class.
2019-12-11 13:25:11 -08:00
Brian Cain f306131a97
Update CHANGELOG 2019-12-05 14:33:20 -08:00
Brian Cain 1e0385443b
Merge pull request #11223 from perlun/patch-1
completion.sh: add more up options
2019-12-05 14:32:36 -08:00
Brian Cain bcf4d5a210
Fixes #11228: Allow to force check for box updates
Prior to this commit, if a user had recently checked for updates, there
was no way to force Vagrant to re-check without manually deleting a
state file in the local `.vagrant` data dir. This commit fixes that by
giving users the ability to force check for updates for a given box with
a flag to the `vagrant box outdated` command.
2019-12-03 11:42:55 -08:00
Per Lundberg 527dda241f
completion.sh: add more up options
I noted the `--provision` option which I currently needed (to retry an Ansible playbook that had failed) was missing, so I added this along with all other options I could find. They are ordered in the same order as they are listed in the `--help` output.
2019-11-28 16:05:58 +02:00
Jeff Bonhag b03f8f5aac
Update CHANGELOG 2019-11-25 15:43:23 -05:00
Jeff Bonhag c6ee1049aa
Darwin: put each NFS export on its own line (#11216)
This commit introduces a Darwin-specific template for NFS exports.  This is almost identical to the standard BSD template except it puts each NFS export on its own line.

This resolves NFS issues discovered in macOS Catalina.
2019-11-25 15:41:05 -05:00
Brian Cain 9fc155bf75
Merge pull request #11165 from briancain/feature/generic-disk-config-mgmnt
Introduce disk management base config layer to core Vagrant
2019-11-22 14:57:00 -08:00
Brian Cain f979d40436
Add warning if machines provider does not support disk configuration 2019-11-22 14:40:23 -08:00
Brian Cain f8449063b6
Have default names for primary and non-primary disks 2019-11-22 14:40:23 -08:00
Brian Cain b56dede627
Do not set primary option if it's not UNSET or false 2019-11-22 14:40:23 -08:00
Brian Cain 8ad810b5b6
Check and call into provider capability `:configure_disks` 2019-11-22 14:40:23 -08:00
Brian Cain f55aca091c
Wrap disk feature in experimental flag 2019-11-22 14:40:23 -08:00
Brian Cain 86f9243762
Move validation message to locales 2019-11-22 14:40:23 -08:00
Brian Cain 3e177d380f
Update disk docs in website for experimental feature banner 2019-11-22 14:40:23 -08:00
Brian Cain 734aad1ede
Enforce unique names for disk config objects 2019-11-22 14:40:23 -08:00
Brian Cain b5b59a4eee
Base name for disk is vagrant_primary if primary 2019-11-22 14:40:23 -08:00
Brian Cain ea7a230cb6
Move disk config validation messages to locales file 2019-11-22 14:40:23 -08:00
Brian Cain 57fd731fbf
Add warning if machines provider was not found in disk provider config
opts
2019-11-22 14:40:23 -08:00
Brian Cain 3a2b4ddef2
Validate that disk file exists in disk config validate 2019-11-22 14:40:23 -08:00
Brian Cain cd98a8bf64
Include unit test for numeric class 2019-11-22 14:40:23 -08:00
Brian Cain 2e324a4971
Add conversion method for shortcut size in disk config 2019-11-22 14:40:23 -08:00
Brian Cain 271cf8a603
Begin to add Numeric class helper for converting size strings 2019-11-22 14:40:23 -08:00
Brian Cain 8031ebe9d1
Add some todos for the disk website docs 2019-11-22 14:40:23 -08:00
Brian Cain 17f8fbe65e
Fix how double underscore options are shown in docs 2019-11-22 14:40:23 -08:00
Brian Cain 63b35ad909
Begin to add short guide for plugin authors and the disk config object 2019-11-22 14:40:23 -08:00
Brian Cain b0f4d43663
Add docs around various ways to define provider specific options for disk configs 2019-11-22 14:40:23 -08:00
Brian Cain 7feee7a87f
Add locale for primary disk validation error 2019-11-22 14:40:23 -08:00
Brian Cain f51805e910
Add list of examples to write up for disk feature 2019-11-22 14:40:23 -08:00
Brian Cain 9190f4b2e6
Fix nav sidebar view for disk page 2019-11-22 14:40:23 -08:00
Brian Cain 97db5d5da3
Add todo for disk management overview 2019-11-22 14:40:23 -08:00
Brian Cain 1a02c52852
Add beginning of disk management docs for vagrant website 2019-11-22 14:40:23 -08:00
Brian Cain 54c3e28a45
Add comment for potential hook into provider configuring disk 2019-11-22 14:40:23 -08:00
Brian Cain a457dee8b0
Set default disk to non-primary 2019-11-22 14:40:23 -08:00
Brian Cain a51e9b1fa1
Support both kinds of provider config options for disk config 2019-11-22 14:40:23 -08:00
Brian Cain 83fea21ff1
Simplify builtin disk action 2019-11-22 14:40:23 -08:00
Brian Cain e598007237
Add provider specific disk options under provider_config hash 2019-11-22 14:40:23 -08:00
Brian Cain 6c54bf6ad9
Fix logger namespace typo 2019-11-22 14:40:23 -08:00
Brian Cain d54e870752
Add file option to disk config 2019-11-22 14:40:23 -08:00
Brian Cain f01c90e676
Rename rspec test name 2019-11-22 14:40:23 -08:00
Brian Cain 71ad0f7aba
Remove duplicate setting of disks variable 2019-11-22 14:40:23 -08:00
Brian Cain 35f113e759
Put back accidental case switching for comments on provisioner 2019-11-22 14:40:23 -08:00
Brian Cain 9c1d05113f
Update merge comment for disk config 2019-11-22 14:40:23 -08:00
Brian Cain 87366cf4f3
Add basic disk config unit tests 2019-11-22 14:40:23 -08:00
Brian Cain 93828508ec
Update config/vm with tests for disk config 2019-11-22 14:40:23 -08:00
Brian Cain d6df83103e
Add todo for attaching and configuring disk for a given provider 2019-11-22 14:40:23 -08:00
Brian Cain 499e39dd10
Ensure primary is true or false 2019-11-22 14:40:23 -08:00
Brian Cain cef1bd47b3
Add initial disk builtin action 2019-11-22 14:40:23 -08:00
Brian Cain a55e3d2b91
Make config.vm.disks accessible instead of internal 2019-11-22 14:40:23 -08:00
Brian Cain 8adffc830a
Add builtin disk action 2019-11-22 14:40:23 -08:00
Brian Cain c18f36e516
Fix code comment typo 2019-11-22 14:40:23 -08:00
Brian Cain ad73969010
Fixup disk config parsing to allow hash and block 2019-11-22 14:40:23 -08:00
Brian Cain 7cfccb5cfd
Update variable docs for disk name 2019-11-22 14:40:23 -08:00
Brian Cain ee751ca6e1
Add disk name for disk config 2019-11-22 14:40:23 -08:00
Brian Cain 995c4bbc60
Add validation for disk configs 2019-11-22 14:40:23 -08:00
Brian Cain a18ce4f732
Add primary config option for disk 2019-11-22 14:40:23 -08:00
Brian Cain 393ce9eb1b
Rename drives to disks to match class, and properly merge configs 2019-11-22 14:40:23 -08:00
Brian Cain 28d339eac5
Ensure block is properly passed through to add_config 2019-11-22 14:40:23 -08:00
Brian Cain ee388d8293
Ensure config is renamed to options 2019-11-22 14:40:23 -08:00
Brian Cain 34673fe5f9
Add disk class function for provider layers 2019-11-22 14:40:23 -08:00
Brian Cain 98a2d0f723
Update internal drives state to be array instead of hash 2019-11-22 14:40:23 -08:00
Brian Cain abcc334900
Add note about disk options value 2019-11-22 14:40:23 -08:00
Brian Cain 1a21782bd5
Add note about disk name 2019-11-22 14:40:23 -08:00
Brian Cain e361900d3a
Update doc string for name attribute 2019-11-22 14:40:23 -08:00
Brian Cain aa5a3ef7f7
Add initial disk management config class 2019-11-22 14:40:23 -08:00
Chris Roberts 1d9533113c Disable master storage 2019-11-22 14:38:46 -08:00
Brian Cain e535a8a624
Update CHANGELOG 2019-11-22 14:22:44 -08:00
Brian Cain e100d9cd48
Merge pull request #11205 from briancain/DOCKER-BUILDKIT-FIXUP
Enhance docker build method for the Docker provider to include buildkit output
2019-11-22 14:21:59 -08:00
Brian Cain 2901dae948
Add option for docker executor to handle stderr from results
Instead of always joining stdout and stderr, only join the two if the
caller explicitly asks for it. Otherwise, only return stdout.
2019-11-22 12:04:09 -08:00
Brian Cain cb661886a2
Merge pull request #11213 from briancain/improve-windows-uninstall-notes
Add more details for removing user data when uninstalling Vagrant
2019-11-22 12:02:59 -08:00
Brian Cain c35861e937
Update CHANGELOG 2019-11-22 10:19:22 -08:00
Brian Cain 2656d3d9d5
Update CHANGELOG 2019-11-22 10:18:49 -08:00
Brian Cain 6831129720
Merge pull request #11211 from briancain/fixup/ensure-checksum-and-type-are-not-empty
Fixes #11207: Do not validate checksums if options are empty string
2019-11-22 10:17:10 -08:00
Brian Cain f5886e6044
Merge pull request #11212 from briancain/NFS-RHEL-FIXUP
Ensure `nfs-server` is restarted when installing nfs client for redhat guests
2019-11-22 10:15:50 -08:00
Brian Cain 601118059c
Fix typo for vagrant 2019-11-22 10:03:25 -08:00
Brian Cain 3ee7b3801f
Add more details for removing user data when uninstalling Vagrant 2019-11-21 15:24:09 -08:00
Brian Cain 2a2e2d5414
Update nfs client test for redhat 2019-11-21 13:44:35 -08:00
Brian Cain fb7a9d5582
Remove trailing whitespace 2019-11-21 13:44:28 -08:00
Tomas Krizek 3519f82b24
guest/redhat: fix nfs client installation
CentOS 8+ and Fedora 30+ no longer have the alias "nfs" for "nfs-server"
systemd service.

This shouldn't break backward compatibility, since "nfs-server" service
is available on all supported redhat systems that have systemctl binary.

Fixes #10838
2019-11-21 13:11:29 -08:00
Brian Cain efd3a62ffe
Fixes #11207: Do not validate checksums if options are empty string
Prior to this commit, if Vagrant received checksum options from Vagrant
Cloud that were simply empty strings, it would try to validate its
checksum with those options. This commit fixes that by ignoring empty
string values.
2019-11-21 09:56:58 -08:00
Brian Cain 1699821571
More specific language around docker build matching errors 2019-11-19 11:14:46 -08:00
Brian Cain 4d70856b8a
Enhance docker build matching for determining built container ID
Prior to this commit, docker would look for a container ID based on
"Successfully built" string. This output does not exist if a user has
enabled the experimental feature buildkit. This commit updates the build
behavior to match against both kinds of outputs, and instead of using
`scan`, it uses MatchData and groups the container id with match group
name `:id` instead of making hard assumptions with the matches being
contained inside arrays from scan.
2019-11-19 10:59:28 -08:00
Juha Ruotsalainen 4fc8b07974
Removed the word 'done'.
There are cases, when 'done' is prefix with a duration, like `... 0.1s done`.
2019-11-19 10:02:03 -08:00
Rumpu-Jussi f3629ebd09
Buildkit-based output processed a bit differently. 2019-11-19 10:02:03 -08:00
Juha Ruotsalainen 8041d0ae78
Build quietly and capture the image hash
At least on macOS combo Catalina + Docker engine 19.03.4 + Docker desktop 2.1.0.4 + vagrant 2.2.6 the original `matches = result.scan(/Successfully built (.+)$/i)` -line fails to generate a match. With this change I can `vagrant up --provider=docker` successfully.
2019-11-19 10:02:03 -08:00
Brian Cain 237af1b6aa
Update CHANGELOG 2019-11-19 09:14:32 -08:00
Brian Cain ff5fc2a8f2
Merge pull request #11201 from terceiro/nfs-exports-sanity
nfs: avoid adding extra newlines to /etc/exports
2019-11-19 09:13:27 -08:00
Antonio Terceiro 4fd2373753 nfs: avoid adding extra newlines to /etc/exports
StringBlockEditor already adds the necessary newlines. That extra
newline was making /etc/exports longer and longer, full of empty lines,
because StringBlockEditor doesn't know about it and does not remove it.
2019-11-17 00:33:08 -03:00
Brian Cain 51ceda7e25
Merge pull request #11198 from briancain/docs/add-quote-heredoc-example
Fixes #11196: Add more examples for ruby heredoc shell scripts
2019-11-15 14:29:53 -08:00
Jeff Bonhag a37226d63d Update CHANGELOG 2019-11-15 17:14:55 -05:00
Brian Cain a8a9f54fab
Update docs to use quotes around terms 2019-11-15 13:18:03 -08:00
Jeff Bonhag 307123c1f2
Fixes #10753: Add reboot support for Linux guests (#11194)
This commit adds support for setting `reboot: true` while using the
shell provisioner with Linux guests.
2019-11-15 14:46:36 -05:00
Brian Cain 28812fb880
Highlight here document terms instead of indent 2019-11-15 10:27:59 -08:00
Brian Cain 2adda6861e
Fixes #11196: Add more examples for ruby heredoc shell scripts
This commit adds an additional example for how to preserve quotes in a
script that uses heredocs.
2019-11-15 09:26:39 -08:00
Brian Cain ed9769586b
Merge pull request #11195 from briancain/fixup/ensure-gem-version-gets-non-nil
Fixup: Ensure Gem::Version.new does not receive nil value
2019-11-14 15:26:55 -08:00
Brian Cain 06799402ed
Fixup: Ensure Gem::Version.new does not receive nil value
This commit fixes an issue where Gem::Version.new could recieve a nil
value if no addtional box updates are available. For some versions of
ruby, this is actually an error case. This commit fixes that by
converting it to an integer to prevent an exception.

Issue reference: https://github.com/rubygems/rubygems/issues/2359
2019-11-14 14:51:29 -08:00
Jeff Bonhag c1a6910539 Update CHANGELOG 2019-11-13 17:37:24 -05:00
Jeff Bonhag 0e68f02dc9
Fixes #11163: Get latest version for provider (#11192)
This commit changes the behavior of `vagrant box outdated --global` so
it gets the latest version for the current machine's provider, rather
than the latest version for any provider.
2019-11-13 17:33:15 -05:00
Chris Roberts 85e34039b9
Merge pull request #11181 from stefansundin/rubyzip-v1.3.0
Bump rubyzip to v1.3.0 to fix CVE-2019-16892
2019-11-12 13:31:11 -08:00
Stefan Sundin 48c893ee18 Bump rubyzip version to fix CVE-2019-16892. 2019-11-12 10:48:29 -08:00
Brian Cain 2ea9323d0b
Merge pull request #11180 from briancain/fixup/docs-insert-key-config
Fixes #8058: Improve wording for config.ssh.insert_key docs
2019-11-12 09:09:08 -08:00
Brian Cain 9e7fae0c51
Update CHANGELOG 2019-11-12 09:08:27 -08:00
Brian Cain 403fece5ac
Merge pull request #11184 from briancain/fixup/cleanup-cloud-publish-cmd
Fixes #11137: Fixup how cloud publish handles its arguments
2019-11-12 09:07:42 -08:00
Brian Cain 8b21051466
Update CHANGELOG 2019-11-12 09:07:15 -08:00
Brian Cain 39ea1af5ab
Merge pull request #11183 from briancain/fixup/include-errors-in-checksum-util
Fixes #11179: Ensure Vagrant::Errors are loaded in file_checksum util
2019-11-12 09:06:49 -08:00
Brian Cain a8b99f422b
Merge pull request #10991 from dcermak/bump_rspec_its
Bump rspec-its dependency
2019-11-12 09:03:24 -08:00
Chris Roberts 063dea5699
Merge pull request #11190 from chrisroberts/e-i18n-constraints
Update i18n dependency constraints
2019-11-12 09:01:35 -08:00
Jeff Bonhag 0015a8c4c6 Update CHANGELOG 2019-11-12 11:44:15 -05:00
Jeff Bonhag a39a7ae794
Fixes #10741: Check if update is available locally (#11188)
This commit checks the local box collection to see if the latest box
update has already been downloaded.  If it has, Vagrant will display the
destroy/recreate message instead of the "run vagrant update" message.
2019-11-12 11:41:10 -05:00
Chris Roberts 687c601755 Update i18n dependency constraints
Loosen dependency constraints on the i18n library to allow
versions under 2.0.
2019-11-12 08:08:32 -08:00
Chris Roberts 2eaa6e9be1
Merge pull request #11185 from rjspiker/rj.font-smooth
website - add -moz-osx-font-smoothing for smooth firefox osx fonts
2019-11-11 17:00:43 -08:00
Brian Cain 474a2e3279
Update CHANGELOG 2019-11-11 15:35:38 -08:00
Brian Cain ce20b70073
Merge pull request #11126 from chrisroberts/f-newline-output
Update UI to properly retain newlines when adding prefix
2019-11-11 15:34:50 -08:00
Brian Cain 823c499dfb
Merge pull request #10969 from olleolleolle/patch-1
gemspec: drop rubyforge_project, it is EOL
2019-11-11 15:34:07 -08:00
Brian Cain 361736579c
Update CHANGELOG 2019-11-07 13:22:27 -08:00
Brian Cain 509812b8e6
Merge pull request #11175 from briancain/fixup/show-machine-name-in-hostname-validation
Fixes #11173: Show guest name in hostname error message
2019-11-07 13:21:42 -08:00
Brian Cain 1ec5e4c396
Merge pull request #11169 from briancain/fixup/website-getting-started-typo
Fixes #11168: Fix Ubuntu version in getting started guide
2019-11-07 13:20:52 -08:00
RJ Spiker 26b6f61682 website - add -moz-osx-font-smoothing for smooth firefox osx fonts 2019-11-07 13:10:59 -07:00
Brian Cain 145f04893c
Fixes #11137: Fixup how cloud publish handles its arguments
Prior to this commit, if a user didn't supply a box file on disk or a
box url, Vagrant would crash and display a stacktrace with an invalid
file. This commit fixes that by adding some extra handling around the
arguments supplied to the publish command.
2019-11-07 10:19:52 -08:00
Brian Cain 44c6f655be
Fixes #11179: Ensure Vagrant::Errors are loaded in file_checksum util
Prior to this commit, the file_checksum class used the `Vagrant::Errors`
class as if it were apart of the Vagrant module. However, since the
file_checksum class is an interface and not part of the Vagrant module,
it doesn't have access to that Error class like other Vagrant modules.
This commit fixes that by ensuring the `"vagrant/errors"` class is
loaded, and that the proper namespace is used.
2019-11-07 09:22:17 -08:00
Brian Cain 72496d5f5d
Fixes #8058: Improve wording for config.ssh.insert_key docs 2019-11-06 16:55:04 -08:00
Jeff Bonhag 7560c7fdef Update CHANGELOG 2019-11-06 16:22:17 -05:00
Jeff Bonhag 8a69c1205c
Fixes #10170: Check for modinfo in /sbin (#11178)
Check for modinfo in /sbin if it doesn't appear on the PATH.

If it's not found on the PATH or in /sbin, the command will default back to modinfo so the user sees the error message about adding it to their PATH.
2019-11-06 16:10:24 -05:00
Chris Roberts 89e0522659
Merge pull request #11167 from rjspiker/rj.fonts
website - font and brand updates
2019-11-06 09:56:32 -08:00
Brian Cain e2adefe4c7
Update CHANGELOG 2019-11-05 09:31:17 -08:00
Brian Cain d4f83ca4a3
Merge pull request #11170 from moench-tegeder/suse_hostname_vs_getent
explicitly test the hostname we'll be setting
2019-11-05 09:30:28 -08:00
RJ Spiker 3d48faa1b4 feedback updates and some style cleanup 2019-11-04 13:59:59 -07:00
Brian Cain 0aaa2cc147
Fixes #11173: Show guest name in hostname erorr message
This commit adds the machine guest name in the hostname validation error
message so that it's easier to see which guest in a Vagrantfile has the
validation error.
2019-11-04 08:41:51 -08:00
Brian Cain f30b136c57
Merge pull request #11151 from dcermak/fix_exception_in_docker_test
Catch NetworkNoInterfaces error in docker prepare_networks_test
2019-11-01 10:58:52 -07:00
Sam Mesterton-Gibbons e4ab40393e Don't prompt for input when installing Ansible
Sets `DEBIAN_FRONTEND=noninteractive` and tells `dpkg` to take the old
version of config files when installing Ansible, to prevent hangs
waiting for user input.

Fixes #10914
2019-11-01 17:17:03 +00:00
Dan Čermák fe4743a22b
Mock call to PrepareNetworks.list_interfaces in docker prepare_networks_test
The test "generates a network name and configuration" calls at the end
`process_public_network()`, which can return an empty list if the currently
executing machine has no usable network interfaces (this is typically the case
for workers that build rpm packages in OBS or Koji). This results in an
exception of type Errors::NetworkNoInterfaces to be thrown and causing this test
to fail.

This commit adds a mock of the PrepareNetworks.list_interfaces call that returns
a single entry with just the required defaults.
2019-11-01 17:36:31 +01:00
Brian Cain d27d7d5a2a
Update CHANGELOG 2019-11-01 08:14:23 -07:00
Brian Cain 4b1297b5d3
Merge pull request #11152 from briancain/fixup/command-snapshot-save-all-vms
Fixes #11139: Skip machines that haven't been created for snapshot save
2019-11-01 08:13:31 -07:00
Brian Cain 811231bf92
Fixes #11168: Fix Ubuntu version in getting started guide 2019-11-01 07:46:47 -07:00
Christoph Moench-Tegeder 6f6e58f4ae explicitly test the hostname we'll be setting
getent queries the system resolver for the hostname - but it's not
the resolver we're interested in. In fact, the hostname-to-be-set
may already exist in DNS (becuase DNS really is a nifty thing and
can do a lot of things which are not that possible with /etc/hosts
alone), in which case getent will "not fail" and vagrant will believe
the hostname had already been set.
Instead, query hostnamectl for the "static" hostname - that's the
one we will be setting, so we're ok IFF hostnamectl returns exactly
what we would be setting.
2019-11-01 15:41:04 +01:00
Brian Cain d70e3eb828
Merge pull request #11164 from slavrd/u/docs-intro-prov
update getting started guide - provision
2019-10-31 10:33:50 -07:00
Slav Donchev 42482849ec add example html for the user to create 2019-10-31 09:14:32 +02:00
RJ Spiker 0f7b250e81 website - font and brand updates 2019-10-30 16:26:38 -06:00
Slav Donchev 8130314741 example provision script copies default web site 2019-10-28 13:25:45 +02:00
Brian Cain 4735699bc8
Merge pull request #11155 from briancain/fixup/mockup-nfsd-call-bsd-nfs
Ensure nfsd call is mocked up in BSD NFS test
2019-10-25 09:22:51 -07:00
Brian Cain ce033454ca
Ensure nfsd call is mocked up in BSD NFS test 2019-10-25 09:02:30 -07:00
Brian Cain f998e535ce
Fixes #11139: Skip machines that haven't been created for snapshot save
This commit fixes the original #11027 fix, which assumed that the
hyper-v provider just wasn't properly getting a VM id when it listed
snapshots. In reality, it was just that if you invoke the
`with_target_vm` method with no arguments, it runs on the entire environment.
This meant that the capability snapshot_list attempted to be invoked on
machines that didn't exist yet, which is the original cause for why the
list_snapshot method did not recieve a vm ID. This commit fixes that by
simply skipping the machine if it does not yet exist.
2019-10-24 13:33:25 -07:00
Brian Cain f6503462f6
Merge pull request #11141 from Jonfor/patch-1
Update CHANGELOG.md
2019-10-21 08:50:28 -07:00
Jonathan Forscher 8def8a794f
Update CHANGELOG.md
Fix speling error in release notes.
2019-10-21 11:38:33 -04:00
Chris Roberts 318dca294a Ensure empty message values are properly formatted 2019-10-15 08:54:24 -07:00
Chris Roberts 783f5fc65d Update UI to properly retain newlines when adding prefix
When using a Prefixed UI instance prevent new line characters from
being removed when adding prefix formatting to output messages.

Fixes #11044
2019-10-14 16:56:40 -07:00
Chris Roberts d2914a85ee Update website download version 2.2.6 2019-10-14 12:35:50 -07:00
Chris Roberts 5aeda42902 Update version and changelog for new development 2019-10-14 09:40:05 -07:00
Chris Roberts f58b97b0fe Release v2.2.6 2019-10-14 09:38:13 -07:00
Brian Cain 9fa3301a0c
Merge pull request #11117 from sk1u/add-ansible-limit-note
docs: Add clarification about ansible.limit in static inventory usecase
2019-10-11 10:12:36 -07:00
Michael C 670cadae9f docs: Add clarification about ansible.limit in static inventory usecase 2019-10-11 08:57:20 +02:00
Brian Cain 0f9a5bacb3
Update CHANGELOG 2019-10-10 13:18:17 -07:00
Brian Cain 33a53d0c4e
Merge pull request #11116 from briancain/DOCKER-LIST-INTERFACES
Only return interfaces where addr is not nil
2019-10-10 13:17:41 -07:00
Brian Cain 7c93151f67
Add test for listing interfaces with docker networks 2019-10-10 11:38:57 -07:00
Dan Čermák 435a32684f
Only return interfaces where addr is not nil
tunnel interfaces on Linux have addr set to nil which makes the function
list_interfaces fail with a backtrace.
2019-10-10 10:49:03 -07:00
Chris Roberts 67270a2d64
Merge pull request #11084 from chrisroberts/doc-update
Update docs page for Vagrant Cloud catalog
2019-10-10 10:02:23 -07:00
Chris Roberts 81b23f3180 Update CHANGELOG 2019-10-10 09:22:20 -07:00
Chris Roberts b12a23273e
Merge pull request #11108 from chrisroberts/macos-catalina
Fix NFS sharing in macOS 10.15 (based on #11105)
2019-10-10 09:20:33 -07:00
Brian Cain a069b48952
Update CHANGELOG 2019-10-09 16:27:06 -07:00
Brian Cain 2147c6544f
Merge pull request #11111 from briancain/bug/docker_network_subnet_prefix
Fixes #11094: Determine prefix for docker public networks
2019-10-09 16:26:22 -07:00
Brian Cain e6d47329ee
Add note about removing prefix workaround 2019-10-09 16:07:21 -07:00
Brian Cain 8458a21657
Determine prefix with netmask 2019-10-09 15:40:36 -07:00
Brian Cain 62b7e35169
Fixes #11094: Determine prefix for docker public networks
Prior to this commit, the docker action was using the method `prefix` on
an IPv4 and IPv6 address. This works fine for ruby versions 2.5 and
newer, however the ruby shipped with Vagrant is before 2.5, and
therefore the IPv4 and IPv6 classes do not have the prefix method,
resulting in an error. This commit fixes that by using a different
method of determining the prefix.
2019-10-09 09:56:59 -07:00
Chris Roberts da15c1d171 Add test coverage on host plugin updates for nfs and resove_host_path capabilities 2019-10-08 16:42:36 -07:00
Chris Roberts 8f42dbff21 Add a resolve_host_path capability for bsd and darwin hosts
For bsd the resolve_host_path capability is a no-op. For darwin
hosts, if firmlinks are defined on the system, paths will be properly
resolved to real path.
2019-10-08 16:41:48 -07:00
Chris Roberts 2c16c96e57 Update nfs_export cap to use resolve_host_path cap for shared directories
Using the resolve_host_path capability allows hosts to modify the
shared folder directory while keeping the logic contained within
the specific host implementation.
2019-10-08 16:38:52 -07:00
Brian Cain d22cfcb86c
Update CHANGELOG 2019-10-08 13:42:01 -07:00
Brian Cain 00e0dc9279
Merge pull request #11076 from dcermak/suse_nfs_support
Update nfs & service daemon names for suse based hosts
2019-10-08 13:41:22 -07:00
Andy Fowler e288a5b732 `df` -> `/bin/df` to use macOS version
Thanks, @AntonioMeireles!
2019-10-08 13:21:34 -07:00
Andy Fowler ae9c3e28d6 Fix #10961 NFS sharing in macOS 10.15 host
On OS X 10.15, / is read-only and paths inside of /Users (and elsewhere)
are mounted via a "firmlink" (which is a new invention in APFS). These
must be resolved to their full path to be shareable via NFS.

/Users/johnsmith/mycode  =>  /System/Volumes/Data/Users/johnsmith/mycode

We check to see if a path is mounted here with `df`, and prepend it.

Firmlinks are only createable by the OS and this wasn't supposed to be
visible to applications anyway:
https://developer.apple.com/videos/play/wwdc2019/710/?time=481
2019-10-08 13:21:34 -07:00
Chris Roberts 72043a8a79 Update CHANGELOG 2019-10-08 13:20:05 -07:00
Chris Roberts 0d2751686b
Merge pull request #11101 from chrisroberts/e-checksums
Extend checksum support for box validation and remote files
2019-10-08 13:16:33 -07:00
Chris Roberts 3d026e84f2 Update constraint on vagrant_cloud for checksum support 2019-10-08 11:23:48 -07:00
Chris Roberts 04a1bb58f3 Add coverage on new behavior of FileChecksum 2019-10-08 11:23:48 -07:00
Chris Roberts 0bce1e6307 Update tests for checksum and filechecksum 2019-10-08 11:23:48 -07:00
Chris Roberts cc23905142 Add support for providing box checksums to Vagrant Cloud 2019-10-08 11:23:48 -07:00
Chris Roberts 13654dcc37 Update box checksum logic to use that supplied from FileChecksum 2019-10-08 11:23:48 -07:00
Chris Roberts 9ee5ce4817 Remove checksum from downloader and replace with FileChecksum
Remove checksum implementation within the Util::Downloader and
relocate it into the FileChecksum helper class. Update Downloader
to use FileChecksum.
2019-10-08 11:23:48 -07:00
Chris Roberts 7fb81bcea1 Add support for other checksum types 2019-10-08 11:23:48 -07:00
Brian Cain eec20f9007
Update CHANGELOG 2019-10-08 09:27:20 -07:00
Brian Cain ea550289a9
Merge pull request #11100 from chkpnt/suse-hostname
Use hostnamectl instead of hostname to set the hostname under SUSE
2019-10-08 09:26:46 -07:00
Brian Cain 292496b9e0
Update CHANGELOG 2019-10-07 14:31:56 -07:00
Brian Cain 7616c99c79
Merge pull request #11106 from briancain/bug/docker_compose_build_args
Ensure build_args are passed into docker compose config file
2019-10-07 14:30:30 -07:00
Brian Cain f9a75514d2
Update CHANGELOG 2019-10-07 14:29:05 -07:00
Brian Cain d6f556c83d
Merge pull request #11099 from briancain/file-provisioner-source-path
Ensure relative path for file provisioner is relative to machines cwd
2019-10-07 14:28:13 -07:00
Chris Roberts af405b03c9
Merge pull request #11103 from chrisroberts/e-ruby-eol
Update Ruby version constraints
2019-10-07 13:53:51 -07:00
Brian Cain f1ea4eaac0
Ensure build_args are passed into docker compose config file
Prior to this commit, the docker compose build method would not properly
set build_args if given in a Vagrantfile. This commit fixes that by
using the passed in key `extra_args` from the docker build action.
2019-10-07 12:48:59 -07:00
Brian Cain ec963966cd
Update CHANGELOG 2019-10-07 09:05:31 -07:00
Brian Cain 96e275451c
Merge pull request #10938 from andersk/virtualbox-usable
virtualbox: Fix usability test to reject bad installs without crashing
2019-10-07 09:04:24 -07:00
Chris Roberts 5916b111a1 Update minimum Ruby version and remove EOL'd Rubies from test config 2019-10-05 10:24:20 -07:00
Chris Roberts fafde5efdc Remove travis configuration (replaced with circle) 2019-10-05 10:19:16 -07:00
Anders Kaseorg 4afd370d6a virtualbox: Fix usability test to reject bad installs without crashing
If VirtualBox is installed but the kernel module is missing or the
service is stopped, the usability test should fail without crashing so
we can fall back to other providers.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-10-04 15:56:10 -07:00
Brian Cain c35758046d
Update CHANGELOG 2019-10-04 13:10:21 -07:00
Brian Cain 656b61175d
Merge pull request #11093 from rgl/fix-windows-shell-reboot-connect-timeout
retry the wait for a windows reboot on connect timeout errors
2019-10-04 13:09:18 -07:00
Gregor Dschung 8442b6b59f Use hostnamectl instead of hostname to set the hostname under SUSE 2019-10-03 14:46:14 +02:00
Brian Cain 0a6c4e2d0f
Ensure relative path for file provisioner is relative to machines cwd
Prior to this commit, if you ran Vagrant in a different current working
directory other than where a current guest machines location is, the
file provisioner would not take into account the machines local dir, and
would instead use the path where Vagrant was invoked to expand the
`source` path option for a file provisioner. This commit fixes that by
passing the root path `machine.env.cwd` when expanding the source dir.
2019-10-02 15:33:23 -07:00
Brian Cain 07a5190676
Merge pull request #10548 from mykaul/patch-1
ansible_ssh_host in the example is deprecated
2019-10-02 14:54:17 -07:00
Brian Cain 620500c1b0
Update CHANGELOG 2019-10-02 12:52:20 -07:00
Brian Cain 968a126405
Merge pull request #11098 from briancain/finalize-ansible-config-values
Fixes #10950: Ensure pip_install_cmd is finalized
2019-10-02 12:51:33 -07:00
Brian Cain 03ad01f158
Update CHANGELOG 2019-10-02 12:50:43 -07:00
Brian Cain 23352d406c
Merge pull request #11097 from briancain/hyperv-command-snapshot-save-fix
Fixes #11027: Ensure VM id is passed to list snapshots
2019-10-02 12:49:38 -07:00
Brian Cain c49a58f0d3
Update CHANGELOG 2019-10-02 12:48:20 -07:00
Brian Cain f92e1a1973
Merge pull request #11089 from briancain/rsync-helper-regex-path-fix
Fixes #10966: Ensure all subdirectory files are watched
2019-10-02 12:47:04 -07:00
Brian Cain 64cb304153
Merge pull request #11090 from briancain/add-note-about-run-bash-scripts
Docs: Add note about running bash with the `run` option for triggers
2019-10-02 12:46:46 -07:00
Brian Cain 96c20ad3cc
Fixes #10950: Ensure pip_install_cmd is finalized
Prior to this commit, the `pip_install_cmd` option for ansible guest
config was not properly finalized. This commit ensures that if that
value is still UNSET_VALUE, it gets set to empty string in the finalize!
method.
2019-10-02 10:33:31 -07:00
Brian Cain 66ec57a637
Fixes #11027: Ensure VM id is passed to list snapshots
Prior to this commit, if you tried to save a snapshot without giving it
a name, the hyper-v driver would not properly obtain a vm id to save a
snapshot on, resulting in an error. This commit updates the command
snapshot save to hold onto the machines ID in argv rather than `pop` it
off, so that the hyperv driver can obtain the guests id when saving a
snapshot.
2019-10-01 13:33:39 -07:00
Brian Cain 1b98f0681c
Update CHANGELOG 2019-10-01 11:13:23 -07:00
Brian Cain 8f856949f2
Merge pull request #10978 from mrshanahan/fix-issue-10973
Fixes issue hashicorp#10973: checks that VMMS WMI reference is null & throws appropriately
2019-10-01 11:12:41 -07:00
Rui Lopes ba71c30e04 retry the wait for a windows reboot on connect timeout errors 2019-09-28 12:20:10 +01:00
Brian Cain 5c26e651e6
Move around example mention in docs 2019-09-26 13:15:16 -07:00
Brian Cain f69bdc4bb6
Docs: Add note about running bash with the `run` option for triggers 2019-09-26 12:54:53 -07:00
Brian Cain 1c620852b6
Fixes #10966: Ensure all subdirectory files are watched
Prior to this commit, due to a fix that ignored `.vagrant` with rsync
helper, it broke the ability to watch for changes in subdirectories when
running the rsync-auto command. This commit puts back some of the helper
methods that were there previously for a given watcher path to ensure
that all files and subdirectories are properly watched and synced.
2019-09-26 08:29:37 -07:00
Brian Cain b3462d805b
Update CHANGELOG 2019-09-24 13:59:17 -07:00
Brian Cain 71bf5de44c
Merge pull request #11075 from jlduran/freebsd-remove-apt-ism
FreeBSD: Remove APT-ism
2019-09-24 13:56:11 -07:00
Brian Cain 0d0db48552
Update CHANGELOG 2019-09-24 09:42:20 -07:00
Brian Cain c9998f4a27
Merge pull request #11012 from aielo/fix-dev-vagrantfile
[#10484] Fixed Vagrantfile for Vagrant development
2019-09-24 09:41:44 -07:00
Chris Roberts 916ea9dd75 Documentation updates to Vagrant Cloud catalog docs page
These updates are based on the comments made by @ladar within #11034
2019-09-24 08:39:42 -07:00
Brian Cain 1d6a248a0f
Merge pull request #11060 from karstengresch/patch-1
Typo.
2019-09-24 08:19:25 -07:00
Ladar Levison 0712c18d68 Fixed grammar mistake. Added periods. 2019-09-23 16:08:49 -07:00
Chris Roberts 058577ec46
Merge pull request #11032 from nfagerlund/aug19_nokogiri_update
Update middleman-hashicorp container and Gemfile.lock
2019-09-23 16:01:00 -07:00
Ricardo Aielo 365111f3bb Box switched to hashicorp/bionic64 and supported providers adjusted 2019-09-22 13:07:46 -03:00
Dan Čermák a3588c28a8
Update nfs & service daemon names for suse based hosts
- nfs.service got recently removed in openSUSE Tumbleweed and calling service
  restart nfs errors out on Tumbleweed. nfs.service has been an alias to
  nfs-client.target for a very long time and can thus be safely substituted.
- all actively supported versions of openSUSE & SLE are using systemd now
  => no reason not to use systemctl
2019-09-18 23:28:18 +02:00
Jose Luis Duran 6c4b537c82 FreeBSD: Remove APT-ism
No functional change intended.
2019-09-17 03:58:37 -03:00
Brian Cain 9eac6ae62d
Update CHANGELOG 2019-09-12 08:47:42 -07:00
Brian Cain 8b4ff9c40f
Merge pull request #11056 from briancain/fixup-windows-config-loading-error
Ensure proper paths are shown in config loading exceptions
2019-09-12 08:47:12 -07:00
Brian Cain 2581efa778
Update CHANGELOG 2019-09-12 08:41:20 -07:00
Brian Cain bab66df318
Merge pull request #11068 from briancain/DOCKER-USABLE
Fix Docker providers usable? check
2019-09-12 08:40:44 -07:00
Brian Cain c7b1f8821d
Try to mock up docker version subprocess result in test 2019-09-11 09:36:11 -07:00
Brian Cain d4002aa74d
Add vagrantfile mock to iso_env machine 2019-09-11 09:17:14 -07:00
Brian Cain e820b5df8e
Add vagrantfile double for environment class 2019-09-11 09:01:35 -07:00
Brian Cain f14cf09af6
Add allow for docker driver execute method 2019-09-11 08:37:07 -07:00
Brian Cain 21db2db9ac
Add machine config to machine double for rspec tests
This commit mocks up the docker machines test config so that it doesn't
actually invoke the docker driver in circle-ci
2019-09-11 08:09:26 -07:00
Brian Cain ebe1f3f1c9
Remove virtualbox context from docker tests 2019-09-11 07:46:40 -07:00
Anders Kaseorg 5b4dcf9443
providers/docker: Fix usability check
In commit 7980178d19 (#10879) I added a
`usable?` class method to `VagrantPlugins::DockerProvider::Provider`.
However, commit 34e53a5a4b (#10890)
incorrectly changed it to an instance method.  This rendered it
ineffective because it’s called on the class, not an instance.  Change
it back to a class method.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-09-10 15:10:43 -07:00
Brian Cain ace67ccdeb
Remove platform require since it is no longer required in file 2019-09-10 13:28:37 -07:00
Brian Cain a22acba467
Simplify line and path checks for exception handling in config loading 2019-09-10 13:27:23 -07:00
Karsten Gresch fc600f1e9e
Typo. 2019-09-08 22:26:41 +02:00
Brian Cain 09a37e0767
Fixes #11022: Ensure correct line is used for windows exceptions
Prior to this commit, if there was a config error inside a provider
block, Vagrant wouldn't grab the right backtrace token on windows since
the api is different for ruby on Windows compared to all other
platforms. This commit ensures that the proper line number is chosen so
the error message is correct.
2019-09-06 14:00:46 -07:00
Brian Cain ccf99d8c0c
Fixes #11022: Show proper path & letter drive on exceptions for windows
Prior to this commit, vagrant was not grabbing all of the tokens on
Windows for showing the full drive because the ruby api for it behaves
differenly on windows compared to other platforms. This commit changes
that by ensuring the letter drive is attached to the path when showing
an exception.
2019-09-06 13:37:38 -07:00
Brian Cain b28e6d95a6
Update CHANGELOG 2019-09-06 11:09:19 -07:00
Brian Cain 8abc0cc90c
Merge pull request #11013 from dcermak/suse_ipv6_support
Add ipv6 network config templates for SUSE based distributions
2019-09-06 11:08:37 -07:00
Brian Cain 2c88a6595c
Update CHANGELOG 2019-09-06 08:53:24 -07:00
Brian Cain f74239bed9
Merge pull request #11043 from briancain/provisioner-enhancements
Introduce new Provisioner options: before and after
2019-09-06 08:52:40 -07:00
Brian Cain 17e5240547
Update CHANGELOG 2019-09-06 08:50:34 -07:00
Brian Cain f9b60ba603
Merge pull request #11052 from briancain/add-skip-used-boxes-with-force-prune
Fixes #10908: Preserve in-use boxes when force flag is used with prune
2019-09-06 08:49:40 -07:00
Brian Cain bc3d80d637
Update CHANGELOG 2019-09-06 08:48:22 -07:00
Brian Cain 2f6d8b5934
Merge pull request #11053 from briancain/docker-passwd-auth-provider-host-vm
Fixes #11051: Only use host vm if specified
2019-09-06 08:47:34 -07:00
Brian Cain 5210e9d82b
Update flag from used to active 2019-09-05 15:46:43 -07:00
Brian Cain 99b5867559
Update reject to compact 2019-09-05 15:39:24 -07:00
Brian Cain 09af983caa
Fixes #11051: Only use host vm if specified
Prior to this commit, the docker login action assumed that if there was
a password to authenticate with, Vagrant was using a host vm to run
docker. This is likely due to some legacy decisions with how Vagrant
used to manage running docker. This commit fixes that by only grabbing a
host_vm lock if the host_vm is actually in use, otherwise login
normally.
2019-09-05 14:54:40 -07:00
Brian Cain e19f54457d
Fixes #10908: Preserve in-use boxes when force flag is used with prune
Prior to this commit, `vagrant box prune --force` would not prompt a
user to prune Vagrant boxes, even if that box was in use. There was no
way to prune boxes, ignore the prompt, but keep in-use boxes. This
commit adds a new flag that can be combined with `--force`, that will
keep in-use boxes but prune older boxes without prompting the user.
2019-09-04 15:54:11 -07:00
Brian Cain 7b0dc8d528
Update provisioner enhancements from pull request feedback 2019-08-29 13:50:22 -07:00
Brian Cain 84bf9aefe9
Merge pull request #11036 from briancain/vagrantcloud/note-about-public-boxes
Add note about public boxes and release status for Vagrant Cloud
2019-08-29 09:25:45 -07:00
Brian Cain 4c35adafbe
Merge pull request #11029 from briancain/update-hashicorp-box
Update docs with newly supported hashicorp/bionic64 box
2019-08-29 09:25:32 -07:00
Brian Cain 07bcfc6077
Add error if both before and after options are set 2019-08-28 16:15:33 -07:00
Brian Cain 258ce7733c
Remove todo note from docs 2019-08-28 16:09:02 -07:00
Brian Cain fc8bf6aed4
Ensure a dependency provisioner isnt configured to rely on another dependency provisioner 2019-08-28 15:52:38 -07:00
Brian Cain f608c324e5
Update dependency provisioner docs 2019-08-28 15:09:48 -07:00
Brian Cain c192651e90
Make dependency provisioners experimental 2019-08-28 15:09:38 -07:00
Brian Cain 963319d938
Flip around action to be after dependency provisioner name 2019-08-28 14:39:42 -07:00
Brian Cain 160ee09da2
Cleanup sorting method for provisioner sorting 2019-08-28 14:32:51 -07:00
Brian Cain 8c39d9bfed
Add dependency provisioner name to error message 2019-08-28 14:30:32 -07:00
Brian Cain c1f0bd638d
Insert _at_ index, rather than before
Inserting at the right index places new item *before* the index, so no
need to decrement and then insert, since `insert` takes care of shifting
down elements of the array.
2019-08-28 14:11:25 -07:00
Brian Cain 5400af7a4a
Add note about dependency provisioner dependencies 2019-08-27 15:37:39 -07:00
Brian Cain 2677a721fb
Update provisioner basic usage with dependency provisioners 2019-08-27 15:11:14 -07:00
Brian Cain e56d2581ee
Add before/after all tests 2019-08-27 14:36:36 -07:00
Brian Cain 271d427c57
Fix bug in :each provisioner sorting
Ensure each provisioners are properly inserted into the final
provisioner array
2019-08-27 14:28:06 -07:00
Brian Cain f27cf9c84e
Update CHANGELOG 2019-08-27 14:04:47 -07:00
Brian Cain 75f1fde1e5
Merge pull request #11000 from ladar/master
Fix the hostname config logic for Alpine.
2019-08-27 14:03:31 -07:00
Ladar Levison 5fb9edd67b Functional/working unit tests for the alt linux guest plugin change hostname capability. 2019-08-27 23:00:36 +05:30
Ladar Levison 243ae0f368 Added service command to alt guest test. 2019-08-27 21:07:58 +05:30
Ladar Levison 7e4c4cd71a Merge remote-tracking branch 'upstream/master' 2019-08-27 20:32:31 +05:30
Ladar Levison 0671843ec0 Initial alt guest unit test attempt. 2019-08-27 20:31:12 +05:30
Brian Cain c189e4d255
Redo how each provisioners are sorted 2019-08-26 16:05:02 -07:00
Brian Cain 28ef368881
Begin to add tests for mixin provisioner 2019-08-26 12:03:36 -07:00
Brian Cain ebaacd524c
Add note about public boxes and release status for Vagrant Cloud 2019-08-23 08:34:10 -07:00
Brian Cain ef82c0a5bc
Move return earlier 2019-08-22 12:01:19 -07:00
Nick Fagerlund ba3aa81841 Update middleman-hashicorp container and Gemfile.lock
Time marches on, and so do security vulnerabilities in Nokogiri. So it's time
for a new container.

As with last time, here's a reminder for the next person who needs to update
this:

- You shouldn't just update the dependency in Gemfile.lock, because your build
  times will go to heck as you compile Nokogiri from source on every run. So you
  need an updated container with all the dependencies.
- To update the container, you need to push a new tag to the middleman-hashicorp
  repo. Teamcity does the rest, and will ship a new container to Docker Hub
  (unless its credentials are out of date, in which case go ask team-eng-serv.)
- Once that's pushed:
    - Update Makefile
    - Update the Gemfile
    - Delete Gemfile.lock
    - `make website` until it comes up, then ctrl-C
    - Commit the changes
2019-08-21 16:08:55 -07:00
Brian Cain be5964a1db
Add basic provisioner sorting 2019-08-21 14:44:16 -07:00
Brian Cain 6777493c46
Include before/after options in final provision hash 2019-08-20 11:31:00 -07:00
Brian Cain 6db03f2aed
Check if rejected entries are nil, not blank 2019-08-20 11:30:42 -07:00
Brian Cain d15bac7fb7
Validate that before/after provisioner exists in machines config 2019-08-19 14:48:06 -07:00
Brian Cain 8ecd32de53
Remove comment 2019-08-19 11:36:54 -07:00
Brian Cain 4933610398
Update rubydoc for before/after return types 2019-08-19 11:33:30 -07:00
Brian Cain 66aac23470
Properly set and validate before/after keys for base provisioner class 2019-08-19 11:23:06 -07:00
Brian Cain 725a13a292
Add note about Bento project with new box 2019-08-16 09:25:15 -07:00
Brian Cain 98f598632e
Update docs with newly supported hashicorp/bionic64 box 2019-08-14 10:48:33 -07:00
Dan Čermák eb9b478951
Add ipv6 network config templates for SUSE based distributions 2019-08-09 17:23:46 +02:00
Ricardo Aielo ae3ae5078f Memory set to 2GB to run tests with no Errno::ENOMEM 2019-08-08 19:11:52 -07:00
Ricardo Aielo 990bc107fa grep error suppressed in case .bash_profile does not exist 2019-08-08 15:55:46 -07:00
Ricardo Aielo 546cd90cea Removed explicit bundler install since there is no dependency in gemspec 2019-08-08 15:53:03 -07:00
Ricardo Aielo 068e348826 Next-to-last ruby to avoid unsupported version from gemspec 2019-08-08 15:42:45 -07:00
Ricardo Aielo 7167c9a2fe RVM installed with apt-get (ubuntu_rvm) 2019-08-08 15:31:14 -07:00
Ricardo Aielo 5dfbd20aa3 Box updated to ubuntu/bionic64 (18.04) 2019-08-08 15:25:34 -07:00
Brian Cain 28c0f6085c
Attempt to validate top scope provisioner options 2019-08-06 16:18:58 -07:00
Brian Cain e05437ddf2
Add validation method and todo 2019-08-06 15:28:04 -07:00
Brian Cain b82b33d204
Add new before/after options for the base Provisioner class
This commit adds two new options: before, after. These string options
refer to other named Provisioners.
2019-08-06 15:28:04 -07:00
Brian Cain 49ae77b2b8
Update doc string for :run option 2019-08-06 15:28:04 -07:00
Brian Cain 1dda6cc14c
Merge pull request #10998 from llsousa/master
Review ansible_local.html.md
2019-08-06 08:30:24 -07:00
Brian Cain d1f415a447
Merge pull request #11001 from phillxnet/patch-1
minor word change re box availability explanation
2019-08-05 08:26:13 -07:00
Philip Guyton 2973750018
minor word change re box availability explanation
Proposed minor re wording on website boxes catalog page.
2019-08-05 13:01:53 +01:00
Dan Čermák f056231deb
Bump rspec-its dependency 2019-08-05 11:25:20 +02:00
Ladar Levison 690963669c Added fall through logic with error messages if OS is unrecognized.
This will print an error message but still exit with 0 if an
ephemeral hostname change was made, which seems more defenisve,
and user friendly to me.
2019-08-03 20:59:41 +05:30
Ladar Levison 53323ba54e Fix the hostname config logic for Alpine.
And allow those who like `vagrant` to go
Alpine skiing!
2019-08-03 15:19:51 +05:30
Luís Sousa d93342cbbb
Merge pull request #1 from llsousa/llsousa-patch-1
Review ansible_local.html.md
2019-08-02 16:20:25 +01:00
Luís Sousa af5c752fb2
Review ansible_local.html.md 2019-08-02 16:18:20 +01:00
Brian Cain 89cf1e70c5
Update CHANGELOG 2019-07-30 09:18:44 -07:00
Brian Cain 3bde70fec1
Merge pull request #10975 from timschumi/patch/alpine-guest-plugin
Integrate the vagrant-alpine guest plugin
2019-07-30 09:17:42 -07:00
Tim Schumacher 39fb585295 alpine: Remove unneeded aliases in change_host_name 2019-07-26 08:32:36 +02:00
Tim Schumacher a7f09f010c alpine: Convert nfs_client capability to seperate commands
The workaround for the broken repository should be safe to be removed,
since the last affected Alpine version (<=3.3) EOL'd in November of 2017.

The remaining important commands can be split out into seperate calls
of sudo(), which removes the need for manual exit-code checking
(since it aborts by itself when a command fails) and makes the code
easier to handle in general.
2019-07-26 08:31:12 +02:00
Matt Shanahan 6caa7bfa86 Fixes issue hashicorp#10973: checks that VMMS WMI reference is null & throws appropriately 2019-07-19 07:48:03 +02:00
Tim Schumacher 77616b22b3 alpine: Use absolute paths for network configuration templates 2019-07-18 04:07:15 +02:00
Tim Schumacher 29362d8af4 alpine: Wire up tests 2019-07-18 03:36:50 +02:00
Tim Schumacher 3b03944331 alpine: Replace capability strings with symbols
Those were introduced upstream in b29864f450.
2019-07-18 03:35:48 +02:00
Tim Schumacher 2216d23048 alpine: Remove version and out-of-tree checks 2019-07-18 03:35:48 +02:00
Tim Schumacher fbffb41fc4 guests: Add unmodified alpine support plugin from maier
This has been available as `vagrant-alpine` in the plugin
repository so far.
2019-07-18 03:35:40 +02:00
Olle Jonsson 55b364f87b
gemspec: drop rubyforge_project, it is EOL 2019-07-14 14:09:54 +02:00
Brian Cain cca36d91ed
Merge pull request #10954 from morkot/fix-docs-formatting-ansible_local
website/docs: fix code formatting
2019-07-10 16:13:34 -07:00
morkot 2fd803cdc2 website/docs: fix code formatting
This change will fix formatting of the code blocks on page https://www.vagrantup.com/docs/provisioning/ansible_local.html
2019-07-08 18:22:50 +01:00
Chris Roberts 4ce8d84f7e
Merge pull request #10932 from Jonfor/patch-1
Fix the date of 2.2.5 release in changelog
2019-06-26 12:25:41 -07:00
Jonathan Forscher 75bc6a93ef
Fix the date of 2.2.5 release 2019-06-26 15:18:01 -04:00
Chris Roberts b200bfb398 Update version and changelog for new development 2019-06-26 06:43:30 -07:00
Chris Roberts b68ea5bd23 Update website download version to 2.2.5 2019-06-26 06:42:04 -07:00
Chris Roberts ae0d574e8a Release v2.2.5 2019-06-25 14:28:53 -07:00
Chris Roberts 8e59d9e159 Update the steps in the release document 2019-06-25 14:26:37 -07:00
Brian Cain 55019bc846
Merge pull request #10929 from briancain/add-suse-sudoers-website-docs
Fixes #10928: Include SUSE for sudoers entry with NFS
2019-06-25 11:00:43 -07:00
Brian Cain b16794c8ca
Fixes #10928: Include SUSE for sudoers entry with NFS
This commit includes the SUSE entry for passwordless sudo when mounting
shared folders with NFS.
2019-06-24 13:38:20 -07:00
Chris Roberts d490b0589f
Merge pull request #10926 from chrisroberts/f-no-local-loading
Fix plugin discovery loading when no data directory is available
2019-06-21 12:41:10 -07:00
Chris Roberts 7fbe8bcabc Fix plugin discovery loading when no data directory is available
If the local data directory is unavailable, there will be no local
file to use within the plugin manager. Check for local file before
returning result, otherwise just return an empty hash.
2019-06-21 11:15:39 -07:00
Chris Roberts 7c6b2963c3
Merge pull request #10911 from chrisroberts/f-plugin-loading
Support loading machine configuration without provider validation
2019-06-20 11:23:10 -07:00
Chris Roberts fef8316b3c
Merge pull request #10915 from laozc/fix-gp
Fix provider name not work when specified
2019-06-20 11:22:01 -07:00
Brian Cain 7a5de4030b
Update CHANGELOG 2019-06-20 08:13:11 -07:00
Brian Cain 181e356a23
Merge pull request #10917 from briancain/chef-install-check-update
Fixes #10912: Update chef install check for guests
2019-06-20 08:11:50 -07:00
Chris Roberts fed8bab0ff Fixing path construction for gem storage 2019-06-19 17:07:01 -07:00
Chris Roberts e61e82511d Update path used for file copy 2019-06-19 16:20:48 -07:00
Chris Roberts 263203e47c
Merge pull request #10921 from chrisroberts/new-circle
Update circle configuration
2019-06-19 15:56:36 -07:00
Chris Roberts 936934fd78 Install bsdtar before running tests 2019-06-19 15:31:43 -07:00
Chris Roberts 5e0f64d654 Only run tests that require bsdtar if it is available 2019-06-19 15:29:55 -07:00
Chris Roberts 2f2d1f9cb2 Fix docker test to not call docker executable 2019-06-19 11:59:09 -07:00
Chris Roberts f3e960141e Update circle configuration 2019-06-19 09:49:14 -07:00
Brian Cain 6e4eb66cb1
Fix windows binary check for chef provisioner 2019-06-17 14:06:03 -07:00
Brian Cain d55f8d3496
Fixes #10912: Update chef install check for guests
Prior to this commit, the chef_installed capability was looking for a
string that has recently changed in newer versions of chef. This commit
fixes that by instead just looking for the right version that was
configured for the chef client, rather than the specific string that
could change again in the future.
2019-06-17 11:02:57 -07:00
Brian Cain 7e0e7ff7e9
Update CHANGELOG 2019-06-17 08:22:54 -07:00
Brian Cain c3a96ace35
Merge pull request #10909 from briancain/fixup-bsd-nfs-exports
Fixes #10609: Properly set BSD options for /etc/exports
2019-06-17 08:21:29 -07:00
Brian Cain 75d42fed9d
Merge pull request #10902 from briancain/fixup-rsync-listener
Fixes #10895: Use relative paths to machines folder path for Listener
2019-06-17 08:20:37 -07:00
Brian Cain 89469511fc
Update CHANGELOG 2019-06-17 08:20:03 -07:00
Brian Cain 45b200e315
Update CHANGELOG 2019-06-17 08:18:55 -07:00
Brian Cain 5f0abd3d40
Merge pull request #10901 from briancain/ensure-empty-arrs-rsync-not-fail
Fixes #10869: Remove excludes if array is empty
2019-06-17 08:18:05 -07:00
Zhongcheng Lao caae214bf7 Fix provider name not work when specified
Provider name should be symbol in guess_provider.
2019-06-17 08:22:50 +08:00
Chris Roberts 9bae0a7094 Support loading machine configuration without provider validation
Allow Vagrantfile#machine_config to load properly when the requested
provider may not be currently available. Update the Environment to
utilize this when searching for plugin information to properly allow
box provided Vagrantfiles to define required plugins.
2019-06-14 11:50:06 -07:00
Brian Cain fc4e03d559
Fixes #10609: Properly set BSD options for /etc/exports
Prior to this commit, the BSD options for the /etc/exports file was not
properly set up in the correct order for a given entry. It was however
fixed for FreeBSD, but never for the original exports template. This
commit fixes that by unifying the BSD and FreeBSD templates.
2019-06-13 11:44:12 -07:00
Brian Cain 206ff9d4ca
Merge pull request #10907 from petems/minor_spelling_fixes
Minor spelling fixes
2019-06-13 08:14:14 -07:00
petems 68c3a906b1 Minor spelling fixes
`docker run    -v $(pwd):/scripts    --workdir=/scripts    nickg/misspell:latest    misspell -w -source=text website/`
2019-06-13 15:37:55 +01:00
Brian Cain 1b0148bc78
Fixes #10895: Use relative paths to machines folder path for Listener
Prior to this commit, the rsync helper expanded all exclude paths that
should be ignored to be full qualified and regexp escaped. However the
Listen gem expects these ignore paths to be relative to the path passed
into the listener, not a full path. This commit fixes that by using the
path given by the user for the `rsync__exclude` option
2019-06-11 14:58:42 -07:00
Brian Cain bf55e43460
Fixes #10869: Remove excludes if array is empty
Prior to this commit, if a user specified that their `rsync__excludes`
option was an empty array, Vagrant would treat that as if it included
options inside the array rather than ignoring it. This commit fixes that
by only adding the excludes option when it exists and is not empty.
2019-06-10 13:44:39 -07:00
Chris Roberts b2aa1b7b69 Update CHANGELOG 2019-06-05 14:02:47 -07:00
Chris Roberts bbd75ef25a
Merge pull request #10896 from chrisroberts/f-plugin-constraints
Properly generate dependency instance when multiple constraints provided
2019-06-05 14:01:48 -07:00
Chris Roberts 892a408b39 Update CHANGELOG 2019-06-05 14:01:19 -07:00
Chris Roberts b90d01377e
Merge pull request #10894 from chrisroberts/e-deps-system
Handle strict dependency enforcement when installed within system
2019-06-05 14:00:07 -07:00
Chris Roberts a0c03860b7 Update CHANGELOG 2019-06-05 13:59:38 -07:00
Chris Roberts 2507b68045
Merge pull request #10891 from chrisroberts/f-trigger-multithread
Update trigger abort behavior when running parallel actions
2019-06-05 13:58:44 -07:00
Chris Roberts 04083e7d07 Update CHANGELOG 2019-06-05 13:57:24 -07:00
Chris Roberts f5f89f72b7
Merge pull request #10889 from chrisroberts/f-local-plugins-boxfile
Support loading plugin information from nested Vagrantfiles
2019-06-05 13:56:29 -07:00
Chris Roberts 5a7afd1c16 Update CHANGELOG 2019-06-05 13:55:30 -07:00
Chris Roberts bbf8f05d75
Merge pull request #10884 from GregJPreece/feature/10506-machine-readable-status
#10506 - Machine Readable Global-Status
2019-06-05 13:54:47 -07:00
Chris Roberts 109214f89d Properly generate dependency instance when multiple constraints provided 2019-06-05 13:46:42 -07:00
Chris Roberts fd34ea657b Add test coverage on expected machine-readable output 2019-06-05 13:04:47 -07:00
Chris Roberts 07b9f39a54 Clean up gem sources modifications
Based on suggestions from @zenspider here:
3daf3e532d (r33408747)
2019-06-05 09:36:37 -07:00
Chris Roberts ce56739b29 Update bundler error text content 2019-06-05 09:14:37 -07:00
Brian Cain 382c7315c8
Update CHANGELOG 2019-06-05 07:59:23 -07:00
Brian Cain fb80e8da9f
Merge pull request #10890 from briancain/add-usability-check-for-docker-plus-tests
Add usability check for docker plus tests
2019-06-05 07:58:23 -07:00
Chris Roberts 062ef52816 Handle strict dependency enforcement when installed within system
When installed outside of the official installer and not running
within a bundler environment, properly activate core dependencies
and properly enforce constraints.
2019-06-05 07:45:07 -07:00
Greg J Preece 2f818c0e23 Removing unneeded .send() calls in machine output. 2019-06-04 21:35:37 -07:00
Greg J Preece ede2c295f4 bsdtar appears to be required for all Vagrant use. 2019-06-04 21:27:14 -07:00
Greg J Preece 8c03b5179a Correcting suggested VAGRANT_HOME location in dev. 2019-06-04 21:16:03 -07:00
Greg J Preece 33a228a8e2 Revert "Suppressing UI output in machine-readable mode"
This reverts commit f626c53af2.
2019-06-04 20:58:52 -07:00
Greg J Preece b57d467fa2 Revert "Updating unit tests w/ UI message suppression"
This reverts commit f25427869c.
2019-06-04 20:58:46 -07:00
Chris Roberts 88c675694a Update trigger abort behavior when running parallel actions
When the provider supports parallel actions and actions are being
run in parallel, do not immediately kill the process on failure.
Instead terminate the action thread and log the exit code. Once
all running actions have completed, the process will then exit
with the stored exit code.
2019-06-04 16:40:59 -07:00
Brian Cain b8b2111700
Remove unnecessary test from virtualbox context 2019-06-04 14:56:31 -07:00
Brian Cain bb6913e6e8
Fixup virtualbox provider tests for Travis 2019-06-04 14:43:13 -07:00
Brian Cain 74c89e5ec1
Add virtualbox provider rspec tests 2019-06-04 14:14:06 -07:00
Brian Cain 34e53a5a4b
Add docker provider class test
This commit introduces aa provider_test class for the Docker provider
2019-06-04 13:24:07 -07:00
Chris Roberts d0115de80e Update CHANGELOG 2019-06-04 11:35:51 -07:00
Chris Roberts 0cba5263ad
Merge pull request #10811 from chrisroberts/f-synced-folder-creds
Remove configuration information from SMB synced folder data
2019-06-04 11:33:33 -07:00
Chris Roberts ac8916341b
Merge pull request #10809 from FranklinYu/doc/expand-var
Mention variable expansion in documentation
2019-06-04 11:25:32 -07:00
Chris Roberts 50c4464d44 Support loading plugin information from nested Vagrantfiles
Since plugin installation happens when the environment is first
initialized, attempt to determine the provider in use and load
any box provided Vagrantfiles to include any plugin configuration
they may include.
2019-06-04 10:07:02 -07:00
Anders Kaseorg 7980178d19 providers/docker: Add usability test
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-05-30 13:13:43 -07:00
Greg J Preece f25427869c Updating unit tests w/ UI message suppression 2019-05-30 09:17:30 -07:00
Greg J Preece f626c53af2 Suppressing UI output in machine-readable mode 2019-05-30 08:39:49 -07:00
Greg J Preece 2088bfb60d Adding note to README re: bsdtar dependency 2019-05-29 20:31:18 -07:00
Greg J Preece 731f249c50 Machine ID output should be 7 characters. 2019-05-29 11:10:33 -07:00
Greg J Preece c6a6fd34a3 Adding machine-readable output to global-status 2019-05-29 10:48:38 -07:00
Greg J Preece a6f0d24f68 Documenting local Vagrant vs package Vagrant. 2019-05-28 18:12:23 -07:00
Brian Cain b3877f4b2c
Merge pull request #10855 from briancain/remove-aws-mention-for-guide
Replace AWS provider in getting started guide with Hyper-V
2019-05-24 09:16:22 -07:00
Brian Cain 3357d7060e
Merge pull request #10858 from briancain/chef-common-docs-navbar
Fixes #10856: Add common chef config options to nav bar
2019-05-24 09:15:53 -07:00
Brian Cain f8eca3f7cf
Update CHANGELOG 2019-05-24 09:14:24 -07:00
Brian Cain f8eaa41b7e
Merge pull request #10854 from briancain/fixup-typed-trigger-actions
Ensure guest names are string when filtering trigger configs
2019-05-24 09:13:43 -07:00
Brian Cain 5ff47b5d69
Update CHANGELOG 2019-05-21 08:29:34 -07:00
Brian Cain 73e3465b47
Merge pull request #10841 from wzur-r3/patch-1
Search for running_vm_list only in `machines` folder
2019-05-21 08:28:36 -07:00
Brian Cain be7876d836
Merge pull request #10860 from issyl0/add_sidebar_link_to_upload_page
Link to the "upload" docs page from the docs sidebar
2019-05-14 13:51:28 -07:00
Isabell (Issy) Long a0e1062819
Link to the "upload" docs page from the docs sidebar
- Fixes #10837.
2019-05-14 20:11:18 +01:00
Brian Cain a8783d6703
Fixes #10856: Add common chef config options to nav bar
This commit updates the provisioner nav bar on the docs website to
include the common chef configuration documentation. This makes these
options more discoverable, as before it was hidden in a URL link inside
of the other chef docs.
2019-05-14 09:58:14 -07:00
Brian Cain b1f14087e5
Replace AWS provider in getting started guide with Hyper-V
The vagrant-aws provider doesn't really make sense anymore to be
mentioned in the getting started guide for providers. Instead, replace
it with the Hyper-V provider.
2019-05-13 14:25:00 -07:00
Brian Cain eb3e309f89
Ensure guest names are string when filtering
Prior to this commit, if a guest name was given as a symbol, the
filter_triggers method would fail to properly match it with the only_on
option, as it is not a valid type to the #String.match method. This
commit fixes that by converting the parameter to a string so that it can
be properly matched on the guest.
2019-05-13 14:07:22 -07:00
Brian Cain 57c4de49f2
Remove "command" string from logger
Since not all triggers are commands, removing the word `command` from
the logger so it is not confused with other types of triggers.
2019-05-13 13:26:47 -07:00
Brian Cain e91a1aadc4
Merge pull request #10849 from pjl/fix-snapshot-delete-documentation
Add vm-name option to snapshot documentation
2019-05-13 09:53:32 -07:00
Brian Cain 28bbd10689
Merge pull request #10812 from mrgnw/patch-1
Prevent nopasswd issues, add vagrant entries at end of sudoers
2019-05-13 09:15:29 -07:00
Perry Lee 017c793f90 Add vm-name option to snapshot documentation 2019-05-10 16:49:20 -07:00
Morgan Williams d1373c9e97 Single paragraph: order matters in sudoers
Single paragraph about how the suoders file format applies these rules in order of entry
2019-05-09 21:49:58 -04:00
Morgan Williams a09ad31db4 Revert " Recommend adding lines to end of sudoers, ensuring %admin and root exist "
This reverts commit 36420ce82b.
2019-05-09 21:46:01 -04:00
Waldemar Żurowski a2a848285c
Search for running_vm_list only in `machines` folder
otherwise it might catch a non-machine id, in my case, for hostmanager plugin
2019-05-09 18:07:23 +01:00
Brian Cain 917aab0552
Update CHANGELOG 2019-05-08 09:33:51 -07:00
Brian Cain 93497b8ca3
Merge pull request #10829 from briancain/box-update-continue
Continue updating environment boxes if metadata not found
2019-05-08 09:32:58 -07:00
Brian Cain f7de9c3bcb
Update CHANGELOG 2019-05-08 09:18:06 -07:00
Brian Cain 237209d6e4
Merge pull request #10828 from briancain/snapshot-list-ux-fixup
Separate snapshot names when listing snapshots
2019-05-08 09:17:06 -07:00
Brian Cain fbbdf45dae
Update CHANGELOG 2019-05-08 09:16:39 -07:00
Brian Cain 86800421db
Merge pull request #10824 from briancain/exit-process-on-abort-triggers
Fixes #10823: Use Process.exit! for abort trigger option
2019-05-08 09:15:51 -07:00
Brian Cain 18f2eee392
Update CHANGELOG 2019-05-08 09:15:18 -07:00
Brian Cain a613044baf
Merge pull request #10820 from briancain/docker-compose-volumes
Fixes #10798: Enhance how docker compose driver path expands
2019-05-08 09:14:33 -07:00
Brian Cain a7f72d29ca
Merge pull request #10814 from briancain/install-link-for-share-docs
Fixes #10813: Add install link docs to Share tutorial
2019-05-08 09:13:53 -07:00
Brian Cain beb9572a9c
Update CHANGELOG 2019-05-08 09:13:33 -07:00
Brian Cain 9a0fa8c061
Merge pull request #10803 from briancain/ensure-gemrc-set
Set gemrc through configuration method rather than relying on environment variable
2019-05-08 09:12:11 -07:00
Brian Cain e2d017b219
Continue updating environment boxes if metadata not found
Prior to this commit, if a user ran a `vagrant box update` on their
entire environment and one of the boxes did not have a metadata file,
the rest of the boxes in the update would be skipped. This commit fixes
that by ignoring those boxes and showng a warning, so that the rest of
the boxes could check for updates.
2019-05-08 09:04:45 -07:00
Brian Cain ca232444e7
Separate snapshot names when listing snapshots
Prior to this commit, Vagrant would list all machine snapshots in a flat
list, without showing which snapshots were associated with which guests.
This commit fixes that by placing some separation to make it clear which
snapshots belong to which guests.
2019-05-06 11:09:34 -07:00
Brian Cain 35ee3e2342
Fixes #10823: Use Process.exit! for abort trigger option
Prior to this commit, the `abort` option for triggers would just call
`exit`, which would end up raising a SystemExit exception, signaling
Vagrant to abort. This broke down however in a multithreaded context
like when running multiple guests at once on supported providers,
resulting in Vagrant failing to exit cleanly and instead raise an
exception. This commit changes that by instead using `Process.exit!` to
abort Vagrant.
2019-05-03 14:48:54 -07:00
Brian Cain ca0fd64ded
Fixes #10798: Enhance how docker compose driver path expands
Prior to this commit, the docker compose driver would _always_ path
expand a host volume no matter what. This is not always the correct
option, for example if that host volume is actually a reference to a key
inside a `volumes` hash instead of a path on disk. This commit changes
that by looking to see if the requested host volume is actually a
defined key inside the compose config, and if not, it will path expand
it like before. Otherwise it will leave the key "as is".
2019-04-29 16:14:37 -07:00
Brian Cain b693da4a2f
Fixes #10813: Add install link docs to Share tutorial
This commit adds a note and link on how to install vagrant-share before
the vagrant share tutorial starts. This ensures that users know they
need the plugin installed since it no longer comes with Vagrant core.
2019-04-26 08:21:26 -07:00
Morgan 36420ce82b
Recommend adding lines to end of sudoers, ensuring %admin and root exist
Adding entries to the end of sudoers is an easy way to prevent issues and ensure NOPASSWD functionality works as expected.
2019-04-25 16:56:56 -04:00
Chris Roberts e7e8a39c55 Stub the ssh path used for exec
Since a full path to the ssh executable is being used and is expected
at a specific location, default to providing that location when looking
up the executable. This prevents errors from occurring when a host
system provides an `ssh` match at a different path.
2019-04-25 10:44:25 -07:00
Chris Roberts 5b94bbb49b Scrub folder configuration data when persisting to disk
Before writing synced folder configuration data to the local
data directory run content through the credential scrubber to
remove any sensitive content before write.
2019-04-25 10:31:48 -07:00
Chris Roberts 92e6a29bfc Update naming in tests as instance methods are being referenced 2019-04-25 10:09:50 -07:00
Chris Roberts b493503e09 Scrub SMB credential information from folder configuration
This prevents credential information from being persisted into the
local data directory which is used during subsequent runs to determine
folder definition changes.
2019-04-25 10:07:48 -07:00
Brian Cain c22a145c59
Update CHANGELOG 2019-04-25 08:44:49 -07:00
Brian Cain 15c7fc23ce
Merge pull request #10810 from alex-goncharov-usa/fix-box-update-version-sort
Fix box version sort in Update.update_specific
2019-04-25 08:41:41 -07:00
Alex Goncharov 9266899b34 Add a test for version selection for a box update 2019-04-24 19:59:37 -04:00
Alex Goncharov b75768fc56 Fix box version sort in Update.update_specific 2019-04-24 18:57:34 -04:00
Franklin Yu 13a959312d
Mention variable expansion in documentation 2019-04-24 17:13:17 -04:00
Brian Cain 757175b94e
Add note about removing patch fix and add test 2019-04-22 10:36:25 -07:00
Brian Cain e2097be55e
Fixes #10800, Fixes #9148: Ensure rubygems is loading gemrc properly on Windows
Prior to this commit, when Vagrant attempted to use the Gem library, it
would attempt to pass in a gemrc through an environment variable that
the rubygems library would try to split and parse. This is normally
fine, as the method in question would return empty if that file did not
exist. However if the user had a file that matches the drive that
Vagrant was installed on, rubygems would fail saying the folder was not
a file (or a gemrc, in this case).

This commit works around that by instead configuring the gemrc location
through ruby with `Gem.configuration`.

Related rubygems issue
[#2733](https://github.com/rubygems/rubygems/issues/2733)
2019-04-19 17:07:49 -07:00
Brian Cain ad342e2bf0
Merge pull request #10792 from briancain/make-env-var-docs-clearer
Reword documentation for VAGRANT_DISABLE_VBOXSYMLINKCREATE option
2019-04-15 09:11:51 -07:00
Brian Cain e0cd29e301
Fixup docs for environment variable 2019-04-12 15:48:31 -07:00
Brian Cain cb69836fb7
Reword documentation for VAGRANT_DISABLE_VBOXSYMLINKCREATE option
Follow-up from #10790
2019-04-12 15:40:10 -07:00
Brian Cain cd3909d7ce
Update CHANGELOG 2019-04-09 15:13:17 -07:00
Brian Cain 139ae4397f
Merge pull request #10625 from vdebroy/fix-issue-9584
Fix issue 9584
2019-04-09 15:12:02 -07:00
Brian Cain 114775475c
Update CHANGELOG 2019-04-09 15:11:36 -07:00
Brian Cain 8e9578cf5d
Merge pull request #10752 from chrisroberts/f-coreos-guest-caps
Update guest capabilities for coreos
2019-04-09 15:10:58 -07:00
Brian Cain 3a81a92db7
Update CHANGELOG 2019-04-09 15:05:11 -07:00
Brian Cain 8109433885
Merge pull request #10784 from briancain/fixup-snapshot-list-virtualbox
Ensure non-existent machines do not attempt to list snapshots
2019-04-09 15:03:50 -07:00
Brian Cain 46e42ed884
Move up doc string for `vagrant snapshot pop`
This commit moves up the doc string for the command `vagrant snapshot
pop` Prior to this commit it was hidden in between command line flags.
2019-04-09 13:14:44 -07:00
Brian Cain 75d4aa42a1
Ensure non-existent machines do not attempt to list snapshots
Prior to this commit, if a snapshot restore was run on an entire
environment with some non-existent guests, Vagrant would attempt to list
their snapshots with a nil id. This commit fixes that by returning an
empty list of snapshots if the machine has not been created yet.
2019-04-09 13:11:19 -07:00
Brian Cain 1fe8712ec2
Merge pull request #10772 from briancain/fixup-provision-shell-docs
Remove *I* from documentation
2019-04-02 10:18:04 -07:00
Brian Cain 872c036686
Remove *I* from documentation
Removing I since it does not really make sense while reading the
documentation.
2019-04-01 16:18:29 -07:00
Brian Cain 5254ed4ae0
Update CHANGELOG 2019-03-29 09:48:49 -07:00
Brian Cain 84e348bfab
Merge pull request #10763 from jlduran/freebsd-simplify-interfaces-list
FreeBSD: Simplify the listing of interfaces
2019-03-29 09:48:11 -07:00
Jose Luis Duran 93f02c67f8
FreeBSD: Simplify the listing of interfaces
According to ifconfig(8), to list only Ethernet interfaces, excluding
all other interface types, including the loopback interface, the command
to use should be:

    ifconfig -l ether

Related to: #8760
2019-03-29 02:47:39 -03:00
Brian Cain 6edcf12979
Merge pull request #10762 from abh23/patch-1
note for pre-requisite of ngrok package
2019-03-28 09:37:31 -07:00
Brian Cain 3d69bfaceb
Update CHANGELOG 2019-03-28 08:44:51 -07:00
Brian Cain 3cb3c91654
Merge pull request #10761 from jlduran/follow-linux-naming-convention
BSD: VirtualBox shared folders naming convention
2019-03-28 08:43:48 -07:00
Amit Bhardwaj 33c1ebf84b
note for pre-requisite of ngrok package
Current version of vagrant-share works only with ngrok installed. Just added a note for the same.
2019-03-28 14:27:39 +05:30
Jose Luis Duran 1cf0e62400
BSD: VirtualBox shared folders naming convention
This is a follow-up of #10717 to use the same naming convention as on
Linux guests, in order to reduce the diffs.

Also adds the missing capability to `unmount_virtualbox_shared_folder`
on FreeBSD guests.
2019-03-28 02:34:34 -03:00
Brian Cain 3da2270366
Update CHANGELOG 2019-03-25 15:44:27 -07:00
Brian Cain ec67151312
Merge pull request #10702 from briancain/docker-network-support
Docker Provider Network Support
2019-03-25 15:43:23 -07:00
Chris Roberts 8339e63423 Fix subnet to ip_range and add gateway information for public networks 2019-03-25 15:26:18 -07:00
Chris Roberts 1e856ecf8a Add information on public_network for docker provider 2019-03-25 15:13:19 -07:00
Brian Cain 1a596e26ab
Merge pull request #10747 from rconde-bt/master
Fixed typos: vargant->vagrant
2019-03-25 14:03:50 -07:00
Brian Cain f4c6aa8aa1
Update docker provider networking docs from pull request feedback 2019-03-25 13:25:49 -07:00
Brian Cain a8733e2800
Merge pull request #10758 from briancain/update-license-year
Update year on LICENSE
2019-03-25 10:39:18 -07:00
Brian Cain dd782294f4
Update year on LICENSE 2019-03-25 10:21:32 -07:00
Chris Roberts 0575fdfd69 Do not rely on IPAddr#prefix as it's not available on older rubies 2019-03-22 16:42:30 -07:00
Brian Cain d9f3f88ff0
Update CHANGELOG 2019-03-22 16:31:20 -07:00
Brian Cain 53c11d9b55
Merge pull request #10748 from briancain/fix-ui-prefix-typo
Fix typo in UI Prefix for trigger UI
2019-03-22 16:30:38 -07:00
Chris Roberts 8ba69e587c Update guest capabilities for coreos 2019-03-22 15:20:37 -07:00
Brian Cain 9d200bdb72
Add note about specific create and connect flag options for Vagrant 2019-03-22 13:50:13 -07:00
Brian Cain 979dd37e46
Remove comment about private networks only working with docker provider 2019-03-22 10:10:44 -07:00
Brian Cain f8744b66f0
Add connect cli argument tests 2019-03-22 09:24:26 -07:00
Brian Cain 4f80a9e6d5
Add test for requesting public ip range for docker network provider 2019-03-22 09:02:40 -07:00
Brian Cain 36f2aaf55e
Add test for public network gateway request 2019-03-22 08:45:14 -07:00
Brian Cain b56f89775d
Add more mocks for public network
Ensure test values are used rather than real values from machine
2019-03-22 08:24:22 -07:00
Brian Cain 6bffdca972
Add beginning of connect network tests for docker provider 2019-03-21 16:06:24 -07:00
Brian Cain 88a18fe2c5
Add public network tests for docker provider 2019-03-21 16:06:11 -07:00
Brian Cain 82700d95b3
Ensure subnet is used if specified from user config options 2019-03-21 15:29:04 -07:00
Brian Cain 2bc6fa854a
Add tests for validating network configurations 2019-03-21 13:51:24 -07:00
Brian Cain 36a41957c9
Fix travis ci tests for public gateway and ip range issues 2019-03-21 13:51:07 -07:00
Brian Cain 98e41eb936
Mock out public/private network calls for existing subnet tests 2019-03-21 13:26:37 -07:00
Brian Cain 32807d70c7
Mock up public/private network calls for #call test 2019-03-21 13:03:39 -07:00
Brian Cain 8c169714c5
Ensure variable names exist in method 2019-03-21 11:39:16 -07:00
Brian Cain 6ce453ab70
Delete old file and add blank describe blocks for remaining tests 2019-03-21 11:16:26 -07:00
Brian Cain 96a19aa00c
Fix how options to cli args are handled
Since options could also be defined as strings, convert it all to string
and compare those instead
2019-03-21 11:15:41 -07:00
Brian Cain 5215354d16
Fix missing docker error classes, and finish out initial #call tests 2019-03-21 10:50:45 -07:00
Brian Cain ee985f9f7f
Fix typo in UI Prefix for trigger UI 2019-03-21 10:11:38 -07:00
Robert Conde b43f5db876 Fixed typos: vargant->vagrant 2019-03-21 12:58:42 -04:00
Brian Cain 75d6c17386
Fix up call method and add todo for prepare networks 2019-03-20 16:41:42 -07:00
Chris Roberts 1220122b46 Update CHANGELOG 2019-03-20 15:58:24 -07:00
Chris Roberts b1d8b952bb
Merge pull request #10745 from chrisroberts/f-net-sftp-comms
Remove require of net/sftp library
2019-03-20 15:57:21 -07:00
Chris Roberts bbb971ee98 Update CHANGELOG 2019-03-20 15:49:34 -07:00
Chris Roberts 2d5091a985
Merge pull request #10713 from renatoaguiar/fix-void-nfs
Fix NFS capability detection on Void Linux
2019-03-20 15:48:46 -07:00
Chris Roberts 7a6e545b6c Update CHANGELOG 2019-03-20 15:48:14 -07:00
Chris Roberts 0462da57c4
Merge pull request #10727 from chrisroberts/f-empty-id-file
Remove whitespace from id file on load
2019-03-20 15:47:14 -07:00
Brian Cain 1027636e41
Split up and rename unit tests for docker network operations 2019-03-20 15:14:39 -07:00
Brian Cain eb75431c4a
Update docker driver and docker driver unit tests 2019-03-20 14:50:28 -07:00
Brian Cain c09bce5386
Fixup docker action destroy_network test 2019-03-20 13:35:46 -07:00
Chris Roberts 3ca8089920 Remove require of net/sftp library
Fixes #10733
2019-03-20 13:02:08 -07:00
Chris Roberts 623a1815ae Allow use of subnet option when defining private network with dhcp type 2019-03-19 14:35:40 -07:00
Chris Roberts 670bef6596 Allow custom subnet to be provided when private network type is dhcp 2019-03-19 14:20:14 -07:00
Chris Roberts afb6c20581 Fix option mask to be expected netmask 2019-03-19 14:03:03 -07:00
Chris Roberts a1c7eec441 Include synchronization as the environment lock is per process only 2019-03-19 13:46:14 -07:00
Chris Roberts a645ce3c25 Docker provider networking support updates
Use `mask` option for defining subnet on network configuration. Allow
options to be passed through using hash scoping and docker_network and
docker_connect prefixes. Enable public networks. Allow configuration
to define pre-existing networks by name.
2019-03-19 11:44:33 -07:00
Chris Roberts 1224622387 Remove container inspection caching and Exception rescue
Container inspection is caching data on first lookup. This will
result in incorrect data being returned on subsequent lookups if
a different `cid` value is provided. Also removed rescue of
the `Exception` class as this generally should never happen; rescue
of StandardError will be enough.
2019-03-19 11:44:22 -07:00
Chris Roberts c251e090b3 Remove Mutex for synchronization. Environment#lock satisfies requirement. 2019-03-19 11:44:02 -07:00
Brian Cain 4e4e03d7fd
Merge pull request #10742 from rockhopper72/fix-typo-in-wsl
Fix formatting issues on WSL docs
2019-03-19 09:05:06 -07:00
rockhopper72 9678e93a27 Fix formatting issues on WSL docs
- Insert underline to fix **bold** formatting
- Remove grave accent to fix `code` highlighting
2019-03-19 09:03:24 -04:00
Brian Cain 6664936c0b
Make ignored vagrant network options a constant 2019-03-12 10:40:58 -07:00
Brian Cain 5ed5868067
Inspect networks before creating new ones
This commit updates the behavior of how the docker provider creates new
docker networks. It looks at each existing network to see if the
requested subnet has already been configured in the docker engine. If
so, Vagrant will use that network rather than creating a new one. This
includes networks not created by Vagrant. Vagrant will not clean up
these networks if created outside of Vagrant.
2019-03-12 10:36:57 -07:00
Chris Roberts 1c650a7fb8 Remove whitespace from id file on load
If the id file includes whitespace, remove it. If the content of
the id file is empty, do not set the machine id.

Fixes: #10722
2019-03-11 17:08:13 -07:00
Brian Cain 1e1c398de5
Update CHANGELOG 2019-03-11 15:08:26 -07:00
Brian Cain e399aeaf70
Merge pull request #10717 from briancain/add-vbox-share-folders-bsd
Add proper VirtualBox share folders support for FreeBSD guests
2019-03-11 15:07:17 -07:00
Brian Cain b4a21617d1
Update CHANGELOG 2019-03-11 15:05:55 -07:00
Brian Cain 11e6ea3a76
Merge pull request #10726 from briancain/improve-cloud-cli-doc-strings
Fixes #10723: Fix bug instance var in Vagrant Cloud CLI optparse
2019-03-11 15:04:55 -07:00
Brian Cain 5b3c6b8ad4
Fixes #10723: Fix bug instance var in Vagrant Cloud CLI optparse
This commit uses the correct instance variable for the optparse library
when reading in the command line flags for various Vagrant Cloud CLI
commands.
2019-03-11 14:21:55 -07:00
Brian Cain 2f0c66f832
Only enable shared folder mounts on freebsd guests
Since the virtualbox guest additions seem to only be available for
freeBSD, move the shared folder functionality over to freebsd guests
rather than all BSD guests.
2019-03-08 11:03:23 -08:00
Brian Cain b2251d5bec
Update logger to display vboxvfs module rather than vboxsf
Ensure the logger displays the right vbox module used for mounting
shared folders
2019-03-07 10:49:38 -08:00
Brian Cain fe002b7e48
Add unit tests for virtualbox shared folders 2019-03-07 10:35:37 -08:00
Brian Cain 0bfca8293a
Update from vboxsf to vboxvfs
BSD guests use vboxvfs module for mounting share folders
2019-03-07 10:35:37 -08:00
Brian Cain 554b096961
Fixes #8884: Introduce proper VirtualBox shared folders for BSD
This commit adds proper VirtualBox shared folder support for BSD guests.
It is essentially a copy of the linux capability.
2019-03-07 10:35:37 -08:00
Brian Cain 2c25cf8d01
Add note about network creation in docker provider 2019-03-05 13:46:05 -08:00
Brian Cain cedf5aff17
Add note about link legacy flag in connect 2019-03-05 11:23:23 -08:00
Brian Cain 93f833d2b3
Add docs page about networking with the docker provider 2019-03-05 11:18:35 -08:00
Brian Cain b78dada2c7
Fix docker driver handling cli flags
Make opts argument set to nil instead of splat to make Travis Ruby 2.3
happy
2019-03-05 10:57:05 -08:00
Renato Aguiar 4de7716ffb Fix NFS capability detection on Void Linux 2019-03-05 10:03:52 -08:00
Brian Cain 2be0bc2d81
Add unit tests for docker network actions 2019-03-05 09:49:15 -08:00
Brian Cain cccbedf4ce
Update how docker network handles processing options to cli arguments
Add an "ignored option" array rather than a big if-statement expression
2019-03-04 14:19:40 -08:00
Brian Cain 953a380371
Fix how Vagrant assigns cli arguments for the create command
This commit inlines the flag assignments so that arguments are properly
assigned to flags rather than arguments to the subcommand.
2019-03-04 13:44:21 -08:00
Brian Cain efb9fd7b65
Move strings into locales file 2019-03-04 13:33:08 -08:00
Brian Cain a1b48ed1bb
Raise proper class if invalid options given for docker network 2019-03-04 13:17:14 -08:00
Chris Roberts fbe44f1f48 Update CHANGELOG 2019-03-04 13:07:07 -08:00
Chris Roberts 5dc504b12c
Merge pull request #10706 from chrisroberts/e-package-metadata
Write metadata file to box contents during package
2019-03-04 13:06:24 -08:00
Chris Roberts 5660d078a8 Update CHANGELOG 2019-03-04 13:05:50 -08:00
Chris Roberts a941ff40c4
Merge pull request #10707 from steve-simpson/bsdtar_fix_issue_10705
Added --no-same-owner & --no-same-permissions flags to bsdtar in box_…
2019-03-04 13:04:47 -08:00
Brian Cain 0b28580105
Move out cli argument generation to own function 2019-03-04 10:33:24 -08:00
Brian Cain 81fa7036be
Rename cli argument method 2019-03-04 10:28:49 -08:00
Brian Cain 6c7c74be5a
Fix if statement from `=` to `==` 2019-03-04 10:28:05 -08:00
Brian Cain 4080f9e64d
Log warning if docker network inspect fails to return json 2019-03-04 10:25:10 -08:00
Brian Cain 5adffb608d
Only allow private_network for docker network provider 2019-03-01 16:34:43 -08:00
Brian Cain 29696b0f73
Allow for ipv6 networks in docker 2019-03-01 16:20:16 -08:00
Brian Cain 000457a012
Update how docker network provider creates networks
This commit updates the docker network provider to only create networks
by subnet rather than per-container.
2019-03-01 16:07:53 -08:00
steve-simpson 7b3ca04a6e Added --no-same-owner & --no-same-permissions flags to bsdtar in box_collection.rb 2019-03-01 18:02:37 +00:00
Brian Cain c20de9044d
Log information if unsupported docker network option is provided 2019-03-01 08:34:43 -08:00
Brian Cain 4a0f1a0a33
Update docker network action to auto-generate cli flags
This commit updates the docker network behavior to auto-generate the
docker network command flags from Vagrants network config option.
2019-03-01 08:34:43 -08:00
Brian Cain b5a092397f
Add new function for handling vagrant options to docker network cli
flags
2019-03-01 08:34:43 -08:00
Brian Cain ba2a1224e0
Update driver to include network tests 2019-03-01 08:34:43 -08:00
Brian Cain dc5f8c66f2
Add todo comment for future fixup 2019-03-01 08:34:43 -08:00
Brian Cain 4dc5f7c330
Add basic ability to configure some networks for containers 2019-03-01 08:34:43 -08:00
Brian Cain e860c7709d
Begin to setup and configure docker networks for containers 2019-03-01 08:34:43 -08:00
Brian Cain 8013d8d5ef
Move around Network setup action for docker provider 2019-03-01 08:34:43 -08:00
Brian Cain 63ba0f9964
Add DestroyNetwork action to docker provider 2019-03-01 08:34:43 -08:00
Brian Cain 349cc5ddac
Add placeholder network destroy action for docker 2019-03-01 08:34:43 -08:00
Brian Cain a336aa687c
Add logger and start to iterate over networks in config 2019-03-01 08:34:43 -08:00
Brian Cain bed653eeb4
Autoload and use Network action on up 2019-03-01 08:34:43 -08:00
Brian Cain 67ea15126d
Make opts var optional for docker driver methods 2019-03-01 08:34:43 -08:00
Brian Cain 627251a307
Add basic docker network action 2019-03-01 08:34:43 -08:00
Brian Cain ec2e0380ee
Add basic docker driver methods for `docker network` subcommand 2019-03-01 08:34:43 -08:00
Chris Roberts c0eaac791d Write metadata file to box contents during package
If the provider does not include a metadata.json file prior to
compressing the box, determine current provider and write
metadata.json file before compressing.
2019-02-28 15:31:49 -08:00
Chris Roberts b4d87e6ce9 Update version for dev 2.2.5.dev 2019-02-27 07:38:22 -08:00
Chris Roberts 521d3fa20f Update download version to 2.2.4 2019-02-27 07:37:03 -08:00
Chris Roberts 25e11650c3 Release v2.2.4 2019-02-27 07:35:56 -08:00
Chris Roberts ddd1e5f8c2 Update CHANGELOG 2019-02-26 14:11:46 -08:00
Chris Roberts 927364652f
Merge pull request #10595 from danowar2k/master
- FIX for #10594
2019-02-26 14:09:31 -08:00
Chris Roberts db0f215d42 Update CHANGELOG 2019-02-26 13:32:22 -08:00
Brian Cain a5f5d533bf
Update CHANGELOG 2019-02-26 13:30:37 -08:00
Brian Cain 1592c0c216
Merge pull request #10690 from briancain/cleanup-rsync-tmp-folders
Cleanup rsync tmp folders
2019-02-26 13:25:34 -08:00
Chris Roberts 6beb736190
Merge pull request #10698 from chrisroberts/f-scp
Update communicator upload behavior to handle `/.` path directives
2019-02-26 13:24:40 -08:00
Brian Cain 3b540e502f
Force removal of rsync tmp dir
Force delete entry to prevent any potentail failures when trying to
clean up the tmp dir from rsync
2019-02-26 09:08:56 -08:00
Chris Roberts e2b6a6645c Always ensure remote destination directory exists 2019-02-26 08:54:49 -08:00
Chris Roberts 6b105d704d Update communicator upload behavior to handle `/.` path directives
This update was prompted by updates in openssh to the scp behavior
making source directory paths suffixed with `.` no longer valid
resulting in errors on upload. The upload implementation within
the ssh communicator has been updated to retain the existing
behavior.

Included in this update is modifications to the winrm communicator
so the upload functionality matches that of the ssh communicator
respecting the trailing `.` behavior on source paths. With the
communicators updated to properly handle the paths, the file
provisioner was also updated to simply apply previously defined
path update rules only.

Fixes #10675
2019-02-26 08:02:09 -08:00
Brian Cain 401a571642
Add windows platform test for ensuring tmp file does not exist 2019-02-22 12:44:46 -08:00
Brian Cain 45ca16ffd5
Add rsync helper test for linux machines 2019-02-22 12:38:23 -08:00
Andrew Eikum 7517faa9ee
Remove tmpdir after rsync completes 2019-02-22 12:24:13 -08:00
Brian Cain 1d25480e23
Update CHANGELOG 2019-02-22 10:51:45 -08:00
Brian Cain 52edbedebf
Merge pull request #10686 from briancain/move-middleware-auth-to-cloud-namespace
Fixes #10682: Move over AddAuthentication middleware and hooks
2019-02-22 10:51:02 -08:00
Brian Cain cdcedb0a9e
Fixes #10682: Move over AddAuthentication middleware and hooks
Prior to this commit, the AddAuthentication hooks still existed in a
deprecated class LoginCommand. This commit fixes that by moving it over
to the vagrant cloud cli namespace instead.
2019-02-21 09:42:16 -08:00
Brian Cain 4bf3f6f80a
Update CHANGELOG 2019-02-20 11:05:05 -08:00
Brian Cain 31b9aafcf7
Merge pull request #10622 from mattin4d/master
Change remaining box_client_cert refs to box_download_client_cert
2019-02-20 11:03:49 -08:00
Brian Cain cee88dad81
Merge pull request #10676 from cemderin/add-validate-parameter-to-docs
Add `vagrant validate` parameters to docs
2019-02-19 09:57:19 -08:00
Cem Derin aa60cb1f8f Add `vagrant validate` parameters to docs 2019-02-17 12:54:05 +01:00
Vidroha Debroy aacb453a79 Fixing bug I introduced. Thanks @chrisroberts! 2019-02-15 14:53:56 -06:00
Vidroha Debroy 7c0ffe369a Updated based on recommended changes per review. 2019-02-15 12:14:37 -06:00
Brian Cain a38b0898ce
Merge pull request #10671 from briancain/err-msg-for-bad-version
Fixes #10663: Ignore boxes in collection with malformed version numbers
2019-02-14 16:16:22 -08:00
Brian Cain 6b9cdb4e48
Fixes #10663: Ignore boxes in collection with malformed version numbers
Prior to this commit, if a box some how got on disk that had an
incorrect or invalid version number that did not match Gem::Version,
Vagrant would throw an exception when attempting to generate a list of
the boxes on disk. This commit fixes that by looking at the version from
the path generated, and shows a warning to the user about the box and
skips it from the list so they at least know about the problematic box
and can still get a list of boxes.
2019-02-14 15:30:11 -08:00
Chris Roberts 7bfb41e71d Update CHANGELOG 2019-02-12 16:36:03 -08:00
Chris Roberts 81a7939a76
Merge pull request #10666 from chrisroberts/f-sigint-trap-err
Wrap output in thread when being called from within trap-context
2019-02-12 16:34:49 -08:00
Chris Roberts 68e1425e14
Merge pull request #10665 from chrisroberts/f-vmware-util-doc
Update path for manual vagrant-vmware-utility installation
2019-02-12 16:27:12 -08:00
Chris Roberts 7e47602e3d Wrap output in thread when being called from within trap-context
This prevents a ThreadError exception being raised on sigint which
resulted in a stacktrace being dumped.
2019-02-12 16:06:16 -08:00
Brian Cain 61a598e612
Update CHANGELOG 2019-02-12 10:01:27 -08:00
Brian Cain 045f31cc45
Merge branch 'master' of github.com:hashicorp/vagrant 2019-02-12 10:00:25 -08:00
Brian Cain 68e21d8ac5
Merge pull request #10664 from chrisroberts/f-plugin-config-format
Fix format finalization of plugins in Vagrantfile
2019-02-12 10:00:14 -08:00
Brian Cain 4961683fc4
Update CHANGELOG 2019-02-12 09:59:25 -08:00
Brian Cain 26d05130c4
Merge pull request #10647 from chrisroberts/f-appimage-ld
Use ld path with appimage libs on suffix
2019-02-12 09:58:53 -08:00
Brian Cain 63ac305780
Update CHANGELOG 2019-02-12 09:57:54 -08:00
Brian Cain 9636f59232
Merge pull request #10638 from chrisroberts/e-reboot-message
Add reboot output to guest capability
2019-02-12 09:57:30 -08:00
Brian Cain 07952096d9
Update CHANGELOG 2019-02-12 09:17:18 -08:00
Brian Cain 0bc0bdd616
Merge pull request #10615 from briancain/introduce-typed-triggers
Introduce :type option for Vagrant triggers
2019-02-12 09:16:01 -08:00
Chris Roberts 20490dbe5b Update path for manual vagrant-vmware-utility installation
This updates the installation path described to be the default
location so that the vagrant-vmware-plugin will automatically
discover the certificates directory without requiring any
customization within the Vagrantfile.
2019-02-12 08:11:13 -08:00
Chris Roberts 2e58e002d6 Fix format finalization of plugins in Vagrantfile 2019-02-11 15:48:43 -08:00
Brian Cain 9bd4db3815
Cleanup trigger documentation 2019-02-07 14:11:08 -08:00
Brian Cain 767346ce81
Adjust command wording to match up 2019-02-07 13:35:47 -08:00
Brian Cain aff66822ef
Reorder type triggers 2019-02-07 13:34:12 -08:00
Brian Cain 6d91dfd025
Update trigger docs with more info on types 2019-02-06 16:29:40 -08:00
Brian Cain c6b42a04cd
Update CHANGELOG 2019-02-05 15:16:50 -08:00
Brian Cain ac6dc0670d
Merge pull request #10645 from briancain/expand-paths-on-compare-docker
Expand paths on synced folder compare with docker provider
2019-02-05 15:15:42 -08:00
Brian Cain 33c3c4a3bf
Merge pull request #10648 from briancain/update-ruby-versions
Update Ruby version to 2.6.1 for Travis CI
2019-02-05 09:25:55 -08:00
Chris Roberts e165a5bc6e Update test checking ld path modifications 2019-02-05 07:16:40 -08:00
Brian Cain 1fad0bb4c7
Update Ruby version to 2.6.1 for Travis CI 2019-02-04 13:43:03 -08:00
Chris Roberts a4eb002750 Use ld path of system libs with appimage libs suffixed 2019-02-04 12:52:55 -08:00
Brian Cain 4c61eaa933
Fixes #10643: Ensure paths are properly expanded when comparing synced folders
Prior to this commit, the docker action would attempt to compare and
validate synced folders based on their string value, rather than their
actual path value. This commit updates that by path expanding the mounts
when comparing a containers synced folders.
2019-02-04 11:15:40 -08:00
Brian Cain 91e351b937
Add unit test for dockers compare_synced_folders 2019-02-04 11:12:55 -08:00
Chris Roberts 80705c4804
Merge pull request #10637 from chrisroberts/f-address-config
Add base_address to core vagrant vm config
2019-02-01 16:15:50 -08:00
Chris Roberts ade5370db3 Add reboot output to guest capability 2019-02-01 15:47:02 -08:00
Chris Roberts dfe9762210 Update CHANGELOG 2019-02-01 14:48:49 -08:00
Chris Roberts d3ea9f1f8c
Merge pull request #10629 from chrisroberts/f-vbox6-import-windows
Fix import paths on Windows for the vbox 6 driver
2019-02-01 14:47:46 -08:00
Chris Roberts 61cf179b42 Add base address attribute to vm config 2019-02-01 14:47:11 -08:00
Brian Cain 64e21a1215
Add test for Action classes with no name 2019-02-01 13:34:15 -08:00
Brian Cain 08214ec90f
Ensure action param is a symbol, and if nil return to do nothing 2019-02-01 13:34:15 -08:00
Brian Cain 6ac23f1a15
Add fire trigger test for cli class 2019-02-01 13:34:15 -08:00
Brian Cain fc4e6e624f
Simplify if-statement in trigger parser 2019-02-01 13:34:15 -08:00
Brian Cain 659aa1c48e
Remove todo in validation 2019-02-01 13:34:15 -08:00
Brian Cain 865c553b8f
Update wording on flag example 2019-02-01 13:34:15 -08:00
Brian Cain c4a03e594f
Update trigger config docs 2019-02-01 13:34:15 -08:00
Brian Cain 071d8b09cd
Add machine for hook and action triggers 2019-02-01 13:34:15 -08:00
Brian Cain 37d71898a3
More docs updates for new triggers 2019-02-01 13:34:15 -08:00
Brian Cain efd549e933
Fix typo 2019-02-01 13:34:15 -08:00
Brian Cain f0058993c6
Add docs for experimental flag 2019-02-01 13:34:15 -08:00
Brian Cain 6e8e3b32eb
Update with some docs 2019-02-01 13:34:15 -08:00
Brian Cain 01c5ca8a43
Fixup wording on run_remote message 2019-02-01 13:34:15 -08:00
Brian Cain 16b5ad74ca
Handle command triggers with run_remote options
This commit adds some handling around when a machine does not exist at
all but a trigger was defined with a run_remote option
2019-02-01 13:34:15 -08:00
Brian Cain 09846b30fe
Fixup action tests
This commit fixes up the action tests by adding a `name` field for all
the Action classes used within the various tests.
2019-02-01 13:34:15 -08:00
Brian Cain 5e4850a0d2
Use name instead of class 2019-02-01 13:34:15 -08:00
Brian Cain ec9bda78c3
Remove comment 2019-02-01 13:34:15 -08:00
Brian Cain ae0960f2da
Add comment to wardens finalize_action method 2019-02-01 13:34:15 -08:00
Brian Cain ebacb96626
Update docs for action trigger actions 2019-02-01 13:34:15 -08:00
Brian Cain fefb702359
Introduce `type` and `command` triggers
This commit introduces some basic functionality for typed triggers:

- command
- action

Command triggers are triggers that will run before or after a given
sub-command.

Action triggers are for running triggers before or after internal
actions for Vagrant. This could be before or after a provision step,
before or after synced folders, or networking, etc.
2019-02-01 13:34:15 -08:00
Chris Roberts d7e036981f Add coverage for windows path behavior in vbox6 driver 2019-01-29 11:09:30 -08:00
Chris Roberts cf99438f1f Update base path on windows to use common file separator
On Windows the File::SEPARATOR ends up being `/` which causes
issues with the new way the path is being extracted from the
vbox information. When on Windows (even with WSL), automatically
convert the path to use common forward slash separator. This
fixes path modifications used for storing guest disks.
2019-01-29 11:09:25 -08:00
Vidroha Debroy 9b618eb0cf Updated documentation. Fixes hashicorp/vagrant#9584. 2019-01-28 13:59:00 -06:00
Vidroha Debroy 281203edf1 Handling the cases for UNSET_VALUE, i.e., config is not finalized. 2019-01-28 13:35:50 -06:00
Matt Adams a3836f5fec Change remaining box_client_cert refs
This fixes issues with box add/update when self hosting with client
certs. The --cert option was not being added to the curl subprocess
in these cases.
2019-01-28 08:45:24 -06:00
Vidroha Debroy d2c11e81ae Config has pip_install_cmd for Provisioner to pick it up. Tests updated. 2019-01-25 16:51:58 -06:00
Vidroha Debroy 8418d26037 Ubuntu code updated because it calls Debian code. 2019-01-25 15:22:04 -06:00
Vidroha Debroy 614523a5fc Exposing pip_install_cmd to callers as optional. 2019-01-25 15:09:31 -06:00
Vidroha Debroy 84df098135 Handling empty strings passed as pip_install_command. 2019-01-25 14:55:39 -06:00
Vidroha Debroy 2b0617fb64 Adding pip_install_cmd as a default parameter to get_pip. Unit Tests. 2019-01-25 13:59:15 -06:00
Chris Roberts 87214ed840
Merge pull request #10614 from hashicorp/f-updateReseller
Update reseller.html.md
2019-01-24 12:54:32 -08:00
Alvaro Miranda Aguilera 0459cefe6e
Update reseller.html.md
selfservice first, PO only for 150 or more
2019-01-24 22:40:50 +02:00
Brian Cain da81948212
Merge pull request #10607 from bdickensheets/patch-1
Update to virtualbox documentation link
2019-01-22 08:57:09 -08:00
bdickensheets 8ccabd90f7
Update to virtualbox documentation link 2019-01-20 19:53:22 +02:00
Chris Roberts d749ffc371 Update utility release version 1.0.7 2019-01-18 14:50:40 -08:00
Daniel Poggenpohl 2d9ba0e906 - FIX for #10594 (more logical flow) 2019-01-17 14:59:52 +01:00
Daniel Poggenpohl d565f628fd - FIX for #10594 2019-01-17 14:21:53 +01:00
Brian Cain 7927c39da9
Update CHANGELOG 2019-01-11 16:22:59 -08:00
Brian Cain b2ae361329
Merge pull request #10586 from briancain/debian-systemd-networkd-dhcp-static-ips
Fixes #10585: Properly set DHCP for systemd-networkd ips
2019-01-11 16:22:09 -08:00
Brian Cain 65a7261853
Fixes #10585: Properly set DHCP for systemd-networkd ips
Prior to this commit, if a debian system requested an DHCP address using
systemd-network, Vagrant would ignore it and instead use the configured
IP from the virtualbox network action. This commit fixes that by instead
looking if DHCP was requested, and if so, use that option for an IP.
2019-01-11 10:19:37 -08:00
Chris Roberts cdd3e7578b Update version for dev 2019-01-09 13:32:09 -08:00
Chris Roberts 15adcf06cd Update download version to 2.2.3 2019-01-09 13:30:54 -08:00
Chris Roberts 37dc3dc648 Release v2.2.3 2019-01-09 13:25:17 -08:00
Brian Cain 9836806f76
Update CHANGELOG 2019-01-09 11:17:46 -08:00
Brian Cain 5d4c9ef8a7
Merge pull request #10513 from briancain/catch-invalid-version-errors-vagrant_cloud
Fixes #10509:  Catch InvalidVersion errors from vagrant_cloud client
2019-01-09 11:16:58 -08:00
Chris Roberts c7a4b05ae7
Merge pull request #10579 from chrisroberts/e-ruby-version
Update ruby version support to include 2.6
2019-01-09 10:46:57 -08:00
Chris Roberts a29273aa17 Update CHANGELOG 2019-01-09 10:46:26 -08:00
Chris Roberts 88793bc706
Merge pull request #10574 from ngyuki/wslpath
Use wslpath command for customized root on WSL
2019-01-09 10:45:36 -08:00
Chris Roberts d8491b7120
Merge pull request #10550 from pkliczewski/master
dependency: update net-ssh version
2019-01-09 10:45:07 -08:00
Chris Roberts 5445c6c79f Update ruby version support to include 2.6 2019-01-09 09:56:23 -08:00
ngyuki 380a1a01b7 Add test using wslpath command in vagrant/util/platform 2019-01-09 20:35:28 +09:00
Brian Cain a37f7a01b2
Update CHANGELOG 2019-01-08 15:41:56 -08:00
Brian Cain e1a13714c0
Merge pull request #10573 from briancain/show-box-version-on-up
Fixes #10339: Show box version during outdated check
2019-01-08 15:41:16 -08:00
Brian Cain 3ca29ff1e0
Merge pull request #10569 from hashicorp/f-updateFAQ-inet
add note to FAQ for internet requirement - license
2019-01-08 12:48:50 -08:00
Alvaro Miranda Aguilera f6f4364173
Update installation.html.md 2019-01-08 20:59:21 +01:00
Alvaro Miranda Aguilera 6cccea8143
Update installation.html.md 2019-01-08 20:56:04 +01:00
Brian Cain ab5e459ed2
Update CHANGELOG 2019-01-08 11:47:43 -08:00
Brian Cain 6b89324a9f
Merge pull request #10554 from iquiw/grep-fix-for-coreos
Fix grep command for network interface of CoreOS guest
2019-01-08 11:47:14 -08:00
ngyuki 924e87342b Use wslpath command for customized root on WSL 2019-01-09 03:59:40 +09:00
Brian Cain c55363412e
Fixes #10339: Show box version during outdated check
This commit updates the output Vagrant displays when checking if a box
is out of date by adding the version.
2019-01-08 10:31:10 -08:00
Chris Roberts 3111c7342a Update CHANGELOG 2019-01-07 16:51:52 -08:00
Chris Roberts abbb5f5ed5
Merge pull request #10571 from chrisroberts/fix/ssh-garbage-detection
Fix garbage detection within SSH communicator
2019-01-07 16:51:05 -08:00
Chris Roberts d87c645bd0 Fix garbage detection within SSH communicator
Fixes #10552
2019-01-07 16:20:56 -08:00
Brian Cain 05dcac11cc
Update CHANGELOG 2019-01-07 13:09:31 -08:00
Brian Cain a8b3d17e5c
Merge pull request #10570 from briancain/show-more-info-with-file-prov
Show source and destination locations with file provisioner
2019-01-07 13:08:48 -08:00
Chris Roberts c8cac957d1
Merge pull request #10564 from dduong42/patch-1
Fix a link to Virtualbox's documentation
2019-01-07 12:48:22 -08:00
Brian Cain b5db5c0156
Show source and destination locations with file provisioner
Prior to this commit, Vagrants output would only show that a file
provisioner was running, but had no detail as to what file was being
copied to where. This is especially confusing if a Vagrantfile has
multiple file provisioners. This commit updates that by showing the
source and destination of the file so that it's clearer what is being
copied and to where.
2019-01-07 11:43:27 -08:00
Alvaro Miranda Aguilera 9f38cd42e9
add note to FAQ for internet requirement - license
Vagrant requires internet access
2019-01-07 19:52:40 +01:00
Daniel Dương 829f9eceae
Fix a link to Virtualbox's documentation 2019-01-04 18:43:19 -02:00
Chris Roberts d84d9ee059
Merge pull request #10561 from anothertobi/update-docs
Add VirtualBox version 6.0.x to docs.
2019-01-04 07:55:05 -08:00
Tobias Nehrlich 54f30f6eeb
Add VirtualBox version 6.0.x to docs. 2019-01-04 11:44:29 +01:00
Chris Roberts 2af84265f1 Update CHANGELOG 2019-01-03 15:26:53 -08:00
Chris Roberts 023238b3d1
Merge pull request #10528 from chrisroberts/e-ps-elevated
Add support for running elevated commands using the powershell command
2019-01-03 15:25:56 -08:00
Chris Roberts 0e933f58eb Update CHANGELOG 2019-01-03 15:19:22 -08:00
Chris Roberts c7522b9114
Merge pull request #10529 from chrisroberts/e-rsync-chown
Add support for using the `--chown` flag with rsync when available.
2019-01-03 15:18:14 -08:00
Chris Roberts 74e5e31967 Update CHANGELOG 2019-01-03 13:53:19 -08:00
Chris Roberts 1f959e03cb
Merge pull request #10532 from chrisroberts/e-reboot
Add reboot option to shell provisioner
2019-01-03 13:52:19 -08:00
Chris Roberts 7fbcb88d82
Merge pull request #10539 from jalandis/disable-required-install_type-salt-option-windows
Disabled salt provision required install_type check on Windows
2019-01-03 13:44:05 -08:00
Chris Roberts 22ed57e9e5 Update CHANGELOG 2019-01-03 13:41:27 -08:00
Chris Roberts 7c1cb4220c
Merge pull request #10537 from jalandis/update-salt-version-in-bootstrap-script
Upgrade default Salt version from 2017.7.1 to 2018.3.3
2019-01-03 13:39:56 -08:00
Chris Roberts 4974fe3a33
Merge pull request #10557 from chrisroberts/f-checkpoint-tests
Update checkpoint client tests
2019-01-03 13:39:37 -08:00
Chris Roberts 4da035200f Update checkpoint client tests
Use `env.ui` for expectations instead of custom double. Fix upgrade
notification test and ensure upgrade notifications are sent to the
error channel.
2019-01-03 10:12:08 -08:00
Iku Iwasa 982534aaed Fix grep command for network interface of CoreOS guest 2019-01-04 00:25:35 +09:00
Piotr Kliczewski 0ad20f725b dependency: update net-ssh version
There is new net-ssh release [1] with a fix needed for vagrant-kubevirt.

Fixes: https://github.com/hashicorp/vagrant/issues/10421

[1] https://github.com/net-ssh/net-ssh/releases/tag/v5.1.0
2019-01-02 15:09:54 +01:00
Yaniv Kaul 68b3ca5a8b
ansible_ssh_host in the example is deprecated
Need to use ansible_host these days. See https://docs.ansible.com/ansible/2.3/intro_inventory.html deprecation note (it was deprecated in 2.0 apparently)
2018-12-31 18:02:33 +02:00
John Landis bd6fa11281
Disabled salt provision required install_type check on Windows where option is not supported. Added test case for salt provisioner config changes. 2018-12-23 11:39:58 -05:00
John Landis 19dc9fd921
Upgrade default Salt version from 2017.7.1 to 2018.3.3 2018-12-22 18:55:38 -05:00
Chris Roberts e735453422 Add reboot option to shell provisioner
Adds a `reboot` option which allows the guest to be rebooted after
the completion of a shell provisioning task. The guest must support
the `:reboot` capability. Like the `reset` option, the `reboot`
option may be provided without defining `inline` or `file` options
when a reboot may be required between other provisioners.

Fixes #8639
2018-12-21 15:50:59 -08:00
Chris Roberts cb3b8bd732 Add support for using the `--chown` flag with rsync when available.
Adds a new `rsync__rsync_ownership` option to rsync based synced folders
which will allow rsync to use the `--chown` flag if it is available. The
`rsync` and `rsync-auto` commands have a new `--rsync-chown` flag which
can be used to force the option on folders when running the commands.

Fixes #7329 #7332
2018-12-20 17:16:36 -08:00
Chris Roberts 1f565b8f27 Update CHANGELOG 2018-12-20 14:02:09 -08:00
Chris Roberts 9c33ffd3fa
Merge pull request #10527 from chrisroberts/f-configure-net-nm
Fix guest network configuration by properly extracting extra options
2018-12-20 14:00:30 -08:00
Chris Roberts e3cf74566c Add support for running elevated commands using the powershell command
This PR adds support for running command passed via the --command
flag as elevated tasks. The option is only valid for commands and
not when setting up a remote session. Logic has also been adjusted
for when communicator restrictions are applied and test coverage
has been added.
2018-12-20 11:30:25 -08:00
Chris Roberts 9f1e7d9895 Prevent nil dup as unsupported in 2.3 2018-12-20 07:43:43 -08:00
Chris Roberts 97c3ec961c Update CHANGELOG 2018-12-19 16:22:40 -08:00
Chris Roberts f4cb33e954
Merge pull request #10012 from Aloz1/add-host-voidlinux
Add void linux host support
2018-12-19 16:21:52 -08:00
Chris Roberts a4a98d97fc Fix guest network configuration by properly extracting extra options
Extra options are extracted from the machine configuration for the
network being configured to allow for customized network manager
behavior. The network entries must be filtered to remove non-network
entries (like port forwards) before accessing by index.

Fixes #9546
2018-12-19 16:08:47 -08:00
Chris Roberts 7f3e842bf7 Update CHANGELOG 2018-12-19 12:38:51 -08:00
Chris Roberts 4873d7879a
Merge pull request #10524 from chrisroberts/e-share-unset
Automatically answer yes when pruning SMB shares
2018-12-19 12:37:41 -08:00
Chris Roberts ac5b45445a Remove use of `system`. Add test coverage. 2018-12-19 12:19:22 -08:00
Chris Roberts 8ef1d372ae Add a few more updates to the CONTRIBUTING document
Include extra information within CLA section. Update PR lifecycle
steps to include CLA signing. Fix some small grammar things.
2018-12-19 10:12:41 -08:00
Chris Roberts 59b3ae38cc Add CLA information within CONTRIBUTING document 2018-12-19 10:01:22 -08:00
Chris Roberts ee2072ec53 Automatically answer yes when pruning SMB shares 2018-12-19 08:59:13 -08:00
Chris Roberts 3e8f4a5df4 Update CHANGELOG 2018-12-18 16:09:30 -08:00
Chris Roberts 8eeb48daf6
Merge pull request #10469 from jlduran/fix-network-static
FreeBSD: Fix rcvar in network_static templates
2018-12-18 16:08:27 -08:00
Chris Roberts 564f0163c3 Update CHANGELOG 2018-12-18 11:44:49 -08:00
Chris Roberts f527826f39
Merge pull request #10515 from chrisroberts/f-rsync-auto-clean
Prevent rsync-auto crashes
2018-12-18 11:43:44 -08:00
Chris Roberts 818d1d97ae Update rsync auto post command error handling to be more generic
Rescue and re-wrap any errors encountered when running the post
rsync capability. Rescue this exception type and notify of error
when encountered by rsync auto. Include test coverage.
2018-12-18 09:50:21 -08:00
hieptranquoc 480e992ea1 @ #10460 | vagrant rsync should restart when rsync find chown command error 2018-12-18 09:49:44 -08:00
hieptranquoc aa6908cc00 @ #10460 | fix vagrant rsync-auto is crashed 2018-12-18 09:49:21 -08:00
Chris Roberts a2a4883355 Update CHANGELOG 2018-12-17 16:15:29 -08:00
Chris Roberts 66938d20cf
Merge pull request #10512 from chrisroberts/f-hostnamectl-no-dbus
Validate hostnamectl command is in working state
2018-12-17 16:14:23 -08:00
Brian Cain eaad94635c
Update vagrant_cloud dep for Vagrant
This commit moves up the vagrant_cloud dependency to take advantage of
the new error VagrantCloud::InvalidVersion for the publish command
2018-12-17 14:42:12 -08:00
Brian Cain ca6cc140ff
Catch InvalidVersion errors from vagrant_cloud client
This commit adds a new rescue to the `publish` command for when the
client detects an invalid version prior to making the API request to
create that version.
2018-12-17 14:41:29 -08:00
Chris Roberts 95493d6c59 Validate hostnamectl command is in working state
When checking if the hostnamectl command should be used for configuring
the guest hostname, ensure the command returns a valid result. The
hostnamectl command relies on dbus and if dbus is not available the
command will simply fail.
2018-12-17 12:46:30 -08:00
Brian Cain 6bff374e79
Merge pull request #10502 from kant/patch-1
Minor fix on string #041
2018-12-13 14:42:33 -08:00
Darío Hereñú aae6e34e6f
Minor fix on string #041 2018-12-13 19:20:02 -03:00
Chris Roberts b3707afca0 Update CHANGELOG 2018-12-13 09:19:58 -08:00
Chris Roberts 2daafd9586
Merge pull request #10490 from chrisroberts/f-snapshot-behavior
Update behavior of `snapshot restore` and `snapshot pop`
2018-12-13 09:18:20 -08:00
Chris Roberts 480bb47e1d
Merge pull request #10496 from chrisroberts/e-ssh-config-file
Add support for config and remote_user to SSH options
2018-12-13 09:16:49 -08:00
Chris Roberts 03b06686e4 Update CHANGELOG 2018-12-13 09:16:03 -08:00
Chris Roberts 19025bb8c3
Merge pull request #10488 from chrisroberts/f-powershell-elevated
Only modify elevated username under specific conditions
2018-12-13 09:14:30 -08:00
Brian Cain e1db9a9263
Merge pull request #10500 from Brandon9598/patch-1
Update project_setup.html.md
2018-12-13 08:11:32 -08:00
Brandon9598 8e8bfd60a9
Update project_setup.html.md 2018-12-13 08:36:36 -05:00
Chris Roberts 90a5854684 Fill out ssh options config and remote_user
Include config option within ssh_config command output template. Default
remote_user value to set username value. Include existence check on
provided config value to ensure file is available. Update tests to
include coverage on all changes. Add new options to the docs.
2018-12-11 08:09:43 -08:00
Gavin Williams 0500f2b9b3 Add support for SSH config file to Rsync helper 2018-12-11 07:51:47 -08:00
Gavin Williams 9d72feb36c Add support for SSH config file to to 'vagrant ssh' command 2018-12-11 07:51:47 -08:00
Gavin Williams 122ef7307c Flesh out `:config` support.
Also noticed whilst testing that if the `ProxyCommand` uses `%r`, then
it fails with `unable to find remote user`, so added support for
`config.ssh.remote_user` aswell
2018-12-11 07:51:47 -08:00
Gavin Williams 87e38a0bed Remove 'config' from ssh.defaults, and instead setup in '.connect' 2018-12-11 07:51:47 -08:00
Gavin Williams 50a569747c Use 'be_falsey' matcher 2018-12-11 07:51:47 -08:00
Gavin Williams 87437317dc Add support for passing ssh config file in via config 2018-12-11 07:51:47 -08:00
Brian Cain 94fc57bce1
Merge pull request #10495 from briancain/specify-starter-box
Use specific Vagrant box in tutorial setup
2018-12-10 09:13:07 -08:00
Brian Cain 951902506f
Use specific Vagrant box in tutorial setup
This commit ensures that a proper box is used during the project setup
tutorial. Otherwise later down the road uesrs will run into Vagrant
saying that the box `base` doesn't exist.
2018-12-10 08:47:24 -08:00
Chris Roberts eeecd258f8 Update CHANGELOG 2018-12-07 16:30:42 -08:00
Chris Roberts 598d4254be
Merge pull request #10489 from chrisroberts/f-lots-o-smb
Only prepare 10 shares per command to prevent exceeding allowed command size
2018-12-07 16:29:56 -08:00
Chris Roberts f78ceb57a6 Update CHANGELOG 2018-12-07 16:29:36 -08:00
Chris Roberts 2c62ab9441
Merge pull request #10487 from chrisroberts/f-powershell-encode
Use Base64#strict_encode64 instead of Base64#urlsafe_encode64 for PowerShell
2018-12-07 16:28:37 -08:00
Chris Roberts 4696943ae6 Add new flag to cli docs 2018-12-07 16:26:13 -08:00
Brian Cain e4b028ffac
Update CHANGELOG 2018-12-07 16:25:44 -08:00
Brian Cain 2011e213c3
Merge pull request #10485 from briancain/introduce-experimental-feature-flag
Add experimental flag to guard development features
2018-12-07 16:25:10 -08:00
Chris Roberts c999e7c3d4 Update behavior of `snapshot restore` and `snapshot pop`
Both of these commands failed to default the options disabling
the provisioning from ignoring the sentinel file. This resulted
in different behavior than what was seen with the `up` and
`resume` commands which would only provision items with run set
to "always". This defaults the options to proper match the behavior
of `up` and `resume` to be consistent.

This also adds an extra `--no-start` flag to allow users to restore
a snapshot but not start the restored guest immediately.

Fixes #6752
2018-12-07 16:17:44 -08:00
Brian Cain 2783b121f9
Remove VALID_FEATURES constant 2018-12-07 13:52:02 -08:00
Brian Cain accabdd7ca
Warn users about unknown requested experimental features 2018-12-07 13:36:16 -08:00
Brian Cain 01ec72cac2
Introduce a local and global check for enabled experimental features 2018-12-07 13:30:50 -08:00
Chris Roberts 924fb97e8c Only prepare 10 shares per command to prevent exceeding allowed command size
When a large number of shares are defined it may cause the generated
command to exceed the maximum allowed length. To prevent this, only
allow 10 shares to be processed at a time.

Fixes #10483
2018-12-07 12:56:55 -08:00
Chris Roberts 24cd988d39 Only modify elevated username under specific conditions
Elevated commands can fail via winrm under certain conditions like
the machine name being changed. Detect this by checking for a known
exit code combined with known output included within stderr. If found,
attempt to re-execute the command using a machine prefixed username
if possible.
2018-12-07 12:11:17 -08:00
Brian Cain c07f99fe7d
Move feature flag checking into a single function 2018-12-07 10:59:21 -08:00
Brian Cain d551738bc7
Allow feature_enabled? to accept symbols 2018-12-07 10:50:34 -08:00
Brian Cain fc4ba7f420
Update to global_enabled? 2018-12-07 10:50:20 -08:00
Brian Cain 1a32930017
Add guard_with method for protecting ruby blocks 2018-12-07 10:28:21 -08:00
Brian Cain 611e3dce96
Use util methods in vagrant bin for experimental flag 2018-12-07 10:27:47 -08:00
Brian Cain 44fa134c48
Unfreeze valid features constant 2018-12-07 10:27:21 -08:00
Chris Roberts f7757b58d9 Update CHANGELOG 2018-12-06 16:35:37 -08:00
Chris Roberts 520d4d4da3
Merge pull request #10486 from chrisroberts/f-vbox-warn-req
Adjust requirement on warnings for VirtualBox NIC
2018-12-06 16:31:34 -08:00
Chris Roberts 8d36ba8864 Use Base64#strict_encode64 instead of Base64#urlsafe_encode64 for PowerShell
The #urlsafe_encode64 method complies with RFC 4648 but as the documentation
points out it uses the "URL and Filename Safe Alphabet". The #strict_encode64
method does not, and does not include linefeeds.

Fixes #10438
2018-12-06 16:13:48 -08:00
Chris Roberts 55a8649963 Adjust requirement on warnings for VirtualBox NIC
The changeset _did_ get included in the 5.2.22 release so adjust
the requirement to only warn on previous versions
2018-12-06 15:40:31 -08:00
Brian Cain 1bb6cb21cc
Update CHANGELOG 2018-12-06 15:10:41 -08:00
Brian Cain b6fb971350
Merge pull request #10482 from briancain/redirect-version-check-to-stderr
Fixes #10463: Display version update on stderr instead of stdout
2018-12-06 15:10:06 -08:00
Brian Cain 21b723ca06
Update CHANGELOG 2018-12-06 15:09:33 -08:00
Brian Cain 119f82d826
Merge pull request #10479 from briancain/ensure-tmp-dir-cleanup-package-cmd
Fixes #9593: Ensure temp dir for package command is cleaned up
2018-12-06 15:08:18 -08:00
Brian Cain 212f6ce8bb
Add experimental flag to guard development features
This commit introduces a special flag for enabling features that are not
ready for release. It can either be enabled by setting the
`VAGRANT_EXPERIMENTAL` flag to "1", or by setting it to a string of one
or more comma seperated values for specific features. It also adds a
couple of Vagrant developer focused methods for making it easier to
determine if the flag has been enabled, and if so, what features.
2018-12-06 09:03:49 -08:00
Brian Cain b6c6102e85
Redirect output to stderr instead of using Basic UI class
This preserves the bolding for the version check rather than using the
no format Basic class.
2018-12-05 12:19:51 -08:00
Brian Cain 4a7bff3325
Fixes #10463: Display version update on stderr instead of stdout
This commit updates the behavior of printing the checkpoint version
check for Vagrant. To allow users to filter out the message, it updates
the version check to go to stderr. It updates the UI class for printing
the version check to be a "basic" class, so that the message continues
to be the same color instead of a red error message.
2018-12-04 15:40:28 -08:00
Brian Cain b781331e88
Update CHANGELOG 2018-12-04 14:33:21 -08:00
Brian Cain 2038f2878c
Merge pull request #10470 from wolfgang42/snapshot-error
snapshot plugin: Raise error for bad subcommand.
2018-12-04 14:32:22 -08:00
Brian Cain 86e2b78997
Fixes #9593: Ensure temp dir for package command is cleaned up
Prior to this commit, the package actions would create a temp dir in
the process of packaging and compressing a Vagrant box. This commit
ensures that the temp dir is removed once the command has completed so
that it doesn't leave around lots of temp directories.
2018-12-04 11:07:53 -08:00
Brian Cain 153101d21b
Update CHANGELOG 2018-12-03 16:00:00 -08:00
Brian Cain d561116d16
Merge pull request #10474 from briancain/ensure-install_type-set-with-version
Fixes #10358: Add validation error in salt provider for certain options
2018-12-03 15:58:59 -08:00
Brian Cain 8f722402e5
Update CHANGELOG 2018-12-03 15:58:39 -08:00
Brian Cain 6531ed0970
Merge pull request #10468 from briancain/raise-error-if-provider-file-missing
Fixes #10432: Validate that provider file exists prior to upload
2018-12-03 15:57:50 -08:00
Brian Cain 85a137c1b5
Update CHANGELOG 2018-12-03 15:57:29 -08:00
Brian Cain 604f56b4f3
Merge pull request #10467 from briancain/validate-ignore-provider-installed
Fixes #10224: Clear our registered providers when validating configs …
2018-12-03 15:56:20 -08:00
Brian Cain 5fa3c5866c
Ensure tmp dir for validate is removed once command exits 2018-12-03 14:50:20 -08:00
Brian Cain 34b64ec247
Fixes #10358: Add validation error in salt provider for certain options
Prior to this commit, if you specified a `version` for the salt provider
but no `install_type` Vagrant would fail to pass the proper parameters
to the bootstrap install script. This commit fixes that by adding some
validation to the salt provider if `version` is specified but not
`install_type`. It also adds some extra context for certain config
validation error messages so that the user knows what option was
incorrect, rather than the message just referring to the option as
*this*.
2018-12-03 10:00:11 -08:00
Wolfgang Faust 4ec092f46d snapshot plugin: Raise error for bad subcommand.
Closes #9773.
2018-12-01 14:44:42 -05:00
Jose Luis Duran 5ab323733f
FreeBSD: Fix rcvar in network_static templates
The rcvar should be `defaultrouter` instead:

https://www.freebsd.org/doc/handbook/network-routing.html
2018-12-01 10:07:40 -02:00
Brian Cain 6d4d9b9304
Fixes #10432: Validate that provider file exists prior to upload
Prior to this commit, Vagrant would attempt to path expand a file that
didn't exist if it was left out of the passed in arguments and no
`--url` was used for external box uploading. This commit fixes that by
adding some additional validation for the passed in box file.
2018-11-30 14:13:45 -08:00
Brian Cain 69eacd2b73
Remove machine from initialize method 2018-11-30 11:03:05 -08:00
Brian Cain 68dda8f853
Fixes #10224: Clear our registered providers when validating configs with no provider
Prior to this commit, if you went to validate your Vagrantfile and
wanted to ignore the provider, Vagrant would still fail as it checks if
there are any registered providers that are installed and usable. This
commit mocks out all registered providers to bypass that for the
validate command so that Vagrant can just validate the config and ignore
any provider config blocks.
2018-11-30 10:54:16 -08:00
Chris Roberts e4a3eb5d14 Update vmware utility version 2018-11-28 10:19:06 -08:00
Chris Roberts 01aaf97cd1 Update version for dev 2018-11-27 09:49:31 -08:00
Chris Roberts 5e4f68f529 Update website version to 2.2.2 2018-11-27 09:49:16 -08:00
Chris Roberts 46388d80b6 Release v2.2.2 2018-11-27 09:48:18 -08:00
Chris Roberts ab850c335d Update CHANGELOG 2018-11-27 09:45:12 -08:00
Chris Roberts b886ec0b32
Merge pull request #10450 from chrisroberts/f-vbox-default-nic-type
Update default_nic_type implementation within VirtualBox provider
2018-11-27 09:41:33 -08:00
Chris Roberts d589aa9f81 Update default_nic_type implementation within VirtualBox provider
In some cases the E1000 NIC type is the only acceptable value. Since
defaulting causes breakages to existing boxes, leave the default value
as `nil` but check the VirtualBox version in use and print warning to
user if VirtualBox version is vulnerable and E1000 NIC types are
configured for use within defined network adapters.
2018-11-26 15:58:45 -08:00
Chris Roberts 45766ad00e
Merge pull request #10422 from hashicorp/circleci-website-build
add circleci website build
2018-11-16 12:18:54 -08:00
Alvin Huang 4f59d2b771 remove packer.json since CircleCI builds the site 2018-11-16 15:12:10 -05:00
Alvin Huang 9f8cbec6b4 add circleci website build
move circleci config to root
2018-11-16 15:12:06 -05:00
Chris Roberts f6d6bcf81d Update version for dev 2018-11-15 15:21:58 -08:00
Chris Roberts 30d2e52c46 Update website version to 2.2.1 2018-11-15 15:20:54 -08:00
Chris Roberts e905ab8c8c Release v2.2.1 2018-11-15 15:19:01 -08:00
Chris Roberts 0ff075c5d3
Merge pull request #10417 from chrisroberts/f-vbox6-import
Update VM import for VirtualBox 6
2018-11-15 14:53:30 -08:00
Chris Roberts f031ec4ce8 Add tests for VirtualBox driver version 6 2018-11-15 11:07:10 -08:00
Chris Roberts c5bc8aba46 Remove existing common tests to shared examples. Add custom import test. 2018-11-15 11:06:30 -08:00
Chris Roberts e86824e098 Move common virtualbox 5 driver tests into shared examples 2018-11-15 11:05:51 -08:00
Chris Roberts b8f5752a82 Update VM import for VirtualBox 6 driver
The dry run import with VirtualBox 6 no longer provides full paths
for disks. Extract base path from suggested settings file location
and use that to generate full path name using provided disk base
name.
2018-11-15 11:04:08 -08:00
Chris Roberts 1225114a15 Update CHANGELOG 2018-11-13 15:45:17 -08:00
Chris Roberts efbf99c451
Merge pull request #10409 from chrisroberts/e-vbox-ssh-port-detect
Update VirtualBox driver ssh_port helper
2018-11-13 15:44:15 -08:00
Chris Roberts 1bc0719438 Update CHANGELOG 2018-11-13 15:43:52 -08:00
Chris Roberts 7750d6182d
Merge pull request #10410 from chrisroberts/f-hyperv-net-typo
Fix typo in hyper-v network configuration detection script
2018-11-13 15:43:03 -08:00
Chris Roberts 7d10cad135 Update CHANGELOG 2018-11-13 15:22:53 -08:00
Chris Roberts 8f49e05ad4
Merge pull request #10406 from chrisroberts/e-hyperv-destroy
Disable automatic checkpoints prior to VM removal
2018-11-13 15:22:11 -08:00
Chris Roberts 0364f9b75e Update CHANGELOG 2018-11-13 15:21:49 -08:00
Chris Roberts 2272a0bfa7
Merge pull request #10404 from chrisroberts/e-hyperv-ver-check
Ignore errors when generating new VM configuration
2018-11-13 15:21:03 -08:00
Chris Roberts 9dd137633a Fix typo in hyper-v network configuration detection script 2018-11-13 15:11:04 -08:00
Chris Roberts 30473a4cb1
Merge pull request #10408 from lunchbag/jen/update-share-img
Update open graph image
2018-11-13 15:04:22 -08:00
Chris Roberts c7721f619b Update VirtualBox driver ssh_port helper
Be more restrictive when matching the port forward used for
SSH. Allow matching simply on the guest port, but also include
extra matching criteria for cases where multiple results may
be returned.
2018-11-13 15:04:12 -08:00
Jen 0ab7fc9ecc Update open graph image 2018-11-13 17:29:29 -05:00
Brian Cain 2db2797203
Update CHANGELOG 2018-11-13 14:26:21 -08:00
Brian Cain 608863809a
Merge pull request #10405 from briancain/fixup-inline-windows-trigger-run
Fixes #10393: Only use Shellwords on non-windows hosts
2018-11-13 14:25:27 -08:00
Chris Roberts 0ea4dcdc6e Disable automatic checkpoints prior to VM removal 2018-11-13 13:09:12 -08:00
Brian Cain 69b3b44505
Fixes #10393: Only use Shellwords on non-windows hosts
This commit updates how the trigger `run` inline option works by only
applying `Shellwords.split` to the inline command if it is going to be
run on non-Windows hosts. Otherwise pass the inline script directly to
be executed by Powershell.
2018-11-13 13:07:39 -08:00
Chris Roberts 83ed01869d Ignore errors when generating new VM configuration
The default error action is to stop. When generating the initial
VM configuration during import, if the Compare-VM command fails
it results in a generic error message. Instead the error should
be ignored so the source VM can be inspected and a useful error
message can be returned to the user.
2018-11-13 12:21:17 -08:00
Chris Roberts b2e682b0e3 Update CHANGELOG 2018-11-13 09:20:00 -08:00
Chris Roberts 7efd501fe8
Merge pull request #10399 from chrisroberts/e-comm-reset
Add communicator reset
2018-11-13 09:13:40 -08:00
Chris Roberts 23b2b0b6ad
Merge pull request #10400 from chrisroberts/e-i18n-lib
Update dependency constraint on i18n
2018-11-12 16:23:02 -08:00
Chris Roberts c4680ae6ee Update CHANGELOG 2018-11-12 16:22:43 -08:00
Chris Roberts 43f7a16baa
Merge pull request #10313 from lloesche/lloesche/fix_wsl_detection
Fix WSL detection for customized roots
2018-11-12 16:21:44 -08:00
Chris Roberts d179e5e117 Update dependency constraint on i18n 2018-11-12 15:49:16 -08:00
Chris Roberts 5045ff14cf Update CHANGELOG 2018-11-12 15:43:09 -08:00
Chris Roberts 90dee00809
Merge pull request #10390 from chrisroberts/e-powerup-handle-spaces
Update powerup to handle spaces properly in arguments
2018-11-12 15:41:20 -08:00
Chris Roberts 6b02914956 Update shell provisioner documentation
Properly order options alphabetically and include new option
for reset.
2018-11-12 15:36:21 -08:00
Chris Roberts 3ebe5b40e3 Add test coverage on new functionality 2018-11-12 15:36:21 -08:00
Chris Roberts 29880ccd1f Add option to shell provisioner to reset communicator 2018-11-12 15:36:21 -08:00
Chris Roberts afc138478d Add reset! method to winrm communicator 2018-11-12 15:36:21 -08:00
Chris Roberts 747dd9301b Add reset! to ssh communicator. Reduce number of ssh info prints. 2018-11-12 15:36:21 -08:00
Chris Roberts cfc3e9e398 Reset communicator after updating user groups 2018-11-12 15:36:21 -08:00
Chris Roberts c2aa1e207f Add a Communicator#reset! method 2018-11-12 15:36:20 -08:00
Brian Cain 11fe0a84d8
Merge pull request #10398 from briancain/fixup-puppet-doc
Remove `I` from documentation
2018-11-12 11:29:03 -08:00
Brian Cain 8b79aaf34c
Update CHANGELOG 2018-11-12 09:14:44 -08:00
Brian Cain a698188c12
Merge pull request #10389 from briancain/ssh-keyfile-paths-spaces-windows
FIXES #9870: Allow for windows path spaces with ssh utility
2018-11-12 09:14:01 -08:00
Brian Cain eff8f5e22b
Merge pull request #10394 from johanhammar/fix-typos
Fix typos
2018-11-12 08:56:37 -08:00
Brian Cain 8eec4fe6e4
Remove `I` from documentation 2018-11-12 08:45:12 -08:00
Johan Hammar 37a3d7113e Fix typos 2018-11-10 20:16:05 +01:00
Chris Roberts 40a7d97131 Update CHANGELOG 2018-11-09 16:27:33 -08:00
Chris Roberts f2c146d6d7
Merge pull request #10387 from chrisroberts/e-winrm-elevated
Prepend computer name to user when created scheduled tasks
2018-11-09 16:26:03 -08:00
Chris Roberts 4ff5291b89 Update powerup to handle spaces properly in arguments 2018-11-09 15:26:55 -08:00
Brian Cain f8bd2b3f82
Add test for private key paths with '%' characters 2018-11-09 10:46:22 -08:00
Brian Cain 80ac5aaf90
Use path as string rather than Pathname 2018-11-09 10:24:58 -08:00
Brian Cain fc0707202a
FIXES #9870: Allow for windows path spaces with ssh utility
Prior to this commit, if a windows path contained a space, the ssh
utility could not properly find the private key path and the ssh command
would fail. This commit adds some additional logic to the ssh utility to
check if a path contains '%', and if so, use the IdentityFile argument.
Otherwise it will default to passing in the private key file with '-i',
which can support paths with spaces.
2018-11-09 10:19:35 -08:00
Chris Roberts e8cee899a8 Update CHANGELOG 2018-11-08 14:40:33 -08:00
Chris Roberts e4cc769b9e
Merge pull request #10383 from chrisroberts/e-vbox-default-nic
Add support for specifying the default NIC type used for guest adapters
2018-11-08 14:39:35 -08:00
Chris Roberts c8f431cf44 Prepend computer name to user when created scheduled tasks
When running a shell provisioner elevated with winrm a scheduled
task is created to bypass permissions issues. If the name of the
computer has changed this may no longer work. To prevent errors
this PR updates the implementation to fetch the computer name
and prepends it to the username before creating the task.
2018-11-08 14:21:20 -08:00
Chris Roberts b7cff2de2b
Merge pull request #10382 from chrisroberts/e-docs-env-sort
Add missing environment variables
2018-11-07 16:02:00 -08:00
Chris Roberts d8bbc5ce09 Add support for specifying the default NIC type used for guest adapters
Provides support for defining the NIC type used for any guest adapter
which does not define an adapter type. This is defaulted to "virtio".
2018-11-07 15:53:46 -08:00
Chris Roberts 28f1e4f36e Update CHANGELOG 2018-11-07 10:13:29 -08:00
Chris Roberts 2808193a1a
Merge pull request #10368 from chrisroberts/f-box-load-meta
Fallback to Vagrantfile configuration when local metadata lookup fails
2018-11-07 10:12:29 -08:00
Chris Roberts 07ca8564ad Update CHANGELOG 2018-11-07 09:52:48 -08:00
Chris Roberts 7d90f532c4
Merge pull request #10379 from chrisroberts/e-vbox-6
Add support for VirtualBox 6.0
2018-11-07 09:51:59 -08:00
Chris Roberts fccc68a471 Add important non-VAGRANT_ prefixed environment variables 2018-11-07 09:38:40 -08:00
Chris Roberts 1bdde30a02 Sort environment variables by name 2018-11-07 08:07:33 -08:00
Chris Roberts 9d728682c4 Add vbox provider driver for 6.0 2018-11-06 16:50:17 -08:00
Chris Roberts de42681742 Inherit from common base since 5.1 driver has no changes 2018-11-06 16:50:17 -08:00
Brian Cain ceb1ec9a60
Update CHANGELOG 2018-11-06 09:26:31 -08:00
Brian Cain bcb6bf8acd
Merge pull request #10347 from briancain/add-timeout-for-ssh-info-hyperv
Fixes #10229: Add proper reboot capability for Windows guests
2018-11-06 09:25:36 -08:00
Brian Cain d2b7da065f
Add test for WinRMNotReady exceptions for ready? method 2018-11-05 14:14:50 -08:00
Brian Cain 796ff7b190
Remove logger from windows hostname cap 2018-11-05 14:12:16 -08:00
Brian Cain 251e0b1452
Update CHANGELOG 2018-11-05 13:26:25 -08:00
Brian Cain 57ca89011c
Merge pull request #10374 from briancain/move-login-warning
Move login command warning
2018-11-05 13:25:37 -08:00
Chris Roberts 8a16b41a10 Update CHANGELOG 2018-11-05 12:54:28 -08:00
Chris Roberts d5f3600c4b
Merge pull request #10366 from chrisroberts/f-hyperv-vlan
Remove module loading from vlan script
2018-11-05 12:53:33 -08:00
Chris Roberts 5b325e7276 Update CHANGELOG 2018-11-05 12:53:17 -08:00
Chris Roberts 11e73eef75
Merge pull request #10365 from chrisroberts/e-ssh-ed25519
Add support for ed25519 keys
2018-11-05 12:52:17 -08:00
Chris Roberts caae50c5e8 Update CHANGELOG 2018-11-05 12:51:58 -08:00
Chris Roberts 1885692f74
Merge pull request #10364 from chrisroberts/e-gem-dep-order
Update ordering of gem sources to ensure proper resolution
2018-11-05 12:50:26 -08:00
Chris Roberts 247f17c279 Update CHANGELOG 2018-11-05 12:50:05 -08:00
Chris Roberts d2d117471a
Merge pull request #10359 from chrisroberts/e-check-limits
Limit automatic box outdated checks to once per hour
2018-11-05 12:46:56 -08:00
Brian Cain b951c0e781
Move login command warning
This commit moves where the warning is for the login command so that it
only displays when the command is invoked, and not when the plugin is
loaded.
2018-11-05 11:24:09 -08:00
Brian Cain 0188d409d4
Add test for windows reboot cap 2018-11-02 16:34:57 -07:00
Brian Cain 377b900277
Only execute reboot check if guest communicator is ready 2018-11-02 16:33:36 -07:00
Chris Roberts 6b7063ef05 Update CHANGELOG 2018-11-02 15:26:09 -07:00
Brian Cain 142a6898bc
Add reboot cap for windows
This commit introduces a proper reboot cap for Windows guests. Once it
initiates a reboot on the guest, it calls out to the wait_for_reboot cap
to block on until the guest is finished rebooting.
2018-11-02 15:25:57 -07:00
Chris Roberts be6f683009
Merge pull request #7699 from legal90/refactor-network
provider/virtualbox: Refactor host-only network settings
2018-11-02 15:25:09 -07:00
Brian Cain 5ebb4cced5
Merge pull request #10361 from johnyserpa/patch-1
fix broken link to token
2018-11-02 15:18:23 -07:00
Chris Roberts 5add5c24fe Show formatted error message with address and netmask 2018-11-02 15:03:22 -07:00
Mikhail Zholobov d9d081199c
action/network: Validate IP settings, show human-readable error 2018-11-02 22:29:19 +01:00
Mikhail Zholobov a02aaa3195
action/network: Refactor the calculation of host-only adapter IP and DHCP settings 2018-11-02 22:28:49 +01:00
Chris Roberts c2cedc98c2 Update CHANGELOG 2018-11-02 14:10:40 -07:00
Brian Cain 007bf991d5
using vagrantcloud.com instead of app.vagrant.com
Co-Authored-By: johnyserpa <joao.serpapinto@gmail.com>
2018-11-02 21:10:24 +00:00
Chris Roberts d293e5dc08
Merge pull request #7693 from legal90/network_address
util/network_ip: Simplify #network_address helper
2018-11-02 14:08:49 -07:00
Chris Roberts 648be1369f Fallback to Vagrantfile configuration when local metadata lookup fails
The project local metadata file may contain invalid information to properly
lookup the configured box. This may occur if the file has been moved,
modified, or the backing box has been removed. In those cases, fall back
to the configuration defined in the Vagrantfile to load the box.
2018-11-02 13:59:53 -07:00
Chris Roberts 1ece44ca84 Remove module loading from vlan script 2018-11-02 10:42:28 -07:00
Chris Roberts 04579e0ac7 Add support for ed25519 keys
The net-ssh library supports ed25519 keys but only if the required
dependencies are available. This adds the required dependencies.
2018-11-02 09:24:50 -07:00
Brian Cain 54c8ebc31a
Fixes #10229: Add timeout for changing hostname on windows
Prior to this commit, if Windows was slow to reboot, Vagrant would fail
to find the right IP address to upload the wait_for_reboot script to.
This commit fixes this race condition by adding a timeout to ensure that
Vagrant can retry. It also properly catches an exception in the winrm
ready? method for checking if a guest is properly ready for
communications.
2018-11-02 09:23:00 -07:00
Chris Roberts 3daf3e532d Update ordering of gem sources to ensure proper resolution
In recent Rubies the first dependency to satisfy the constraint will
be used regardless if higher versions are available in subsequent
sources. Move custom source to start of list when resolving plugins
to provide desired behavior.
2018-11-02 09:14:27 -07:00
Johny Serpa eba487a345
fix broken link to token
Link to generate token is broken. Fixed it.
2018-11-01 19:57:34 +00:00
Brian Cain 872c3c957d
Merge pull request #10357 from briancain/add-note-about-install-type-salt
Add note about install_type for version
2018-11-01 10:04:04 -07:00
Chris Roberts 976320ec06 Limit automatic box outdated checks to once per hour 2018-11-01 09:45:11 -07:00
Brian Cain 0dd3f57e81
Merge pull request #10346 from hashicorp/f-updateVMWareDocsBox
Update vmware_desktop in boxes.html.md
2018-11-01 09:39:25 -07:00
Brian Cain 1a0b014ef7
Add note about install_type for version 2018-11-01 08:51:04 -07:00
Brian Cain a25caf1d92
Merge pull request #10355 from briancain/update-salt-version-docs
Update salt provisioner docs
2018-10-31 12:58:40 -07:00
Brian Cain 8a07e731af
Update salt provisioner docs 2018-10-31 11:31:50 -07:00
Brian Cain 6f2ce24325
Update CHANGELOG 2018-10-31 09:09:20 -07:00
Brian Cain 338827e382
Merge pull request #10351 from briancain/ignore-provider-config-on-validate
Fixes #10224: Allow validation of config while ignoring provider
2018-10-31 09:08:34 -07:00
Brian Cain 6051f3598e
Fixes #10224: Allow validation of config while ignoring provider
This commit adds a new flag to the `vagrant validate` command which
allows users to completely ignore the provider block of a config file.
This is useful for when you are running `vagrant validate` in CI and
don't want to install a valid provider to check the syntax of your
Vagratnfile. When the flag is invoked, a warning will be displayed
saying that the provider block will be ignored and not validated.
2018-10-30 13:37:22 -07:00
Alvaro Miranda Aguilera 93fc675ad5
Update boxes.html.md 2018-10-29 19:26:34 +01:00
Brian Cain 716a5f1501
Merge pull request #10343 from glenvillef/glenvillef
Grammar corrections on web pages
2018-10-29 08:45:57 -07:00
Chris Roberts df874adf69
Merge pull request #10341 from chrisroberts/e-docs-update
Update vagrantfile documentation content to use list
2018-10-29 08:29:44 -07:00
Mikhail Zholobov 74de13cae5
util/network_ip: Simplify #network_address helper
Allow to use IPv6 net masks in string notation.
2018-10-28 21:17:43 +01:00
Glenville Fanoo (ZA) cdc0e1c11c
Grammer: corrected 2018-10-27 12:53:02 +02:00
Glenville Fanoo (ZA) e4a7b932fc
Grammer: corrected 2018-10-27 09:38:13 +02:00
Chris Roberts 7a725d7424 Update vmware utility version for website 2018-10-26 17:06:57 -07:00
Chris Roberts 32dbb6185a Update vagrantfile documentation content to use list 2018-10-26 15:32:51 -07:00
Chris Roberts 22119e157b Update CHANGELOG 2018-10-25 09:02:24 -07:00
Chris Roberts 58e6cbb01d
Merge pull request #10332 from chrisroberts/e-hyperv-pwsh-vr
Prevent exception from raising on hyper-v check
2018-10-25 09:01:26 -07:00
Chris Roberts ca81f9d6cb Prevent exception from raising on hyper-v check 2018-10-24 17:06:47 -07:00
Brian Cain ed310a954b
Update CHANGELOG 2018-10-24 16:20:39 -07:00
Brian Cain 580bcaebb0
Merge pull request #10311 from briancain/DOCKER-VM-FOLDER-MOUNT
Deterministic host VM synced folder location for Docker provider
2018-10-24 16:19:41 -07:00
Brian Cain 1f9cec0fba
Update CHANGELOG 2018-10-24 15:58:36 -07:00
Brian Cain f524a191e1
Merge pull request #10330 from briancain/fall-back-on-ifdown-ifup-tools-hostname
Reliably restart Debian and Ubuntu guests networking on setting hostname
2018-10-24 15:53:11 -07:00
Brian Cain a1bb7b837a
Use semicolon over ampersand to separate commands 2018-10-24 15:27:33 -07:00
Brian Cain e8c6916ebc
Restart each interface if systemd-networkd or networkmanager is not used
This commit is a workaround due to how older debian and ubuntu systems
fail to properly restart networking. Instead of relying on the init
scripts or ifup/down tools to restart each interface, this commit
instead restarts each interface individually
2018-10-24 11:34:38 -07:00
Brian Cain 1761e65f26
Fixes #9763 #10300: Fall back on ifdown/ifup tools for network restart
This commit adds some additional logic that falls back to using the
ifdown/ifup tools to restart networking. On Ubuntu 14.04, the init
script was designed to always fail to restart newtorking, so it needs
to use the ifdown/up tools instead. This commit will use the networking
init script as a last resort to restart networking, assuming other
commands haven't broken networking already.

https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/1301015
2018-10-23 14:47:12 -07:00
Brian Cain 6b34f3655a
Update CHANGELOG 2018-10-23 09:25:33 -07:00
Brian Cain 238a46299b
Merge pull request #10326 from briancain/add-automount-vbox
Fixes #10016: Add `automount` flag if specified with synced_folder
2018-10-23 09:24:49 -07:00
Brian Cain 7c06950e43
Ensure true or false for automount option 2018-10-23 09:00:55 -07:00
Brian Cain 6d0dfb2690
Fixes #10016: Add `automount` flag if specified with synced_folder
This commit adds a new option to virtualbox synced_folders called
`automount`, where if set to true, will supply the `--automount` flag to
virtualbox.
2018-10-22 15:45:32 -07:00
Chris Roberts 5ac79d2821 Update CHANGELOG 2018-10-19 16:00:39 -07:00
Chris Roberts b0fc33e9b7
Merge pull request #10321 from chrisroberts/f-ssh-comm-output
Prevent overly verbose output from SSH communicator
2018-10-19 15:59:01 -07:00
Chris Roberts 8562daf85e Prevent overly verbose output from SSH communicator
If the type of error changes on retry the messages will effectively
spam the user display with alternating messages. Log each message
sent and only re-display each message once within 10 seconds.
2018-10-19 15:18:03 -07:00
Brian Cain 5f5d874997
Update CHANGELOG 2018-10-19 14:11:06 -07:00
Brian Cain 9fab454bd5
Merge pull request #10319 from briancain/username-prompt-smb
Fixes #9591: Allow for 'default' smb_username if set
2018-10-19 14:09:48 -07:00
Brian Cain 65651178cd
Fixes #9591: Allow for 'default' smb_username if set
Prior to this commit, Vagrant would prompt for smb username and password
every time, even if only smb_username was defined. This commit changes
that by allowing a "default" username from the Vagrantfile, with the
option of overriding it.
2018-10-19 13:26:18 -07:00
Brian Cain 28c4940969
Update CHANGELOG 2018-10-18 09:02:52 -07:00
Brian Cain e54c9b22ef
Merge pull request #10301 from briancain/debian-fixup-hostname-change
Fixes #9763, #10300: Split out how hostname is set with Debian hosts
2018-10-18 08:57:29 -07:00
Brian Cain a1fa319f7e
Merge pull request #10315 from briancain/update-ruby-again
Bump ruby to 2.5.3
2018-10-18 08:49:32 -07:00
Brian Cain 4489b80931
Bump ruby to 2.5.3 2018-10-18 08:17:02 -07:00
Lukas Lösche 73cb4b5b42
Fix WSL detection for customized roots 2018-10-18 15:13:18 +02:00
Brian Cain 94bb50fa7e
Add test for syncing folders with docker provider 2018-10-17 14:14:27 -07:00
Brian Cain 52c04909d5
Merge pull request #10310 from briancain/update-ruby-for-travis
Update ruby to latest for travis tests
2018-10-17 12:42:42 -07:00
Brian Cain 31fabc94f7
Update ruby to latest for travis tests 2018-10-17 12:27:20 -07:00
Martin Jonas 238338d803
Deterministic host VM synced folder location for Docker provider to prevent broken sync after host VM shutdown
Fix for #10282
2018-10-17 11:28:24 -07:00
Brian Cain 2ce62cad65
Merge pull request #10308 from 5uper5hoot/patch-1
Small typo fix
2018-10-17 08:19:24 -07:00
Peter Schutt 78c7549b1b
Small typo fix 2018-10-17 22:12:27 +10:00
Chris Roberts ae7d2bed9d Update version for dev 2018-10-16 15:45:30 -07:00
Chris Roberts 6e37e49708 Update website version 2.2.0 2018-10-16 15:42:23 -07:00
Chris Roberts 9c835d823f Release v2.2.0 2018-10-16 15:39:34 -07:00
Brian Cain f20ab1ab39
Update CHANGELOG 2018-10-16 15:20:35 -07:00
Brian Cain 23de7f0898
Merge pull request #10148 from briancain/add-cloud-command
Introduce `vagrant cloud` subcommand to Vagrant
2018-10-16 15:19:58 -07:00
Brian Cain 15fb2b729d
Remove #Hash.compact for ruby 2.3 compatibility 2018-10-16 14:41:31 -07:00
Chris Roberts e595403419
Merge pull request #10304 from chrisroberts/f-hyperv-config
Add missing hyperv provider configuration option
2018-10-16 14:19:53 -07:00
Chris Roberts 2b157fc9be Add missing hyperv provider configuration option 2018-10-16 13:47:32 -07:00
Brian Cain 6443fe7109
Merge pull request #10302 from nqb/patch-1
Add details and fix typo for run: "never" option
2018-10-16 13:23:34 -07:00
Nicolas Quiniou-Briand 8293b763bd
Add details and fix typo for run: "never" 2018-10-16 15:36:40 -04:00
Brian Cain 0c5d55e69c
Fixes #9763, #10300: Split out how hostname is set with Debian hosts
Prior to this commit, the hostname was set with one big bash script and
attempted to determine what tools are available. This commit changes
that by splitting out that tool check on the Vagrant side of things with
the GuestInspection class, and adds back restarting networking to get a
DHCP lease with the change rather than using `dhclient`. This pattern
matches how hostnames are set in the redhat capability.
2018-10-16 12:00:25 -07:00
Brian Cain b92b1ba0bb
Add `cloud` command to bash completion 2018-10-12 09:49:49 -07:00
Brian Cain b1b829f69d
Fix missing `end` in errors class 2018-10-12 09:16:36 -07:00
Brian Cain 5225b48e00
Fixup cloud cli website documentation 2018-10-12 09:07:12 -07:00
Brian Cain 42c01f241c
Mark password as sensitive in logs 2018-10-12 09:07:12 -07:00
Brian Cain f1bae9f1eb
Remove level conditional for RestClient logging 2018-10-12 09:07:12 -07:00
Brian Cain adefbbaf6e
Scrub Vagrant Cloud tokens from RestClient logger 2018-10-12 09:07:12 -07:00
Brian Cain e8115a4389
Update based on second round of feedback 2018-10-12 09:07:12 -07:00
Brian Cain d8ec19faa8
Fixup: Update vagrant cloud command PR with feedback 2018-10-12 09:07:12 -07:00
Brian Cain e67dac0dbb
Alias `vagrant login` command 2018-10-12 09:07:12 -07:00
Brian Cain 9b385df4ec
Fix comment formatting 2018-10-12 09:07:12 -07:00
Brian Cain 3c45acc35f
Continue if entity already exists with publish command 2018-10-12 09:07:12 -07:00
Brian Cain 83bd592e30
Introduce curl helper and uploader classes
This commit introduces a new uploader class for uploading files and
splits up some commonly used functionality between it and the downloader
class into a curl helper library.
2018-10-12 09:07:10 -07:00
Brian Cain e70b871660
Introduce `cloud` command
This commit adds a new command to Vagrant called `cloud`. It handles any
and all interactions with the external service Vagrant Cloud.
2018-10-12 09:06:00 -07:00
Chris Roberts dd3d6c7cf2 Extend assert retries to allow for slow setup 2018-10-11 13:00:44 -07:00
Chris Roberts 9e4a3ee9d0 Update CHANGELOG 2018-10-11 10:49:40 -07:00
Chris Roberts 95fad3a8e3
Merge pull request #10259 from hoatle/bugs/#10258-vagrant_ansible_local_inventory
@ #10258 | BUG: should not create /tmp/vagrant-ansible/inventory/vagrant_ansible_local_inventory/vagrant_ansible_local_inventory
2018-10-11 10:48:27 -07:00
Brian Cain 506f87cf9c
Update CHANGELOG 2018-10-11 10:32:49 -07:00
Brian Cain 06070429c2
Merge pull request #10291 from briancain/create-proper-tmp-dir-rsync
Fixes #10289: Create proper tmp dir for ControlPath
2018-10-11 10:31:43 -07:00
Brian Cain cc14b43a96
Ensure `tmpdir` is loaded for rsync helper class 2018-10-11 09:57:20 -07:00
Brian Cain cb0bd89ae1
Fixes #10289: Create proper tmp dir for ControlPath
Prior to this commit, when creating the ControlPath tmp dir for
socket path, Vagrant would simply rely on `rand(1000)` for making unique
dirs for rsyncing files which could result in collisions. This commit
updates that be properly using `Dir.mktmpdir` with a `vagrant-rsync-`
prefix.
2018-10-11 09:51:03 -07:00
Chris Roberts 56aa5860cb
Merge pull request #10288 from chrisroberts/e-win-pageant-doc
Add information on using pageant with ssh
2018-10-11 08:40:48 -07:00
Chris Roberts 55fbc30fca Add information on using pageant with ssh
Fixes #10195
2018-10-10 17:06:26 -07:00
Chris Roberts 3b100d0781 Update CHANGELOG 2018-10-10 16:39:09 -07:00
Chris Roberts a841a75a78
Merge pull request #10279 from chrisroberts/e-local-encoded
Provide rgloader for project local plugins
2018-10-10 16:38:09 -07:00
Chris Roberts 1c480880f1 Add test coverage of local rgloader creation 2018-10-10 10:30:30 -07:00
Chris Roberts 006cea45e3 Provide rgloader for project local plugins 2018-10-09 16:27:47 -07:00
Chris Roberts 9333e54990 Update CHANGELOG 2018-10-09 14:49:09 -07:00
Chris Roberts d7b5922378
Merge pull request #10275 from chrisroberts/e-hyperv-admin
Update Hyper-V admin check
2018-10-09 14:48:13 -07:00
Chris Roberts ae6ff4256b Update CHANGELOG 2018-10-09 14:47:53 -07:00
Chris Roberts 080dd748ef
Merge pull request #10265 from chrisroberts/f-win-chktyp
Only configure CheckpointType if available to be configured.
2018-10-09 14:47:15 -07:00
Chris Roberts a7a55398fe Update CHANGELOG 2018-10-09 14:46:58 -07:00
Chris Roberts 7241bd9fda
Merge pull request #10264 from chrisroberts/f-win-autochk
Wrap automatic checkpoint enable to prevent inadvertent execution
2018-10-09 14:46:04 -07:00
Chris Roberts 4742c6ae2a Update CHANGELOG 2018-10-09 14:45:07 -07:00
Chris Roberts 93c2f0f497
Merge pull request #10263 from chrisroberts/e-winrm-extensions
Add winrm and upload commands
2018-10-09 14:42:54 -07:00
Chris Roberts ba0f0fbcab Default destination to basename of clean source 2018-10-08 15:29:55 -07:00
Chris Roberts 67bb5d2e6c Update Hyper-V admin check 2018-10-08 14:39:40 -07:00
Chris Roberts 49a9ae4bd9 Remove current communicator name from error text 2018-10-08 14:30:11 -07:00
Chris Roberts 3181b5c1f9 Ensure winrm helper is loaded for command 2018-10-08 14:28:52 -07:00
Chris Roberts d81abc1245 Fix active machine check to use common types when setting arguments 2018-10-08 14:22:32 -07:00
Chris Roberts 412290828b Fix trailing quotes in source path 2018-10-08 14:18:30 -07:00
Brian Cain 23f98f9a15
Merge pull request #10273 from briancain/add-more-ruby-trigger-context-docs
Add more information about Ruby trigger option
2018-10-08 10:51:55 -07:00
Brian Cain af91b3bb2f
Add more information about Ruby trigger option
This commit provides a bit more context to using the new Ruby trigger
option.
2018-10-08 10:30:29 -07:00
Brian Cain 9ee153802a
Update CHANGELOG 2018-10-08 09:03:13 -07:00
Brian Cain 5daa25db80
Merge pull request #10267 from briancain/ruby-trigger-option
Fixes #9840: Introduce `ruby` option for trigger
2018-10-08 09:02:17 -07:00
Brian Cain f4d618eb58
Fixes #9840: Introduce `ruby` option for trigger
This commit introduces a new option to the core trigger feature: `ruby`.
It can be defined to run ruby code when the trigger is configured to
fire. If you give the ruby block an env and machine argument, the
defined ruby code can use those variables internally.
2018-10-05 12:53:41 -07:00
Chris Roberts 88469d99f7 Only configure CheckpointType if available to be configured. 2018-10-04 15:24:05 -07:00
Chris Roberts 9c1ab2bd9f Wrap automatic checkpoint enable to prevent inadvertent execution 2018-10-04 15:16:58 -07:00
Chris Roberts 904a712838 Provide correct RDP information within configuration information
Dynamically generate RDP information when applicable via provider
if supported. When no RDP port is provided ignore RDP in config
and omit from output.
2018-10-04 14:41:10 -07:00
Chris Roberts a4231d630a Update CHANGELOG 2018-10-04 13:39:24 -07:00
Chris Roberts 64987daf06
Merge pull request #10255 from chrisroberts/e-base-mac-vbox
Allow automatic mac address assignment with virtuabox provider
2018-10-04 13:38:08 -07:00
Chris Roberts 48d358adcb Add winrm and upload commands 2018-10-04 13:26:41 -07:00
Brian Cain c6a0793cc3
Merge pull request #10262 from jeff-jk/machine-settings-doc-update
Add :windows to config.vm.guest in machine settings doc
2018-10-03 16:46:47 -07:00
jeff-jk 141bcc03f5 :windows should be a symbol in machine_settings doc
This should just be a symbol :windows rather than a string ":windows"
2018-10-03 17:36:24 -06:00
jeff-jk f1f4003fa9 Add :windows to config.vm.guest option
This commit updates the documentation so that it is more clear that Windows guests need to change the `config.vm.guest` option along with the `config.vm.communicator` option.
2018-10-03 15:47:25 -06:00
hoatle cae2119c0f @ #10258 | BUG: should not create /tmp/vagrant-ansible/inventory/vagrant_ansible_local_inventory/vagrant_ansible_local_inventory 2018-10-02 16:21:15 +07:00
Chris Roberts 648e0ddeaa Explicitly define driver version used for tests 2018-10-01 11:51:14 -07:00
Brian Cain 6aedc66c1c
Update CHANEGLOG 2018-10-01 11:08:35 -07:00
Brian Cain 184d114374
Merge pull request #10242 from briancain/IGNORE-BOX-VAGRNANTFILE
Add config option `ignore_box_vagrantfile`
2018-10-01 11:07:28 -07:00
Chris Roberts 85dc0ebec9 Allow automatic mac address assignment with virtuabox provider 2018-10-01 11:05:28 -07:00
Chris Roberts 11b0d58fa0 Include communicator on call 2018-10-01 08:43:49 -07:00
Brian Cain 7798add296
Ensure log is only printed if box has Vagrantfile 2018-10-01 08:39:46 -07:00
Brian Cain 5520cf65d6
Add warning if Vagrantfile inside box is ignored 2018-09-28 16:44:50 -07:00
Brian Cain 2c7c38e3bb
Merge pull request #10250 from briancain/fix-old-box-url
Update old URL for box_url example
2018-09-28 08:42:20 -07:00
Brian Cain 4060722ea1
Update old URL for box_url example 2018-09-28 08:31:18 -07:00
Chris Roberts 1797798760 Fix module name 2018-09-28 07:59:39 -07:00
Chris Roberts 976149b9a4
Merge pull request #10247 from hashicorp/je.fix-download-tracking
Fix download tracking analytics events
2018-09-27 17:49:19 -07:00
Jeff Escalante d4cf8b088e fix download tracking analytics events 2018-09-27 20:00:06 -04:00
Chris Roberts b5cb5f300b
Merge pull request #10243 from chrisroberts/e-vmware
Website updates for VMware
2018-09-26 14:02:01 -07:00
Chris Roberts f7f83faacd Website updates for VMware 2018-09-26 13:27:49 -07:00
Brian Cain f6ae328346
Add test for ignore_box_vagrantfile option 2018-09-26 10:31:55 -07:00
Brian Cain 424f49b919
Simplify config option to ignore box vagrantfile 2018-09-26 10:31:41 -07:00
Alex Wu a45e62cacd
fix the import issue when 'box_ignore_box_vagrantfile' is set, the box object should never be null. 2018-09-26 10:10:47 -07:00
Alex Wu 710b8da953
add config option 'box_ignore_box_vagrantfile' to ignore the Vagrantfile packaged in the box. 2018-09-26 10:10:47 -07:00
Alex Wu 282c7341c9
add a option to ignore the vagrantfile packaged with the box 2018-09-26 10:10:45 -07:00
Brian Cain 0699323da2
Update CHANGELOG 2018-09-25 13:54:24 -07:00
Brian Cain 5f56f0c8b1
Merge pull request #10223 from chrisroberts/e-rhel-nmsysd
Update restart logic in redhat change_host_name cap
2018-09-25 13:53:41 -07:00
Brian Cain 5d877c0e2a
Update CHANGELOG 2018-09-25 10:46:56 -07:00
Brian Cain f6ac70e86e
Merge pull request #10232 from briancain/clean-halt-trigger
Add abort option to core triggers
2018-09-25 10:45:47 -07:00
Brian Cain 58ebd52f99
Add abort option to core triggers
This commit adds a new option `abort`, which when configured, will exit
the Vagrant process completely. If set to `true`, it will exit cleanly
with exit code 0. Otherwise, the exit code can be configured.
2018-09-25 09:40:36 -07:00
Brian Cain 36582ef1b1
Update CHANGELOG 2018-09-24 15:18:07 -07:00
Brian Cain 99be58c1e5
Merge pull request #10235 from chregu/fix-sudoers-osx
Fix the broken sudoers file for OS X
2018-09-24 15:14:34 -07:00
Christian Stocker f44b98238c
Fix the pretty broken sudoers file for OS X 2018-09-24 23:39:01 +02:00
Chris Roberts 8fd05fe3c1 Use `command -v` for checks in all inspection helpers. Fix stubs in tests. 2018-09-21 09:19:40 -07:00
Chris Roberts bc217d5e57 Update redhat change host name capability tests for systemd/NetworkManger updates 2018-09-20 16:46:45 -07:00
Chris Roberts ff021fcab4 Update redhat change host name capability to support systemd
Update capability to use guest inspection module for determining
correct actions to execute. When systemd is in use restart the
correct active service, either NetworkManager or networkd. Default
to using the original service restart when systemd service is not
found.
2018-09-20 16:44:08 -07:00
Chris Roberts fb5fc0e657 Update guest inspection utility module
Use sudo option for communicator test command instead of inline sudo
to properly use configured sudo value. Use command for checking
availability of hostnamectl. Use is-active for determining if a
service is being actively managed by systemd.
2018-09-20 16:42:39 -07:00
shotop a12b09b098 add specs around network restart logic 2018-09-20 15:28:37 -07:00
Joe Doss 86ab4533b1 Fix the test to check for systemctl restart NetworkManager.service too. 2018-09-20 15:28:37 -07:00
Joe Doss 19aa9578c7 Exit 1 if we cannot set the hostname. 2018-09-20 15:28:37 -07:00
Joe Doss c14a4a09f7 Switch if statements, check for systemctl, and switch to is-active. 2018-09-20 15:28:37 -07:00
Joe Doss 94954739b5 Simplified if statements. 2018-09-20 15:28:37 -07:00
Joe Doss 80006251f4 Add in logic to restart NetworkManager if it is enabled. 2018-09-20 15:28:36 -07:00
Brian Cain 7402823ad0
Merge pull request #10222 from zwass/patch-1
Update Docker containerization docs
2018-09-20 14:30:18 -07:00
Zachary Wasserman 4a0628afbd
same for mac, linux and windows 2018-09-20 17:11:56 -04:00
Zachary Wasserman 995c7933b3
Update Docker containerization docs
The docs indicate that most systems must use a VM for containerization. This is no longer the case as Docker For Mac now uses HyperKit.

See https://docs.docker.com/v17.12/docker-for-mac/docker-toolbox/
2018-09-20 13:17:58 -04:00
Brian Cain 97d343b0ab
Update CHANGELOG 2018-09-20 09:20:08 -07:00
Brian Cain f3dcb7655b
Update CHANGELOG 2018-09-20 09:19:18 -07:00
Brian Cain a4d5ee6ac1
Merge pull request #10215 from briancain/FIX-SALT-PILLAR
Salt pillar configuration on Windows guests
2018-09-20 09:17:32 -07:00
Brian Cain 3b7e37a2ed
Merge pull request #10221 from briancain/DOCKER-REPO-GIT
Docker provider build from repo
2018-09-20 09:16:22 -07:00
Brian Cain d471932a4e
Update website about required docker params 2018-09-19 10:54:14 -07:00
Brian Cain 4612619dc4
Fixup docker config update 2018-09-19 10:52:59 -07:00
Brian Cain 29128e73b9
Remove old changelog addition 2018-09-19 10:52:42 -07:00
Brian Cain aecfc45eab
Add note about required docker config options 2018-09-19 10:38:40 -07:00
Oleksiy Protas 166fe374b6
More explicit logging and 'dockerfile' option support 2018-09-19 10:25:37 -07:00
Oleksiy Protas cbc69f5158
Build from git operation for docker 2018-09-19 10:24:09 -07:00
Oleksiy Protas de6a1794c7
Config, validation and test 2018-09-19 10:24:09 -07:00
Oleksiy Protas 8d1b5fc1c9
Docu changes for building Docker images from git 2018-09-19 10:24:05 -07:00
Brian Cain 7c7a2ed465
Update CHANGELOG 2018-09-19 09:04:39 -07:00
Brian Cain c3c7ad4ea2
Merge pull request #10218 from briancain/fix-env-vars-puppet-windows
Fixes #8315: Properly set env variables for puppet provisioner
2018-09-19 09:04:01 -07:00
Brian Cain b19e891bab
Update CHANGELOG 2018-09-19 09:02:50 -07:00
Brian Cain 5834b1ca70
Merge pull request #10219 from briancain/SMB-PASSWORD-CHARS
Allow special characters in SMB password field
2018-09-19 09:02:08 -07:00
Brian Cain 3ed4ab7022
Update CHANGELOG 2018-09-19 09:01:44 -07:00
Brian Cain b580268730
Merge pull request #10220 from briancain/FIX-PATH-WARNING-WINDOWS
Ensure file paths are identical when checking for cwd
2018-09-19 09:01:09 -07:00
Brian Cain dac78eb626
Add test for identical file paths 2018-09-18 14:15:34 -07:00
slackfan 59ecf95b0d
Remove unnessary import
Signed-off-by: Alexander Fischer <github@ordnungsdienst.org>
2018-09-18 13:56:18 -07:00
slackfan e547b26309
Don't compare paths by String
The implemented String comparison is misleading on Windows as it does not consider that paths on Windows are case insensitive

Signed-off-by: Alexander Fischer <github@ordnungsdienst.org>
2018-09-18 13:56:17 -07:00
Brian Cain 5ebb548be9
Add test for SMB mount_shared_folder function
This commit ensures that the command that adds the smb username and
password properly quotes the password given by the user.
2018-09-18 13:38:57 -07:00
John Rizzo b7d702ab5f
Update mount_shared_folder.rb
This change allows special characters in the password such as ) which will cause cmdkey to fail without the quotes.
2018-09-18 13:34:32 -07:00
Brian Cain 06b3268b6f
Fixes #8315: Properly set env variables for puppet provisioner
Prior to this commit, the puppet provisioner would not properly set its
environment variables, if any were configured in the Vagrantfile. This
commit separates those properly with semicolons when calling out to
puppet apply.
2018-09-18 10:09:01 -07:00
Brian Cain 96a00ad692
Include test for get_pillar salt function 2018-09-17 14:32:17 -07:00
mtkennerly 38175f93c6
Specify Salt pillar dependency on PowerShell 3.0 due to --% syntax. 2018-09-17 14:20:34 -07:00
mtkennerly 5c50c50d73
Fix #8328: Use special quote and backslash formatting for Windows when setting Salt pillar. 2018-09-17 14:20:31 -07:00
Brian Cain 89a21f0f47
Update CHANGELOG 2018-09-17 11:48:11 -07:00
Brian Cain 31689b6032
Merge pull request #9054 from tom-mi/master
Add completion for snapshot names for vagrant snapshot restore|delete
2018-09-17 11:47:32 -07:00
Brian Cain 07a2bc4d1d
Update CHANGELOG 2018-09-17 11:27:37 -07:00
Brian Cain 9ad04ada6c
Merge pull request #9431 from blueyed/options-without-leading-space
salt: remove leading space with bootstrap_options
2018-09-17 11:26:54 -07:00
Brian Cain ff3d1235fb
Update CHANEGLOG 2018-09-17 11:14:09 -07:00
Brian Cain 4fd9d522f6
Merge pull request #9432 from blueyed/curl-s
salt: bootstrap-salt.sh: use -s with curl
2018-09-17 11:13:21 -07:00
Aloz1 b9b9eeac85 Void requires root access to check service status
Service status check was failing because it was not being run as root. This resulted in vagrant thinking the service was not running, hence it would always try to start nfs rather than updating exports.
2018-07-14 15:53:13 +10:00
Aloz1 5e258cbc7c Fixed nfs_start_command. NFS now starts. 2018-07-13 08:08:05 +10:00
Aloz1 98f70d4d7a Add void linux host support 2018-07-12 08:40:33 +10:00
Daniel Hahler ec99b75c53 squash! salt: bootstrap-salt.sh: use -s with curl
Also use --show-error, and long option for --silent.
2018-02-02 00:39:32 +01:00
Daniel Hahler 6f7c383fe8 salt: bootstrap-salt.sh: use -s with curl
This makes it silent (no progress information), which would otherwise
result in output like the following (when the output from the bootstrap
script is displayed in verbose mode):

      % Total    % Recei
    ved % Xferd  Avera
    ge Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
      0     0
       0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
    100  244k  100
     244k    0     0
       458k      0 --:--:-- --:--:-- --:--:--  458k
     *  INFO: Running version: 2017.12.13
     …
2018-02-01 21:27:27 +01:00
Daniel Hahler 496d9b24c1 salt: remove leading space with bootstrap_options 2018-02-01 21:24:15 +01:00
Thomas Reifenberger 52bf853cee Add completion for snapshot names for vagrant snapshot restore|delete
- Note that this does not cover additional options like --no-provision
- It is also a bit slow, as `vagrant snapshot list` is used to gather
  the data
2017-10-13 12:59:01 +02:00
564 changed files with 24193 additions and 2490 deletions

20
.ci/build.sh Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
csource="${BASH_SOURCE[0]}"
while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done
root="$( cd -P "$( dirname "$csource" )/../" && pwd )"
. "${root}/.ci/init.sh"
pushd "${root}" > "${output}"
# Build our gem
wrap gem build *.gemspec \
"Failed to build Vagrant RubyGem"
# Get the path of our new gem
g=(vagrant*.gem)
gem=$(printf "%s" "${g}")
wrap aws s3 cp "${gem}" "${ASSETS_PRIVATE_BUCKET}/${repository}/vagrant-master.gem" \
"Failed to store Vagrant RubyGem master build"

432
.ci/common.sh Executable file
View File

@ -0,0 +1,432 @@
# last-modified: Tue Jan 14 20:37:58 UTC 2020
#!/usr/bin/env bash
# Path to file used for output redirect
# and extracting messages for warning and
# failure information sent to slack
function output_file() {
printf "/tmp/.ci-output"
}
# Write failure message, send error to configured
# slack, and exit with non-zero status. If an
# "$(output_file)" file exists, the last 5 lines will be
# included in the slack message.
#
# $1: Failure message
function fail() {
(>&2 echo "ERROR: ${1}")
if [ -f ""$(output_file)"" ]; then
slack -s error -m "ERROR: ${1}" -f "$(output_file)" -T 5
else
slack -s error -m "ERROR: ${1}"
fi
exit 1
}
# Write warning message, send warning to configured
# slack
#
# $1: Warning message
function warn() {
(>&2 echo "WARN: ${1}")
if [ -f ""$(output_file)"" ]; then
slack -s warn -m "WARNING: ${1}" -f "$(output_file)"
else
slack -s warn -m "WARNING: ${1}"
fi
}
# Execute command while redirecting all output to
# a file (file is used within fail mesage on when
# command is unsuccessful). Final argument is the
# error message used when the command fails.
#
# $@{1:$#-1}: Command to execute
# $@{$#}: Failure message
function wrap() {
i=$(("${#}" - 1))
wrap_raw "${@:1:$i}"
if [ $? -ne 0 ]; then
cat "$(output_file)"
fail "${@:$#}"
fi
rm "$(output_file)"
}
# Execute command while redirecting all output to
# a file. Exit status is returned.
function wrap_raw() {
rm -f "$(output_file)"
"${@}" > "$(output_file)" 2>&1
return $?
}
# Execute command while redirecting all output to
# a file (file is used within fail mesage on when
# command is unsuccessful). Command output will be
# streamed during execution. Final argument is the
# error message used when the command fails.
#
# $@{1:$#-1}: Command to execute
# $@{$#}: Failure message
function wrap_stream() {
i=$(("${#}" - 1))
wrap_stream_raw "${@:1:$i}"
if [ $? -ne 0 ]; then
fail "${@:$#}"
fi
rm "$(output_file)"
}
# Execute command while redirecting all output
# to a file. Command output will be streamed
# during execution. Exit status is returned
function wrap_stream_raw() {
rm -f "$(output_file)"
"${@}" > "$(output_file)" 2>&1 &
pid=$!
until [ -f "$(output_file)" ]; do
sleep 0.1
done
tail -f --quiet --pid "${pid}" "$(output_file)"
wait "${pid}"
return $?
}
# Send command to packet device and wrap
# execution
# $@{1:$#-1}: Command to execute
# $@{$#}: Failure message
function pkt_wrap() {
wrap packet-exec run -quiet -- "${@}"
}
# Send command to packet device and wrap
# execution
# $@: Command to execute
function pkt_wrap_raw() {
wrap_raw packet-exec run -quiet -- "${@}"
}
# Send command to packet device and wrap
# execution with output streaming
# $@{1:$#-1}: Command to execute
# $@{$#}: Failure message
function pkt_wrap_stream() {
wrap_stream packet-exec run -quiet -- "${@}"
}
# Send command to packet device and wrap
# execution with output streaming
# $@: Command to execute
function pkt_wrap_stream_raw() {
wrap_stream_raw packet-exec run -quiet -- "${@}"
}
# Generates location within the asset storage
# bucket to retain built assets.
function asset_location() {
if [ "${tag}" = "" ]; then
dst="${ASSETS_PRIVATE_LONGTERM}/${repository}/${ident_ref}/${short_sha}"
else
if [[ "${tag}" = *"+"* ]]; then
dst="${ASSETS_PRIVATE_LONGTERM}/${repository}/${tag}"
else
dst="${ASSETS_PRIVATE_BUCKET}/${repository}/${tag}"
fi
fi
echo -n "${dst}"
}
# Upload assets to the asset storage bucket.
#
# $1: Path to asset file or directory to upload
function upload_assets() {
if [ "${1}" = "" ]; then
fail "Parameter required for asset upload"
fi
if [ -d "${1}" ]; then
wrap aws s3 cp --recursive "${1}" "$(asset_location)/" \
"Upload to asset storage failed"
else
wrap aws s3 cp "${1}" "$(asset_location)/" \
"Upload to asset storage failed"
fi
}
# Download assets from the asset storage bucket. If
# destination is not provided, remote path will be
# used locally.
#
# $1: Path to asset or directory to download
# $2: Optional destination for downloaded assets
function download_assets() {
if [ "${1}" = "" ]; then
fail "At least one parameter required for asset download"
fi
if [ "${2}" = "" ]; then
dst="${1#/}"
else
dst="${2}"
fi
mkdir -p "${dst}"
src="$(asset_location)/${1#/}"
remote=$(aws s3 ls "${src}")
if [[ "${remote}" = *" PRE "* ]]; then
mkdir -p "${dst}"
wrap aws s3 cp --recursive "${src%/}/" "${dst}" \
"Download from asset storage failed"
else
mkdir -p "$(dirname "${dst}")"
wrap aws s3 cp "${src}" "${dst}" \
"Download from asset storage failed"
fi
}
# Upload assets to the cache storage bucket.
#
# $1: Path to asset file or directory to upload
function upload_cache() {
if [ "${1}" = "" ]; then
fail "Parameter required for cache upload"
fi
if [ -d "${1}" ]; then
wrap aws s3 cp --recursive "${1}" "${asset_cache}/" \
"Upload to cache failed"
else
wrap aws s3 cp "${1}" "${asset_cache}/" \
"Upload to cache failed"
fi
}
# Download assets from the cache storage bucket. If
# destination is not provided, remote path will be
# used locally.
#
# $1: Path to asset or directory to download
# $2: Optional destination for downloaded assets
function download_cache() {
if [ "${1}" = "" ]; then
fail "At least one parameter required for cache download"
fi
if [ "${2}" = "" ]; then
dst="${1#/}"
else
dst="${2}"
fi
mkdir -p "${dst}"
src="${asset_cache}/${1#/}"
remote=$(aws s3 ls "${src}")
if [[ "${remote}" = *" PRE "* ]]; then
mkdir -p "${dst}"
wrap aws s3 cp --recursive "${src%/}/" "${dst}" \
"Download from cache storage failed"
else
mkdir -p "$(dirname "${dst}")"
wrap aws s3 cp "${src}" "${dst}" \
"Download from cache storage failed"
fi
}
# Validate arguments for GitHub release. Checks for
# two arguments and that second argument is an exiting
# file asset, or directory.
#
# $1: GitHub tag name
# $2: Asset file or directory of assets
function release_validate() {
if [ "${1}" = "" ]; then
fail "Missing required position 1 argument (TAG) for release"
fi
if [ "${2}" = "" ]; then
fail "Missing required position 2 argument (PATH) for release"
fi
if [ ! -e "${2}" ]; then
fail "Path provided for release (${2}) does not exist"
fi
}
# Generate a GitHub release
#
# $1: GitHub tag name
# $2: Asset file or directory of assets
function release() {
release_validate "${@}"
wrap_raw ghr -u "${repo_owner}" -r "${repo_name}" -c "${full_sha}" -n "${1}" -delete
if [ $? -ne 0 ]; then
wrap ghr -u "${repo_owner}" -r "${repo_name}" -c "${full_sha}" -n "${1}" \
"${1}" "${2}" "Failed to create release for version ${1}"
fi
}
# Generate a GitHub prerelease
#
# $1: GitHub tag name
# $2: Asset file or directory of assets
function prerelease() {
release_validate "${@}"
if [[ "${1}" != *"+"* ]]; then
ptag="${1}+${short_sha}"
else
ptag="${1}"
fi
wrap_raw ghr -u "${repo_owner}" -r "${repo_name}" -c "${full_sha}" -n "${ptag}" \
-delete -prerelease "${ptag}" "${2}"
if [ $? -ne 0 ]; then
wrap ghr -u "${repo_owner}" -r "${repo_name}" -c "${full_sha}" -n "${ptag}" \
-prerelease "${ptag}" "${2}" \
"Failed to create prerelease for version ${1}"
fi
echo -n "${ptag}"
}
# Check if version string is valid for release
#
# $1: Version
# Returns: 0 if valid, 1 if invalid
function valid_release_version() {
if [[ "${1}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
return 0
else
return 1
fi
}
# Validate arguments for HashiCorp release. Ensures asset
# directory exists, and checks that the SHASUMS and SHASUM.sig
# files are present.
#
# $1: Asset directory
function hashicorp_release_validate() {
directory="${1}"
# Directory checks
if [ "${directory}" = "" ]; then
fail "No asset directory was provided for HashiCorp release"
fi
if [ ! -d "${directory}" ]; then
fail "Asset directory for HashiCorp release does not exist"
fi
# SHASUMS checks
if [ ! -e "${directory}/"*SHASUMS ]; then
fail "Asset directory is missing SHASUMS file"
fi
if [ ! -e "${directory}/"*SHASUMS.sig ]; then
fail "Asset directory is missing SHASUMS signature file"
fi
}
# Verify release assets by validating checksum properly match
# and that signature file is valid
#
# $1: Asset directory
function hashicorp_release_verify() {
directory="${1}"
pushd "${directory}" > "${output}"
# First do a checksum validation
wrap shasum -a 256 -c *_SHA256SUMS \
"Checksum validation of release assets failed"
# Next check that the signature is valid
gpghome=$(mktemp -qd)
export GNUPGHOME="${gpghome}"
wrap gpg --import "${HASHICORP_PUBLIC_GPG_KEY}" \
"Failed to import HashiCorp public GPG key"
wrap gpg --verify *SHA256SUMS.sig *SHA256SUMS \
"Validation of SHA256SUMS signature failed"
rm -rf "${gpghome}" > "${output}" 2>&1
popd > "${output}"
}
# Generate a HashiCorp release
#
# $1: Asset directory
function hashicorp_release() {
directory="${1}"
hashicorp_release_validate "${directory}"
hashicorp_release_verify "${directory}"
oid="${AWS_ACCESS_KEY_ID}"
okey="${AWS_SECRET_ACCESS_KEY}"
export AWS_ACCESS_KEY_ID="${RELEASE_AWS_ACCESS_KEY_ID}"
export AWS_SECRET_ACCESS_KEY="${RELEASE_AWS_SECRET_ACCESS_KEY}"
wrap_stream hc-releases upload "${directory}" \
"Failed to upload HashiCorp release assets"
wrap_stream hc-releases publish \
"Failed to publish HashiCorp release"
export AWS_ACCESS_KEY_ID="${oid}"
export AWS_SECRET_ACCESS_KEY="${okey}"
}
# Configures git for hashibot usage
function hashibot_git() {
wrap git config user.name "${HASHIBOT_USERNAME}" \
"Failed to setup git for hashibot usage (username)"
wrap git config user.email "${HASHIBOT_EMAIL}" \
"Failed to setup git for hashibot usage (email)"
wrap git remote set-url origin "https://${HASHIBOT_USERNAME}:${HASHIBOT_TOKEN}@github.com/${repository}" \
"Failed to setup git for hashibot usage (remote)"
}
# Stub cleanup method which can be redefined
# within actual script
function cleanup() {
(>&2 echo "** No cleanup tasks defined")
}
trap cleanup EXIT
# Enable debugging. This needs to be enabled with
# extreme caution when used on public repositories.
# Output with debugging enabled will likely include
# secret values which should not be publicly exposed.
#
# If repository is public, FORCE_PUBLIC_DEBUG environment
# variable must also be set.
is_private=$(curl -H "Authorization: token ${HASHIBOT_TOKEN}" -s "https://api.github.com/repos/${GITHUB_REPOSITORY}" | jq .private)
if [ "${DEBUG}" != "" ]; then
if [ "${is_private}" = "false" ]; then
if [ "${FORCE_PUBLIC_DEBUG}" != "" ]; then
set -x
output="/dev/stdout"
else
fail "Cannot enable debug mode on public repository unless forced"
fi
else
set -x
output="/dev/stdout"
fi
else
output="/dev/null"
fi
# Check if we are running a public repository on private runners
if [ "${VAGRANT_PRIVATE}" != "" ] && [ "${is_private}" = "false" ]; then
fail "Cannot run public repositories on private Vagrant runners. Disable runners now!"
fi
# Common variables
full_sha="${GITHUB_SHA}"
short_sha="${full_sha:0:8}"
ident_ref="${GITHUB_REF#*/*/}"
if [[ "${GITHUB_REF}" == *"refs/tags/"* ]]; then
tag="${GITHUB_REF##*tags/}"
valid_release_version "${tag}"
if [ $? -eq 0 ]; then
release=1
fi
fi
repository="${GITHUB_REPOSITORY}"
repo_owner="${repository%/*}"
repo_name="${repository#*/}"
asset_cache="${ASSETS_PRIVATE_SHORTTERM}/${repository}/${GITHUB_ACTION}"
job_id="${GITHUB_ACTION}"

6
.ci/init.sh Normal file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
. "${root}/.ci/common.sh"
export DEBIAN_FRONTEND="noninteractive"
export PATH="${PATH}:${root}/.ci"

62
.ci/release.sh Executable file
View File

@ -0,0 +1,62 @@
#!/usr/bin/env bash
ghr_version="0.13.0"
# NOTE: This release will generate a new release on the installers
# repository which in turn triggers a full package build
target_owner="hashicorp"
target_repository="vagrant-builders"
csource="${BASH_SOURCE[0]}"
while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done
root="$( cd -P "$( dirname "$csource" )/../" && pwd )"
. "${root}/.ci/init.sh"
pushd "${root}" > "${output}"
# Install ghr
wrap curl -Lso /tmp/ghr.tgz "https://github.com/tcnksm/ghr/releases/download/v${ghr_version}/ghr_v${ghr_version}_linux_amd64.tar.gz" \
"Failed to download ghr utility"
wrap tar -C /tmp/ -xf /tmp/ghr.tgz \
"Failed to unpack ghr archive"
wrap mv "/tmp/ghr_v${ghr_version}_linux_amd64/ghr" "${root}/.ci/" \
"Failed to install ghr utility"
# Build our gem
wrap gem build *.gemspec \
"Failed to build Vagrant RubyGem"
# Get the path of our new gem
g=(vagrant*.gem)
gem=$(printf "%s" "${g}")
# Determine the version of the release
vagrant_version="$(gem specification "${gem}" version)"
vagrant_version="${vagrant_version##*version: }"
# We want to release into the builders repository so
# update the repository variable with the desired destination
repo_owner="${target_owner}"
repo_name="${target_repository}"
full_sha="master"
export GITHUB_TOKEN="${HASHIBOT_TOKEN}"
if [ "${tag}" = "" ]; then
echo "Generating Vagrant RubyGem pre-release... "
version="v${vagrant_version}+${short_sha}"
prerelease "${version}" "${gem}"
else
# Validate this is a proper release version
valid_release_version "${vagrant_version}"
if [ $? -ne 0 ]; then
fail "Invalid version format for Vagrant release: ${vagrant_version}"
fi
echo "Generating Vagrant RubyGem release... "
version="v${vagrant_version}"
release "${version}" "${gem}"
fi
slack -m "New Vagrant installers release triggered: *${version}*"

176
.ci/slack Executable file
View File

@ -0,0 +1,176 @@
#!/usr/bin/env ruby
require "optparse"
require "net/https"
require "uri"
require "json"
OPTIONS = [:channel, :username, :icon, :state, :message,
:message_file, :file, :title, :tail, :webhook].freeze
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: #{File.basename(__FILE__)} [options]"
opts.on("-c", "--channel CHAN", "Send to channel") do |c|
options[:channel] = c
end
opts.on("-u", "--username USER", "Send as username") do |u|
options[:username] = u
end
opts.on("-i", "--icon URL", "User icon image") do |i|
options[:icon] = i
end
opts.on("-s", "--state STATE", "Message state (success, warn, error, or color code)") do |s|
options[:state] = s
end
opts.on("-m", "--message MESSAGE", "Message to send") do |m|
options[:message] = m
end
opts.on("-M", "--message-file MESSAGE_FILE", "Use file contents as message") do |m|
options[:message_file] = m
end
opts.on("-f", "--file MESSAGE_FILE", "Send raw contents of file in message") do |f|
options[:file] = f
end
opts.on("-t", "--title TITLE", "Message title") do |t|
options[:title] = t
end
opts.on("-T", "--tail N", "Send last N lines of content from raw message file") do |t|
options[:tail] = t
end
opts.on("-w", "--webhook HOOK", "Slack webhook") do |w|
options[:webhook] = w
end
opts.on("-h", "--help", "Print help") do
puts opts
exit
end
end.parse!
OPTIONS.each do |key|
if !options.key?(key)
env_key = "SLACK_#{key.to_s.upcase}"
if ENV[env_key]
options[key] = ENV[env_key]
end
end
end
if !options[:webhook]
$stderr.puts "ERROR: Webhook is required!"
exit 1
end
if ENV["CIRCLECI"]
options[:icon] = "https://emoji.slack-edge.com/TF1GCKJNM/circleci/054b58d488e65138.png" unless options[:icon]
options[:username] = "circleci" unless options[:username]
options[:footer] = "CircleCI - <#{ENV["CIRCLE_BUILD_URL"]}|#{ENV["CIRCLE_PROJECT_USERNAME"]}/#{ENV["CIRCLE_PROJECT_REPONAME"]}>"
options[:footer_icon] = "https://emoji.slack-edge.com/TF1GCKJNM/circleci/054b58d488e65138.png"
end
if ENV["GITHUB_ACTIONS"]
options[:icon] = "https://ca.slack-edge.com/T024UT03C-WG8NDATGT-f82ae03b9fca-48" unless options[:icon]
options[:username] = "github" unless options[:username]
options[:footer] = "Actions - <https://github.com/#{ENV["GITHUB_REPOSITORY"]}/commit/#{ENV["GITHUB_SHA"]}/checks|#{ENV["GITHUB_REPOSITORY"]}>"
options[:footer_icon] = "https://ca.slack-edge.com/T024UT03C-WG8NDATGT-f82ae03b9fca-48"
end
options[:state] = "success" unless options[:state]
case options[:state]
when "success", "good"
options[:state] = "good"
when "warn", "warning"
options[:state] = "warning"
when "error", "danger"
options[:state] = "danger"
else
if !options[:state].start_with?("#")
$stderr.puts "ERROR: Invalid value for `state` (#{options[:state]})"
exit 1
end
end
msg = options[:message]
# NOTE: Message provided from CLI argument will end up with
# double escaped newlines so remove one
msg.gsub!("\\n", "\n") if msg
if options[:message_file]
if !File.exist?(options[:message_file])
$stderr.puts "ERROR: Message file does not exist `#{options[:message_file]}`"
exit 1
end
msg_c = File.read(options[:message_file])
msg = msg ? "#{msg}\n\n#{msg_c}" : msg_c
end
if options[:file]
if !File.exist?(options[:file])
$stderr.puts "ERROR: Message file does not exist `#{options[:file]}`"
exit 1
end
if (tail = options[:tail].to_i) > 0
content = ""
buffer = 0
File.open(options[:file], "r") do |f|
until (content.split("\n").size > tail) || buffer >= f.size
buffer += 1000
buffer = f.size if buffer > f.size
f.seek(f.size - buffer)
content = f.read
end
end
parts = content.split("\n")
if parts.size > tail
parts = parts.slice(-tail, tail)
end
fmsg = parts ? parts.join("\n") : ""
else
fmsg = File.read(options[:file])
end
fmsg = "```\n#{fmsg}\n```"
if msg
msg = msg << "\n\n" << fmsg
end
end
if msg.to_s.empty?
$stderr.puts "ERROR: No message content provided!"
exit 1
end
attach = {text: msg, fallback: msg, color: options[:state], mrkdn: true}
attach[:title] = options[:title] if options[:title]
attach[:footer] = options[:footer] if options[:footer]
attach[:footer_icon] = options[:footer_icon] if options[:footer_icon]
attach[:ts] = Time.now.to_i
payload = {}.tap do |pd|
pd[:username] = options.fetch(:username, "packet-exec")
pd[:channel] = options[:channel] if options[:channel]
pd[:icon_url] = options[:icon] if options[:icon]
pd[:attachments] = [attach]
end
result = Net::HTTP.post(URI(options[:webhook]), payload.to_json, "Content-Type" => "application/json")
if !result.code.start_with?("2")
$stderr.puts "Failed to send slack message"
exit 1
else
$stdout.puts "ok"
end

27
.ci/test.sh Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
csource="${BASH_SOURCE[0]}"
while [ -h "$csource" ] ; do csource="$(readlink "$csource")"; done
root="$( cd -P "$( dirname "$csource" )/../" && pwd )"
pushd "${root}" > /dev/null
export DEBIAN_FRONTEND="noninteractive"
# Install required dependencies
sudo apt-get update || exit 1
sudo apt-get install -yq bsdtar || exit 1
# Ensure bundler is installed
gem install --no-document bundler || exit 1
# Install the bundle
bundle install || exit 1
# Run tests
bundle exec rake test:unit
result=$?
popd > /dev/null
exit $result

33
.circleci/config.yml Normal file
View File

@ -0,0 +1,33 @@
version: 2
jobs:
build-website:
# setting the working_directory along with the checkout path allows us to not have
# to cd into the website/ directory for commands
working_directory: ~/project/website
docker:
- image: hashicorp/middleman-hashicorp:0.3.35
steps:
- checkout:
path: ~/project
- 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:
- ~/project/website/vendor/bundle
- run:
command: bundle exec middleman build
- run:
command: ./scripts/deploy.sh
workflows:
version: 2
website:
jobs:
- build-website:
context: static-sites
filters:
branches:
only: stable-website

View File

@ -54,12 +54,23 @@ Once you're confident that your upcoming changes will be accepted:
### Pull Request Lifecycle
1. You are welcome to submit your PR for commentary or review before it is fully completed. Please prefix the title of your PR with "[WIP]" to indicate this. It's also a good idea to include specific questions or items you'd like feedback on.
2. The PR is categorized by Vagrant collaborator(s), applying GitHub tags similarly to issues triage.
3. Once you believe your PR is ready to be merged, you can remove any
2. Sign the [HashiCorp CLA](#hashicorp-cla). If you haven't signed the CLA yet, a bot will ask you to do so. You only need to sign the CLA once. If you've already signed the CLA, the CLA status will be green automatically.
3. The PR is categorized by Vagrant collaborator(s), applying GitHub tags similarly to issues triage.
4. Once you believe your PR is ready to be merged, you can remove any
"[WIP]" prefix from the title and a Vagrant collaborator will review.
4. One of Vagrant collaborator will look over your contribution and either provide comments letting you know if there is anything left to do. We do our best to provide feedback in a timely manner, but it may take some time for us to respond.
5. Once all outstanding comments have been addressed, your contribution will be merged! Merged PRs will be included in the next Vagrant release. The Vagrant contributors will take care of updating the CHANGELOG as they merge.
6. We might decide that a PR should be closed. We'll make sure to provide clear reasoning when this happens.
5. One of the Vagrant collaborators will look over your contribution and either provide comments letting you know if there is anything left to do. We do our best to provide feedback in a timely manner, but it may take some time for us to respond.
6. Once all outstanding comments have been addressed, your contribution will be merged! Merged PRs will be included in the next Vagrant release. The Vagrant contributors will take care of updating the CHANGELOG as they merge.
7. We might decide that a PR should be closed. We'll make sure to provide clear reasoning when this happens.
## HashiCorp CLA
We require all contributors to sign the [HashiCorp CLA](https://www.hashicorp.com/cla).
In simple terms, the CLA affirms that the work you're contributing is original, that you grant HashiCorp permission to use that work (including license to any patents necessary), and that HashiCorp may relicense your work for our commercial products if necessary. Note that this description is a summary and the specific legal terms should be read directly in the [CLA](https://www.hashicorp.com/cla).
The CLA does not change the terms of the standard open source license used by our software such as MPL2 or MIT. You are still free to use our projects within your own projects or businesses, republish modified source, and more. Please reference the appropriate license of this project to learn more.
To sign the CLA, open a pull request as usual. If you haven't signed the CLA yet, a bot will respond with a link asking you to sign the CLA. We cannot merge any pull request until the CLA is signed. You only need to sign the CLA once. If you've signed the CLA before, the bot will not respond to your PR and your PR will be allowed to merge.
# Additional Resources

37
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,37 @@
on:
push:
branches:
- master
paths-ignore:
- 'CHANGELOG.md'
- 'website/**'
jobs:
build-gem:
name: Build Vagrant RubyGem
runs-on: ubuntu-18.04
steps:
- name: Code Checkout
uses: actions/checkout@v1
- name: Set Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: '2.6'
- name: Build RubyGem
run: ./.ci/build.sh
working-directory: ${{github.workspace}}
env:
ASSETS_LONGTERM_PREFIX: elt
ASSETS_PRIVATE_BUCKET: ${{ secrets.ASSETS_PRIVATE_BUCKET }}
ASSETS_PRIVATE_LONGTERM: ${{ secrets.ASSETS_PRIVATE_LONGTERM }}
ASSETS_PRIVATE_SHORTTERM: ${{ secrets.ASSETS_PRIVATE_SHORTTERM }}
ASSETS_PUBLIC_BUCKET: ${{ secrets.ASSETS_PUBLIC_BUCKET }}
ASSETS_PUBLIC_LONGTERM: ${{ secrets.ASSETS_PUBLIC_LONGTERM }}
ASSETS_PUBLIC_SHORTTERM: ${{ secrets.ASSETS_PUBLIC_SHORTTERM }}
ASSETS_SHORTTERM_PREFIX: est
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
HASHIBOT_EMAIL: ${{ secrets.HASHIBOT_EMAIL }}
HASHIBOT_TOKEN: ${{ secrets.HASHIBOT_TOKEN }}
HASHIBOT_USERNAME: ${{ secrets.HASHIBOT_USERNAME }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

38
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,38 @@
on:
push:
branches:
- 'build-*'
tags: '*'
paths-ignore:
- 'CHANGELOG.md'
- 'website/**'
jobs:
trigger-release:
name: Trigger Installers Build
runs-on: ubuntu-18.04
steps:
- name: Code Checkout
uses: actions/checkout@v1
- name: Set Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: '2.6'
- name: Create Builders Release
run: ./.ci/release.sh
working-directory: ${{github.workspace}}
env:
ASSETS_LONGTERM_PREFIX: elt
ASSETS_PRIVATE_BUCKET: est
ASSETS_PRIVATE_LONGTERM: ${{ secrets.ASSETS_PRIVATE_LONGTERM }}
ASSETS_PRIVATE_SHORTTERM: ${{ secrets.ASSETS_PRIVATE_SHORTTERM }}
ASSETS_PUBLIC_BUCKET: ${{ secrets.ASSETS_PUBLIC_BUCKET }}
ASSETS_PUBLIC_LONGTERM: ${{ secrets.ASSETS_PUBLIC_LONGTERM }}
ASSETS_PUBLIC_SHORTTERM: ${{ secrets.ASSETS_PUBLIC_SHORTTERM }}
ASSETS_SHORTTERM_PREFIX: ${{ secrets.ASSETS_SHORTTERM_PREFIX }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
HASHIBOT_EMAIL: ${{ secrets.HASHIBOT_EMAIL }}
HASHIBOT_TOKEN: ${{ secrets.HASHIBOT_TOKEN }}
HASHIBOT_USERNAME: ${{ secrets.HASHIBOT_USERNAME }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

29
.github/workflows/testing.yml vendored Normal file
View File

@ -0,0 +1,29 @@
on:
push:
branches:
- master
- 'test-*'
paths-ignore:
- 'CHANGELOG.md'
- 'website/**'
pull_request:
branches:
- master
jobs:
unit-tests:
runs-on: ubuntu-18.04
strategy:
matrix:
ruby: [ '2.4.x', '2.5.x', '2.6.x' ]
name: Vagrant unit tests on Ruby ${{ matrix.ruby }}
steps:
- name: Code Checkout
uses: actions/checkout@v1
- name: Setup Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: ${{matrix.ruby}}
architecture: 'x64'
- name: Run Tests
run: .ci/test.sh

12
.hashibot.hcl Normal file
View File

@ -0,0 +1,12 @@
poll "closed_issue_locker" "locker" {
schedule = "0 50 1 * * *"
closed_for = "720h" # 30 days
max_issues = 500
sleep_between_issues = "5s"
message = <<-EOF
I'm going to lock this issue because it has been closed for _30 days_ . This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
EOF
}

View File

@ -1,26 +0,0 @@
language: ruby
sudo: false
cache: bundler
addons:
apt:
packages:
- bsdtar
rvm:
- 2.3.7
- 2.4.4
- 2.5.0
- 2.5.1
branches:
only:
- master
env:
global:
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
script: bundle exec rake test:unit

View File

@ -6,6 +6,273 @@ IMPROVEMENTS:
BUG FIXES:
## 2.2.7 (January 27, 2020)
IMPROVEMENTS:
- guest/opensuse: Check for basename hostname prior to setting hostname [GH-11170]
- host/linux: Check for modinfo in /sbin if it's not on PATH [GH-11178]
- core: Show guest name in hostname error message [GH-11175]
- provisioners/shell: Linux guests now support `reboot` option [GH-11194]
- darwin/nfs: Put each NFS export on its own line [GH-11216]
- contrib/bash: Add more completion flags to up command [GH-11223]
- provider/virtualbox: Add VirtualBox provider support for version 6.1.x [GH-11250]
- box/outdated: Allow to force check for box updates and ignore cached check [GH-11231]
- guest/alpine: Update apk cache when installing rsync [GH-11220]
- provider/virtualbox: Improve error message when machine folder is inaccessible [GH-11239]
- provisioner/ansible_local: Add pip install method for arch guests [GH-11265]
- communicators/winssh: Use Windows shell for `vagrant ssh -c` [GH-11258]
BUG FIXES:
- command/snapshot/save: Fix regression that prevented snapshot of all guests in environment [GH-11152]
- core: Update UI to properly retain newlines when adding prefix [GH-11126]
- core: Check if box update is available locally [GH-11188]
- core: Ensure Vagrant::Errors are loaded in file_checksum util [GH-11183]
- cloud/publish: Improve argument handling for missing arguments to command [GH-11184]
- core: Get latest version for current provider during outdated check [GH-11192]
- linux/nfs: avoid adding extra newlines to /etc/exports [GH-11201]
- guest/darwin: Fix VMware synced folders on APFS [GH-11267]
- guest/redhat: Ensure `nfs-server` is restarted when installing nfs client [GH-11212]
- core: Do not validate checksums if options are empty string [GH-11211]
- provider/docker: Enhance docker build method to match against buildkit output [GH-11205]
- provisioner/ansible_local: Don't prompt for input when installing Ansible on Ubuntu and Debian [GH-11191]
- provisioner/ansible_local: Ensure all guest caps accept all passed in arguments [GH-11265]
- host/windows: Fix regression that prevented port collisions from being detected [GH-11244]
- core/provisioner: Set top level provisioner name if set in a provisioner config [GH-11295]
## 2.2.6 (October 14, 2019)
FEATURES:
- core/provisioners: Introduce new Provisioner options: before and after [GH-11043]
- guest/alpine: Integrate the vagrant-alpine plugin into Vagrant core [GH-10975]
IMPROVEMENTS:
- command/box/prune: Allow prompt skip while preserving actively in use boxes [GH-10908]
- command/cloud: Support providing checksum information with boxes [GH-11101]
- dev: Fixed Vagrantfile for Vagrant development [GH-11012]
- guest/alt: Improve handling for using network tools when setting hostname [GH-11000]
- guest/suse: Add ipv6 network config templates for SUSE based distributions [GH-11013]
- guest/windows: Retry on connection timeout errors for the reboot capability [GH-11093]
- host/bsd: Use host resolve path capability to modify local paths if required [GH-11108]
- host/darwin: Add host resolve path capability to provide real paths for firmlinks [GH-11108]
- 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]
- provider/virtualbox: Raise additional errors for incomplete virtualbox installation on usable check [GH-10938]
- util/filechecksum: Add support for more checksum types [GH-11101]
BUG FIXES:
- 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]
- core: Ensure proper paths are shown in config loading exceptions [GH-11056]
- guest/suse: Use hostnamectl instead of hostname to set the hostname under SUSE [GH-11100]
- provider/docker: Fix default provider validation if password is used [GH-11053]
- provider/docker: Fix Docker providers usable? check [GH-11068]
- provisioner/ansible_local: Ensure pip_install_cmd is finalized to emptry string [GH-11098]
- provisioner/file: Ensure relative path for file provisioner source is relative to guest machines cwd [GH-11099]
- provider/docker: Ensure docker build_args option is properly set in docker compose config yaml [GH-11106]
- guest/suse: Update nfs & service daemon names for suse based hosts and guests [GH-11076]
- provider/docker: Determine ip address prefix workaround for docker public networks [GH-11111]
- provider/docker: Only return interfaces where addr is not nil for networks [GH-11116]
## 2.2.5 (June 19, 2019)
FEATURES:
- providers/docker: Private and Public networking support [GH-10702]
IMPROVEMENTS:
- command/global-status: Provide machine-readable information [GH-10506]
- command/snapshot: Separate snapshot names for guests when listing snapshots [GH-10828]
- command/box/update: Ignore missing metadata files when updating all boxes [GH-10829]
- core: Use consistent settings when unpacking boxes as root [GH-10707]
- core: Write metadata.json file when packaging box [GH-10706]
- core: Remove whitespace from id file on load [GH-10727]
- core/bundler: Support resolution when installed within system [GH-10894]
- guest/coreos: Update network configuration and hostname setting [GH-10752]
- guest/freebsd: Add proper VirtualBox share folders support for FreeBSD guests [GH-10717]
- guest/freebsd: Add unmount share folder for VirtualBox guests [GH-10761]
- guest/freebsd: Simplify network interface listing when configuring networks [GH-10763]
- providers/docker: Add usable? check to docker provider [GH-10890]
- synced_folder/smb: Remove configuration information from synced folder data [GH-10811]
BUG FIXES:
- command/box/update: Ensure the right version is picked when updating specific boxes [GH-10810]
- command/cloud: Properly set variable from CLI argument parsing for `username` field [GH-10726]
- command/rsync_auto: Use relative paths to machines folder path for file path Listener [GH-10902]
- communicator/ssh: Remove net/sftp loading to prevent loading errors [GH-10745]
- contrib/bash: Search for running_vm_list only in `machines` folder [GH-10841]
- core/bundler: Properly parse multiple constants when installing plugins [GH-10896]
- core/environment: Support plugin configuration within box Vagrantfiles [GH-10889]
- core/triggers: Fix typo in UI output [GH-10748]
- core/triggers: Properly exit with abort option [GH-10824]
- core/triggers: Ensure guest names are string when filtering trigger configs [GH-10854]
- core/triggers: Abort after all running processes have completed when parallel is enabled [GH-10891]
- guest/void: Fix NFS capability detection [GH-10713]
- guest/bsd: Properly set BSD options order for /etc/exports [GH-10909]
- host/windows: Fix rubygems error when host has directory named `c` [GH-10803]
- 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)
FEATURES:
- core/triggers: Introduce new option `:type` for actions, hooks, and commands [GH-10615]
IMPROVEMENTS:
- communicator/ssh: Update `#upload` behavior to work properly with new sshd path checks [GH-10698]
- communicator/winrm: Update `#upload` behavior to match ssh communicator upload behavior [GH-10698]
- guest/windows: Add reboot output to guest capability [GH-10638]
- provisioner/file: Refactor path modification rules and allow communicator to handle details [GH-10698]
BUG FIXES:
- core: Fix format finalization of plugins in Vagrantfile [GH-10664]
- core: Fix SIGINT behavior and prevent backtrace [GH-10666]
- core: Change remaining box_client_cert refs to box_download_client_cert [GH-10622]
- core: Move over AddAuthentication middleware and hooks out of deprecated class [GH-10686]
- guest/debian: Properly set DHCP for systemd-networkd ips [GH-10586]
- guest/solaris11: Create interface if required before configuration [GH-10595]
- installers/appimage: Use ld path with appimage libs on suffix [GH-10647]
- providers/docker: Expand paths when comparing synced folders on reload [GH-10645]
- providers/virtualbox: Fix import paths on Windows with VirtualBox 6 [GH-10629]
- synced_folders/rsync: Properly clean up tmp folder created during rsync [GH-10690]
## 2.2.3 (January 9, 2019)
FEATURES:
- host/void: Add host support for void linux [GH-10012]
IMPROVEMENTS:
- command/rsync-auto: Prevent crash on post-rsync command failure [GH-10515]
- command/snapshot: Raise error for bad subcommand [GH-10470]
- command/package: Ensure temp dir for package command is cleaned up [GH-10479]
- command/powershell: Support running elevated commands [GH-10528]
- communicator/ssh: Add `config` and `remote_user` options [GH-10496]
- core: Display version update on stderr instead of stdout [GH-10482]
- core: Add experimental feature flag [GH-10485]
- core: Show box version during box outdated check [GH-10573]
- guest/windows: Modify elevated username only on username failure [GH-10488]
- host/windows: Prevent SMB setup commands from becoming too long [GH-10489]
- host/windows: Automatically answer yes when pruning SMB shares [GH-10524]
- provisioners/file: Show source and destination locations with file provisioner [GH-10570]
- provisioners/salt: Validate that `install_type` is set if `version` is specified [GH-10474]
- provisioners/salt: Update default install version [GH-10537]
- provisioners/shell: Add `reboot` option for rebooting supported guest [GH-10532]
- synced_folders/rsync: Support using rsync `--chown` option [GH-10529]
- util/guest_inspection: Validate hostnamectl command works when detected [GH-10512]
- util/platform: Use wslpath command for customized root on WSL [GH-10574]
BUG FIXES:
- command/cloud publish: Ensure box file exists before path expanding [GH-10468]
- command/cloud publish: Catch InvalidVersion errors from vagrant_cloud client [GH-10513]
- command/snapshot: Retain consistent provisioning behavior across all commands [GH-10490]
- command/validate: Bypass install checks for validating configs with the `--ignore-provider` flag [GH-10467]
- communicator/ssh: Fix garbage output detection [GH-10571]
- guest/alt: Fix network configuration errors [GH-10527]
- guest/coreos: Fix grep command for network interface of CoreOS guest [GH-10554]
- guest/freebsd: Fix defaultrouter rcvar in static network template [GH-10469]
- guest/redhat: Fix network configuration errors [GH-10527]
- providers/virtualbox: Adjust version requirement for NIC warning [GH-10486]
- util/powershell: Use correct Base64 encoding for encoded commands [GH-10487]
## 2.2.2 (November 27, 2018)
BUG FIXES:
- providers/virtualbox: Update default_nic_type implementation and add warning [GH-10450]
## 2.2.1 (November 15, 2018)
FEATURES:
- core/plugins: Add reset! method to communicator [GH-10399]
- providers/virtualbox: Add support for VirtualBox 6.0 [GH-10379]
IMPROVEMENTS:
- command/validate: Allow validation of config while ignoring provider [GH-10351]
- communicators/ssh: Prevent overly verbose output waiting for connection [GH-10321]
- communicators/ssh: Support ed25519 keys [GH-10365]
- communicators/ssh: Add reset! implementation [GH-10399]
- communicators/winrm: Add reset! implementation [GH-10399]
- core: Limit number of automatic box update checks [GH-10359]
- host/windows: Remove PATH check in WSL detection [GH-10313]
- providers/hyperv: Disable automatic checkpoints before deletion [GH-10406]
- providers/virtualbox: Add `automount` flag if specified with synced_folder [GH-10326]
- providers/virtualbox: Refactor host only network settings [GH-7699]
- providers/virtualbox: Support setting default NIC type for network adapters [GH-10383]
- providers/virtualbox: Update ssh_port helper to handle multiple matches [GH-10409]
- provisioners/shell: Add :reset option to allow communicator reset [GH-10399]
- synced_folders/smb: Allow for 'default' smb_username in prompt if set [GH-10319]
- util/network_ip: Simplify `network_address` helper [GH-7693]
- util/platform: Prevent hard failure during hyper-v enabled check [GH-10332]
BUG FIXES:
- command/login: Only show deprecation warning when command is invoked [GH-10374]
- core: Fallback to Vagrantfile defined box information [GH-10368]
- core/bundler: Update source ordering to properly resolve with new RubyGems [GH-10364]
- core/triggers: Only split inline script if host is non-Windows [GH-10405]
- communicator/winrm: Prepend computer name to username when running elevated commands [GH-10387]
- guest/debian: Fix halting issue when setting hostname by restarting networking on guest [GH-10301, GH-10330]
- guest/linux: Fix vagrant user access to docker after install [GH-10399]
- guest/windows: Add reboot capability to fix hostname race condition [GH-10347]
- guest/windows: Allow for reading key paths with spaces [GH-10389]
- host/windows: Fix powershell to properly handle paths with spaces [GH-10390]
- providers/docker: Deterministic host VM synced folder location for Docker VM [GH-10311]
- providers/hyperv: Fix network vlan configuration script [GH-10366]
- providers/hyperv: Properly output error message on failed guest import [GH-10404]
- providers/hyperv: Fix typo in network configuration detection script [GH-10410]
## 2.2.0 (October 16, 2018)
FEATURES:
- command/cloud: Introduce `vagrant cloud` subcommand to Vagrant [GH-10148]
- command/upload: Add command for uploading files to guest [GH-10263]
- command/winrm: Add command for executing guest commands via WinRM [GH-10263]
- command/winrm-config: Add command for providing WinRM configuration [GH-10263]
IMPROVEMENTS:
- core: Ensure file paths are identical when checking for cwd [GH-10220]
- core: Add config option `ignore_box_vagrantfile` for ignoring vagrantfile inside box [GH-10242]
- core/triggers: Add abort option to core triggers [GH-10232]
- core/triggers: Introduce `ruby` option for trigger [GH-10267]
- contrib/bash: Add completion for snapshot names for vagrant snapshot restore|delete [GH-9054]
- providers/docker: Build docker from git repo [GH-10221]
- providers/hyperv: Update Hyper-V admin check and allow override via ENV variable [GH-10275]
- providers/virtualbox: Allow base_mac to be optional [GH-10255]
- provisioners/salt: bootstrap-salt.sh: use -s with curl [GH-9432]
- provisioners/salt: remove leading space with bootstrap_options [GH-9431]
BUG FIXES:
- core/environment: Provide rgloader for local plugin installations [GH-10279]
- contrib/sudoers/osx: Fix missing comma and add remove export alias [GH-10235]
- guest/redhat: Update restart logic in redhat change_host_name cap [GH-10223]
- guest/windows: Allow special characters in SMB password field [GH-10219]
- providers/hyperv: Only use AutomaticCheckpointsEnabled when available [GH-10264]
- providers/hyperv: Only use CheckpointType when available [GH-10265]
- provisioners/ansible: Fix remote directory creation [GH-10259, GH-10258]
- provisioners/puppet: Properly set env variables for puppet provisioner on windows [GH-10218]
- provisioners/salt: Properly set salt pillar variables for windows guests [GH-10215]
- synced_folders/rsync: Ensure unique tmp dirs for ControlPath with rsync [GH-10291]
## 2.1.5 (September 12, 2018)
IMPROVEMENTS:
@ -285,7 +552,7 @@ BUG FIXES:
- core: Rescue more exceptions when checking if port is open [GH-8517]
- guests/solaris11: Inherit from Solaris guest and keep solaris11 specific methods [GH-9034]
- guests/windows: Split out cygwin path helper for msys2/cygwin paths and ensure cygpath exists [GH-8972]
- guests/windows: Specify expected shell when executing on guest (fixes winssh communicator usage) [GH-9012]
- guests/windows: Specify expected shell when executing on guest (fixes einssh communicator usage) [GH-9012]
- guests/windows: Include WinSSH Communicator when using insert_public_key [GH-9105]
- hosts/windows: Check for vagrant.exe when validating versions within WSL [GH-9107, GH-8962]
- providers/docker: Isolate windows check within executor to handle running through VM [GH-8921]

View File

@ -1,6 +1,6 @@
The MIT License
Copyright (c) 2010-2018 Mitchell Hashimoto
Copyright (c) 2010-2019 Mitchell Hashimoto
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -19,6 +19,8 @@ between Windows, Mac OS X, and Linux.
## Quick Start
Package dependencies: Vagrant requires `bsdtar` to be available on your system PATH to run successfully.
For the quick-start, we'll bring up a development machine on
[VirtualBox](https://www.virtualbox.org/) because it is free and works
on all major platforms. Vagrant can, however, work with almost any
@ -31,11 +33,11 @@ installed. After this,
To build your first virtual environment:
vagrant init hashicorp/precise32
vagrant init hashicorp/bionic64
vagrant up
Note: The above `vagrant up` command will also trigger Vagrant to download the
`precise32` box via the specified URL. Vagrant only does this if it detects that
`bionic64` box via the specified URL. Vagrant only does this if it detects that
the box doesn't already exist on your system.
## Getting Started Guide
@ -56,6 +58,14 @@ Once your Vagrant bundle is installed from Git repository, you can run the test
This will run the unit test suite, which should come back all green!
If you are developing Vagrant on a machine that already has a Vagrant package installation present, both will attempt to use the same folder for their configuration (location of this folder depends on system). This can cause errors when Vagrant attempts to load plugins. In this case, override the `VAGRANT_HOME` environment variable for your development version of Vagrant before running any commands, to be some new folder within the project or elsewhere on your machine. For example, in Bash:
export VAGRANT_HOME=~/.vagrant-dev
You can now run Vagrant commands against the development version:
bundle exec vagrant
Please take time to read the [HashiCorp Community Guidelines](https://www.hashicorp.com/community-guidelines) and the [Vagrant Contributing Guide](https://github.com/hashicorp/vagrant/blob/master/.github/CONTRIBUTING.md).
Then you're good to go!

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.

39
Vagrantfile vendored
View File

@ -4,13 +4,13 @@
# Ruby, run unit tests, etc.
Vagrant.configure("2") do |config|
config.vm.box = "hashicorp/precise64"
config.vm.box = "hashicorp/bionic64"
config.vm.hostname = "vagrant"
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
["vmware_fusion", "vmware_workstation", "virtualbox"].each do |provider|
["vmware_desktop", "virtualbox", "hyperv"].each do |provider|
config.vm.provider provider do |v, override|
v.memory = "1024"
v.memory = "2048"
end
end
@ -29,32 +29,32 @@ $shell = <<-'CONTENTS'
export DEBIAN_FRONTEND=noninteractive
MARKER_FILE="/usr/local/etc/vagrant_provision_marker"
RUBY_VER_REQ=$(awk '$1 == "s.required_ruby_version" { print $4 }' /vagrant/vagrant.gemspec | tr -d '"')
BUNDLER_VER_REQ=$(awk '/s.add_dependency "bundler"/ { print $4 }' /vagrant/vagrant.gemspec | tr -d '"')
# Only provision once
if [ -f "${MARKER_FILE}" ]; then
exit 0
fi
# Add ubuntu_rvm repo
apt-add-repository -y ppa:rael-gc/rvm
# Update apt
apt-get update --quiet
# Install basic dependencies
apt-get install -qy build-essential bsdtar curl
# Add vagrant user to sudo group:
# ubuntu_rvm only adds users in group sudo to group rvm
usermod -a -G sudo vagrant
# Install basic dependencies and RVM
apt-get install -qy build-essential bsdtar rvm
# Import the mpapis public key to verify downloaded releases
su -l -c 'gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3' vagrant
# Install RVM
su -l -c 'curl -sL https://get.rvm.io | bash -s stable' vagrant
# Add the vagrant user to the RVM group
#usermod -a -G rvm vagrant
# Install latest Ruby that complies with Vagrant's version constraint
RUBY_VER_LATEST=$(su -l -c 'rvm list known' vagrant | tr '[]-' ' ' | awk "/^ ruby ${RUBY_VER_REQ:0:1}\./ { print \$2 }" | sort | tail -n1)
su -l -c "rvm install ${RUBY_VER_LATEST}" vagrant
su -l -c "rvm --default use ${RUBY_VER_LATEST}" vagrant
# Install next-to-last Ruby that complies with Vagrant's version constraint
RUBY_VER=$(su -l -c 'rvm list known' vagrant | tr '[]-' ' ' | awk "/^ ruby ${RUBY_VER_REQ:0:1}\./ { print \$2 }" | sort -r | sed -n '2p')
su -l -c "rvm install ${RUBY_VER}" vagrant
su -l -c "rvm --default use ${RUBY_VER}" vagrant
# Output the Ruby version (for sanity)
su -l -c 'ruby --version' vagrant
@ -63,15 +63,14 @@ su -l -c 'ruby --version' vagrant
apt-get install -qy git
# Upgrade Rubygems
su -l -c "rvm ${RUBY_VER_LATEST} do gem update --system" vagrant
su -l -c "rvm ${RUBY_VER} do gem update --system" vagrant
# Install bundler and prepare to run unit tests
su -l -c "gem install bundler -v ${BUNDLER_VER_REQ}" vagrant
# Prepare to run unit tests
su -l -c 'cd /vagrant; bundle install' vagrant
# Automatically move into the shared folder, but only add the command
# if it's not already there.
grep -q 'cd /vagrant' /home/vagrant/.bash_profile || echo 'cd /vagrant' >> /home/vagrant/.bash_profile
grep -q 'cd /vagrant' /home/vagrant/.bash_profile 2>/dev/null || echo 'cd /vagrant' >> /home/vagrant/.bash_profile
# Touch the marker file so we don't do this again
touch ${MARKER_FILE}

View File

@ -89,6 +89,7 @@ begin
require 'vagrant/bundler'
require 'vagrant/cli'
require 'vagrant/util/platform'
require 'vagrant/util/experimental'
# Schedule the cleanup of things
at_exit(&Vagrant::Bundler.instance.method(:deinit))
@ -159,6 +160,23 @@ begin
env.ui.warn(I18n.t("vagrant.general.not_in_installer") + "\n", prefix: false)
end
# Acceptable experimental flag values include:
#
# Unset - Disables experimental features
# 0 - Disables experimental features
# 1 - Enables all features
# String - Enables one or more features, separated by commas
if Vagrant::Util::Experimental.enabled?
experimental = Vagrant::Util::Experimental.features_requested
ui = Vagrant::UI::Prefixed.new(env.ui, "vagrant")
logger.debug("Experimental flag is enabled")
if Vagrant::Util::Experimental.global_enabled?
ui.warn(I18n.t("vagrant.general.experimental.all"), bold: true, prefix: true, channel: :error)
else
ui.warn(I18n.t("vagrant.general.experimental.features", features: experimental.join(", ")), bold: true, prefix: true, channel: :error)
end
end
begin
# Execute the CLI interface, and exit with the proper error code
exit_status = env.cli(argv)

View File

@ -53,7 +53,7 @@ __vagrantinvestigate() {
_vagrant() {
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
commands="box connect destroy docker-exec docker-logs docker-run global-status halt help init list-commands login package plugin provision push rdp reload resume rsync rsync-auto share snapshot ssh ssh-config status suspend up version"
commands="box cloud connect destroy docker-exec docker-logs docker-run global-status halt help init list-commands login package plugin provision push rdp reload resume rsync rsync-auto share snapshot ssh ssh-config status suspend up version"
if [ $COMP_CWORD == 1 ]
then
@ -75,7 +75,19 @@ _vagrant() {
then
local vm_list=$(find "${vagrant_state_file}/machines" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
fi
local up_commands="--no-provision"
local up_commands="\
--provision \
--no-provision \
--provision-with \
--destroy-on-error \
--no-destroy-on-error \
--parallel \
--no-parallel
--provider \
--install-provider \
--no-install-provider \
-h \
--help"
COMPREPLY=($(compgen -W "${up_commands} ${vm_list}" -- ${cur}))
return 0
;;
@ -85,7 +97,7 @@ _vagrant() {
then
running_vm_list=$(grep 'active' "${vagrant_state_file}" | sed -e 's/"active"://' | tr ',' '\n' | cut -d '"' -f 2 | tr '\n' ' ')
else
running_vm_list=$(find "${vagrant_state_file}" -type f -name "id" | awk -F"/" '{print $(NF-2)}')
running_vm_list=$(find "${vagrant_state_file}/machines" -type f -name "id" | awk -F"/" '{print $(NF-2)}')
fi
COMPREPLY=($(compgen -W "${running_vm_list}" -- ${cur}))
return 0
@ -95,6 +107,11 @@ _vagrant() {
COMPREPLY=($(compgen -W "${box_commands}" -- ${cur}))
return 0
;;
"cloud")
cloud_commands="auth box search provider publish version"
COMPREPLY=($(compgen -W "${cloud_commands}" -- ${cur}))
return 0
;;
"plugin")
plugin_commands="install license list uninstall update"
COMPREPLY=($(compgen -W "${plugin_commands}" -- ${cur}))
@ -140,6 +157,15 @@ _vagrant() {
;;
esac
;;
"snapshot")
case "$prev" in
"restore"|"delete")
local snapshot_list=$(vagrant snapshot list)
COMPREPLY=($(compgen -W "${snapshot_list}" -- ${cur}))
return 0
;;
esac
;;
*)
;;
esac

View File

@ -7,4 +7,4 @@ Cmnd_Alias VAGRANT_SMB_LIST = /usr/sbin/sharing -l
Cmnd_Alias VAGRANT_SMB_PLOAD = /bin/launchctl load -w /System/Library/LaunchDaemons/com.apple.smb.preferences.plist
Cmnd_Alias VAGRANT_SMB_DLOAD = /bin/launchctl load -w /System/Library/LaunchDaemons/com.apple.smbd.plist
Cmnd_Alias VAGRANT_SMB_DSTART = /bin/launchctl start com.apple.smbd
%admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_SMB_ADD, VAGRANT_SMB_REMOVE, VAGRANT_SMB_LIST, VAGRANT_SMB_PLOAD, VAGRANT_SMB_DLOAD VAGRANT_SMB_DSTART
%admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE, VAGRANT_SMB_ADD, VAGRANT_SMB_REMOVE, VAGRANT_SMB_LIST, VAGRANT_SMB_PLOAD, VAGRANT_SMB_DLOAD, VAGRANT_SMB_DSTART

View File

@ -49,7 +49,16 @@ if ENV["VAGRANT_LOG"] && ENV["VAGRANT_LOG"] != ""
# Set the logging level on all "vagrant" namespaced
# logs as long as we have a valid level.
if level
logger = Log4r::Logger.new("vagrant")
# NOTE: We must do this little hack to allow
# rest-client to write using the `<<` operator.
# See https://github.com/rest-client/rest-client/issues/34#issuecomment-290858
# for more information
class VagrantLogger < Log4r::Logger
def << (msg)
debug(msg.strip)
end
end
logger = VagrantLogger.new("vagrant")
logger.outputters = Log4r::Outputter.stderr
logger.level = level
base_formatter = Log4r::BasicFormatter.new
@ -59,6 +68,11 @@ if ENV["VAGRANT_LOG"] && ENV["VAGRANT_LOG"] != ""
date_pattern: "%F %T"
)
end
# Vagrant Cloud gem uses RestClient to make HTTP requests, so
# log them if debug is enabled and use Vagrants logger
require 'rest_client'
RestClient.log = logger
Log4r::Outputter.stderr.formatter = Vagrant::Util::LoggingFormatter.new(base_formatter)
logger = nil
end

View File

@ -15,6 +15,7 @@ module Vagrant
autoload :Confirm, "vagrant/action/builtin/confirm"
autoload :ConfigValidate, "vagrant/action/builtin/config_validate"
autoload :DestroyConfirm, "vagrant/action/builtin/destroy_confirm"
autoload :Disk, "vagrant/action/builtin/disk"
autoload :EnvSet, "vagrant/action/builtin/env_set"
autoload :GracefulHalt, "vagrant/action/builtin/graceful_halt"
autoload :HandleBox, "vagrant/action/builtin/handle_box"

View File

@ -0,0 +1,31 @@
module Vagrant
module Action
module Builtin
# This class is intended to be used by the Action::Warden class for executing
# action triggers before any given action.
#
# @param [Symbol] action_name - name to fire trigger on
# @param [Vagrant::Plugin::V2::Triger] triggers - trigger object
class AfterTriggerAction
# @param [Symbol] action_name - The action class name to fire trigger on
# @param [Vagrant::Plugin::V2::Triger] triggers - trigger object
def initialize(app, env, action_name, triggers)
@app = app
@env = env
@triggers = triggers
@action_name = action_name
end
def call(env)
machine = env[:machine]
machine_name = machine.name if machine
@triggers.fire_triggers(@action_name, :after, machine_name, :action) if Vagrant::Util::Experimental.feature_enabled?("typed_triggers");
# Carry on
@app.call(env)
end
end
end
end
end

View File

@ -0,0 +1,28 @@
module Vagrant
module Action
module Builtin
# This class is intended to be used by the Action::Warden class for executing
# action triggers before any given action.
class BeforeTriggerAction
# @param [Symbol] action_name - The action class name to fire trigger on
# @param [Vagrant::Plugin::V2::Triger] triggers - trigger object
def initialize(app, env, action_name, triggers)
@app = app
@env = env
@triggers = triggers
@action_name = action_name
end
def call(env)
machine = env[:machine]
machine_name = machine.name if machine
@triggers.fire_triggers(@action_name, :before, machine_name, :action) if Vagrant::Util::Experimental.feature_enabled?("typed_triggers");
# Carry on
@app.call(env)
end
end
end
end
end

View File

@ -348,9 +348,15 @@ module Vagrant
end
if opts[:checksum] && opts[:checksum_type]
env[:ui].detail(I18n.t("vagrant.actions.box.add.checksumming"))
validate_checksum(
opts[:checksum_type], opts[:checksum], box_url)
if opts[:checksum].to_s.strip.empty?
@logger.warn("Given checksum is empty, cannot validate checksum for box")
elsif opts[:checksum_type].to_s.strip.empty?
@logger.warn("Given checksum type is empty, cannot validate checksum for box")
else
env[:ui].detail(I18n.t("vagrant.actions.box.add.checksumming"))
validate_checksum(
opts[:checksum_type], opts[:checksum], box_url)
end
end
# Add the box!
@ -527,22 +533,11 @@ module Vagrant
end
def validate_checksum(checksum_type, checksum, path)
checksum_klass = case checksum_type.to_sym
when :md5
Digest::MD5
when :sha1
Digest::SHA1
when :sha256
Digest::SHA2
else
raise Errors::BoxChecksumInvalidType,
type: checksum_type.to_s
end
@logger.info("Validating checksum with #{checksum_klass}")
@logger.info("Validating checksum with #{checksum_type}")
@logger.info("Expected checksum: #{checksum}")
actual = FileChecksum.new(path, checksum_klass).checksum
actual = FileChecksum.new(path, checksum_type).checksum
@logger.info("Actual checksum: #{actual}")
if actual.casecmp(checksum) != 0
raise Errors::BoxChecksumMismatch,
actual: actual,

View File

@ -40,6 +40,7 @@ module Vagrant
# Have download options specified in the environment override
# options specified for the machine.
download_options = {
automatic_check: !env[:box_outdated_force],
ca_cert: env[:ca_cert] || machine.config.vm.box_download_ca_cert,
ca_path: env[:ca_path] || machine.config.vm.box_download_ca_path,
client_cert: env[:client_cert] ||
@ -50,7 +51,8 @@ module Vagrant
env[:ui].output(I18n.t(
"vagrant.box_outdated_checking_with_refresh",
name: box.name))
name: box.name,
version: box.version))
update = nil
begin
update = box.has_update?(constraints, download_options: download_options)
@ -68,15 +70,23 @@ module Vagrant
message: e.message))
end
env[:box_outdated] = update != nil
if update
local_update = check_outdated_local(env)
if update && (local_update.nil? || (local_update.version < update[1].version))
env[:ui].warn(I18n.t(
"vagrant.box_outdated_single",
name: update[0].name,
provider: box.provider,
current: box.version,
latest: update[1].version))
elsif local_update
env[:ui].warn(I18n.t(
"vagrant.box_outdated_local",
name: local_update.name,
old: box.version,
new: local_update.version))
env[:box_outdated] = true
else
check_outdated_local(env)
env[:box_outdated] = false
end
@app.call(env)
@ -91,19 +101,8 @@ module Vagrant
version ||= ""
version += "> #{machine.box.version}"
box = env[:box_collection].find(
env[:box_collection].find(
machine.box.name, machine.box.provider, version)
if box
env[:ui].warn(I18n.t(
"vagrant.box_outdated_local",
name: box.name,
old: machine.box.version,
new: box.version))
env[:box_outdated] = true
return
end
env[:box_outdated] = false
end
end
end

View File

@ -99,8 +99,11 @@ module Vagrant
b.use Confirm, message, force_key
end
# Keep used boxes, even if "force" is applied
keep_used_boxes = env[:keep_used_boxes]
result = env[:action_runner].run(stack, env)
if !result[:result]
if !result[:result] || keep_used_boxes
# They said "no", so continue with the next box
next
end

View File

@ -12,7 +12,7 @@ module Vagrant
def call(env)
if !env.key?(:config_validate) || env[:config_validate]
errors = env[:machine].config.validate(env[:machine])
errors = env[:machine].config.validate(env[:machine], env[:ignore_provider])
if errors && !errors.empty?
raise Errors::ConfigInvalid,

View File

@ -0,0 +1,39 @@
module Vagrant
module Action
module Builtin
class Disk
def initialize(app, env)
@app = app
@logger = Log4r::Logger.new("vagrant::action::builtin::disk")
end
def call(env)
machine = env[:machine]
defined_disks = get_disks(machine, env)
# Call into providers machine implementation for disk management
if !defined_disks.empty?
if machine.provider.capability?(:configure_disks)
machine.provider.capability(:configure_disks, defined_disks)
else
env[:ui].warn(I18n.t("vagrant.actions.disk.provider_unsupported",
provider: machine.provider_name))
end
end
# Continue On
@app.call(env)
end
def get_disks(machine, env)
return @_disks if @_disks
@_disks = []
@_disks = machine.config.vm.disks
@_disks
end
end
end
end
end

View File

@ -25,19 +25,114 @@ module Vagrant
# Store in the type map so that --provision-with works properly
@_provisioner_types[result] = provisioner.type
# Set top level provisioner name to provisioner configs name if top level name not set.
# This is mostly for handling the shell provisioner, if a user has set its name like:
#
# config.vm.provision "shell", name: "my_provisioner"
#
# Where `name` is a shell config option, not a top level provisioner class option
#
# Note: `name` is set to a symbol, since it is converted to one via #Config::VM.provision
provisioner_name = provisioner.name
if !provisioner_name
if provisioner.config.respond_to?(:name) &&
provisioner.config.name
provisioner_name = provisioner.config.name.to_sym
end
else
provisioner_name = provisioner_name.to_sym
end
# Build up the options
options = {
name: provisioner.name,
name: provisioner_name,
run: provisioner.run,
before: provisioner.before,
after: provisioner.after,
}
# Return the result
[result, options]
end
@_provisioner_instances = sort_provisioner_instances(@_provisioner_instances)
return @_provisioner_instances.compact
end
private
# Sorts provisioners based on order specified with before/after options
#
# @return [Array<Provisioner, Hash>]
def sort_provisioner_instances(pvs)
final_provs = []
root_provs = []
# extract root provisioners
root_provs = pvs.find_all { |_, o| o[:before].nil? && o[:after].nil? }
if root_provs.size == pvs.size
# no dependencies found
return pvs
end
# ensure placeholder variables are Arrays
dep_provs = []
each_provs = []
all_provs = []
# extract dependency provisioners
dep_provs = pvs.find_all { |_, o| o[:before].is_a?(String) || o[:after].is_a?(String) }
# extract each provisioners
each_provs = pvs.find_all { |_,o| o[:before] == :each || o[:after] == :each }
# extract all provisioners
all_provs = pvs.find_all { |_,o| o[:before] == :all || o[:after] == :all }
# insert provisioners in order
final_provs = root_provs
dep_provs.each do |p,options|
idx = 0
if options[:before]
idx = final_provs.index { |_, o| o[:name].to_s == options[:before] }
final_provs.insert(idx, [p, options])
elsif options[:after]
idx = final_provs.index { |_, o| o[:name].to_s == options[:after] }
idx += 1
final_provs.insert(idx, [p, options])
end
end
# Add :each and :all provisioners in reverse to preserve order in Vagrantfile
tmp_final_provs = []
final_provs.each_with_index do |(prv,o), i|
tmp_before = []
tmp_after = []
each_provs.reverse_each do |p, options|
if options[:before]
tmp_before << [p,options]
elsif options[:after]
tmp_after << [p,options]
end
end
tmp_final_provs += tmp_before unless tmp_before.empty?
tmp_final_provs += [[prv,o]]
tmp_final_provs += tmp_after unless tmp_after.empty?
end
final_provs = tmp_final_provs
# Add all to final array
all_provs.reverse_each do |p,options|
if options[:before]
final_provs.insert(0, [p,options])
elsif options[:after]
final_provs.push([p,options])
end
end
return final_provs
end
# This will return a mapping of a provisioner instance to its
# type.
def provisioner_type_map(env)
@ -47,6 +142,13 @@ module Vagrant
# Return the type map
@_provisioner_types
end
# @private
# Reset the cached values for platform. This is not considered a public
# API and should only be used for testing.
def self.reset!
instance_variables.each(&method(:remove_instance_variable))
end
end
end
end

View File

@ -97,8 +97,14 @@ module Vagrant
end
end
folder_data = JSON.dump(folders)
# Scrub any register credentials from the synced folders
# configuration data to prevent accidental leakage
folder_data = Util::CredentialScrubber.desensitize(folder_data)
machine.data_dir.join("synced_folders").open("w") do |f|
f.write(JSON.dump(folders))
f.write(folder_data)
end
end

View File

@ -36,17 +36,35 @@ module Vagrant
# Get the command and wrap it in a login shell
command = ShellQuote.escape(env[:ssh_run_command], "'")
command = "#{env[:machine].config.ssh.shell} -c '#{command}'"
if env[:machine].config.vm.communicator == :winssh
shell = env[:machine].config.winssh.shell
else
shell = env[:machine].config.ssh.shell
end
if shell == "cmd"
# Add an extra space to the command so cmd.exe quoting works
# properly
command = "#{shell} /C #{command} "
elsif shell == "powershell"
command = "$ProgressPreference = \"SilentlyContinue\"; #{command}"
command = Base64.strict_encode64(command.encode("UTF-16LE", "UTF-8"))
command = "#{shell} -encodedCommand #{command}"
else
command = "#{shell} -c '#{command}'"
end
# Execute!
opts = env[:ssh_opts] || {}
opts[:extra_args] ||= []
# Allow the user to specify a tty or non-tty manually, but if they
# don't then we default to a TTY
# don't then we default to a TTY unless they are using WinSSH
if !opts[:extra_args].include?("-t") &&
!opts[:extra_args].include?("-T") &&
env[:tty]
env[:tty] &&
env[:machine].config.vm.communicator != :winssh
opts[:extra_args] << "-t"
end

View File

@ -80,8 +80,10 @@ module Vagrant
@app.call(env)
@env[:ui].info I18n.t("vagrant.actions.general.package.compressing", fullpath: fullpath)
copy_include_files
setup_private_key
write_metadata_json
compress
end
@ -151,6 +153,22 @@ module Vagrant
end
end
# Write the metadata file into the box so that the provider
# can be automatically detected when adding the box
def write_metadata_json
meta_path = File.join(@env["package.directory"], "metadata.json")
return if File.exist?(meta_path)
if @env[:machine] && @env[:machine].provider_name
provider_name = @env[:machine].provider_name
elsif @env[:env] && @env[:env].default_provider
provider_name = @env[:env].default_provider
else
return
end
File.write(meta_path, {provider: provider_name}.to_json)
end
# This will copy the generated private key into the box and use
# it for SSH by default. We have to do this because we now generate
# random keypairs on boot, so packaged boxes would stop working

View File

@ -2,6 +2,7 @@ require 'log4r'
require 'vagrant/action/hook'
require 'vagrant/util/busy'
require 'vagrant/util/experimental'
module Vagrant
module Action
@ -33,6 +34,19 @@ module Vagrant
environment.merge!(@lazy_globals.call) if @lazy_globals
environment.merge!(options || {})
if Vagrant::Util::Experimental.feature_enabled?("typed_triggers")
# NOTE: Triggers are initialized later in the Action::Runer because of
# how `@lazy_globals` are evaluated. Rather than trying to guess where
# the `env` is coming from, we can wait until they're merged into a single
# hash above.
env = environment[:env]
machine = environment[:machine]
machine_name = machine.name if machine
ui = Vagrant::UI::Prefixed.new(env.ui, "vagrant")
triggers = Vagrant::Plugin::V2::Trigger.new(env, env.vagrantfile.config.trigger, machine, ui)
end
# Setup the action hooks
hooks = Vagrant.plugin("2").manager.action_hooks(environment[:action_name])
if !hooks.empty?
@ -52,19 +66,43 @@ module Vagrant
ui = environment[:ui] if environment.key?(:ui)
int_callback = lambda do
if environment[:interrupted]
ui.error I18n.t("vagrant.actions.runner.exit_immediately") if ui
if ui
begin
ui.error I18n.t("vagrant.actions.runner.exit_immediately")
rescue ThreadError
# We're being called in a trap-context. Wrap in a thread.
Thread.new {
ui.error I18n.t("vagrant.actions.runner.exit_immediately")
}.join(THREAD_MAX_JOIN_TIMEOUT)
end
end
abort
end
ui.warn I18n.t("vagrant.actions.runner.waiting_cleanup") if ui && !@@reported_interrupt
if ui && !@@reported_interrupt
begin
ui.warn I18n.t("vagrant.actions.runner.waiting_cleanup")
rescue ThreadError
# We're being called in a trap-context. Wrap in a thread.
Thread.new {
ui.warn I18n.t("vagrant.actions.runner.waiting_cleanup")
}.join(THREAD_MAX_JOIN_TIMEOUT)
end
end
environment[:interrupted] = true
@@reported_interrupt = true
end
action_name = environment[:action_name]
triggers.fire_triggers(action_name, :before, machine_name, :hook) if Vagrant::Util::Experimental.feature_enabled?("typed_triggers")
# We place a process lock around every action that is called
@logger.info("Running action: #{environment[:action_name]} #{callable_id}")
Util::Busy.busy(int_callback) { callable.call(environment) }
triggers.fire_triggers(action_name, :after, machine_name, :hook) if Vagrant::Util::Experimental.feature_enabled?("typed_triggers")
# Return the environment in case there are things in there that
# the caller wants to use.
environment

View File

@ -1,4 +1,7 @@
require "log4r"
require 'vagrant/util/experimental'
require 'vagrant/action/builtin/before_trigger'
require 'vagrant/action/builtin/after_trigger'
module Vagrant
module Action
@ -16,8 +19,21 @@ module Vagrant
attr_accessor :actions, :stack
def initialize(actions, env)
if Vagrant::Util::Experimental.feature_enabled?("typed_triggers")
if env[:trigger_env]
@env = env[:trigger_env]
else
@env = env[:env]
end
machine = env[:machine]
machine_name = machine.name if machine
ui = Vagrant::UI::Prefixed.new(@env.ui, "vagrant")
@triggers = Vagrant::Plugin::V2::Trigger.new(@env, @env.vagrantfile.config.trigger, machine, ui)
end
@stack = []
@actions = actions.map { |m| finalize_action(m, env) }
@actions = actions.map { |m| finalize_action(m, env) }.flatten
@logger = Log4r::Logger.new("vagrant::action::warden")
@last_error = nil
end
@ -31,7 +47,16 @@ module Vagrant
raise Errors::VagrantInterrupt if env[:interrupted]
action = @actions.shift
@logger.info("Calling IN action: #{action}")
if !action.is_a?(Proc) && env[:hook]
hook_name = action.class.name.split("::").last.
gsub(/([a-z])([A-Z])/, '\1_\2').gsub('-', '_').downcase
end
env[:hook].call("before_#{hook_name}".to_sym) if hook_name
@stack.unshift(action).first.call(env)
env[:hook].call("after_#{hook_name}".to_sym) if hook_name
raise Errors::VagrantInterrupt if env[:interrupted]
@logger.info("Calling OUT action: #{action}")
rescue SystemExit
@ -87,7 +112,17 @@ module Vagrant
if klass.is_a?(Class)
# A action klass which is to be instantiated with the
# app, env, and any arguments given
klass.new(self, env, *args, &block)
# We wrap the action class in two Trigger method calls so that
# action triggers can fire before and after each given action in the stack.
klass_name = klass.name
[Vagrant::Action::Builtin::BeforeTriggerAction.new(self, env,
klass_name,
@triggers),
klass.new(self, env, *args, &block),
Vagrant::Action::Builtin::AfterTriggerAction.new(self, env,
klass_name,
@triggers)]
elsif klass.respond_to?(:call)
# Make it a lambda which calls the item then forwards
# up the chain

View File

@ -71,6 +71,10 @@ module Vagrant
thread = Thread.new do
Thread.current[:error] = nil
# Note that this thread is being used for running
# a batch action
Thread.current[:batch_parallel_action] = par
# Record our pid when we started in order to figure out if
# we've forked...
start_pid = Process.pid
@ -160,6 +164,16 @@ module Vagrant
if !errors.empty?
raise Errors::BatchMultiError, message: errors.join("\n\n")
end
# Check if any threads set an exit code and exit if found. If
# multiple threads have exit code values set, the first encountered
# will be the value used.
threads.each do |thread|
if thread[:exit_code]
@logger.debug("Found exit code set within batch action thread. Exiting")
Process.exit!(thread[:exit_code])
end
end
end
end
end

View File

@ -16,6 +16,9 @@ module Vagrant
class Box
include Comparable
# Number of seconds to wait between checks for box updates
BOX_UPDATE_CHECK_INTERVAL = 3600
# The box name. This is the logical name used when adding the box.
#
# @return [String]
@ -154,6 +157,11 @@ module Vagrant
raise Errors::BoxUpdateNoMetadata, name: @name
end
if download_options.delete(:automatic_check) && !automatic_update_check_allowed?
@logger.info("Skipping box update check")
return
end
version += ", " if version
version ||= ""
version += "> #{@version}"
@ -164,6 +172,25 @@ module Vagrant
[md, newer, newer.provider(@provider)]
end
# Check if a box update check is allowed. Uses a file
# in the box data directory to track when the last auto
# update check was performed and returns true if the
# BOX_UPDATE_CHECK_INTERVAL has passed.
#
# @return [Boolean]
def automatic_update_check_allowed?
check_path = directory.join("box_update_check")
if check_path.exist?
last_check_span = Time.now.to_i - check_path.mtime.to_i
if last_check_span < BOX_UPDATE_CHECK_INTERVAL
@logger.info("box update check is under the interval threshold")
return false
end
end
FileUtils.touch(check_path)
true
end
# This repackages this box and outputs it to the given path.
#
# @param [Pathname] path The full path (filename included) of where

View File

@ -116,7 +116,7 @@ module Vagrant
# Extract the box into a temporary directory.
@logger.debug("Unpacking box into temporary directory: #{temp_dir}")
result = Util::Subprocess.execute(
"bsdtar", "-v", "-x", "-m", "-s", "|\\\\\|/|", "-C", temp_dir.to_s, "-f", path.to_s)
"bsdtar", "--no-same-owner", "--no-same-permissions", "-v", "-x", "-m", "-s", "|\\\\\|/|", "-C", temp_dir.to_s, "-f", path.to_s)
if result.exit_code != 0
raise Errors::BoxUnpackageFailure,
output: result.stderr.to_s
@ -233,14 +233,23 @@ module Vagrant
version = versiondir.basename.to_s
versiondir.children(true).each do |provider|
# Ensure version of box is correct before continuing
if !Gem::Version.correct?(version)
ui = Vagrant::UI::Prefixed.new(Vagrant::UI::Colored.new, "vagrant")
ui.warn(I18n.t("vagrant.box_version_malformed",
version: version, box_name: box_name))
@logger.debug("Invalid version #{version} for box #{box_name}")
next
end
# Verify this is a potentially valid box. If it looks
# correct enough then include it.
if provider.directory? && provider.join("metadata.json").file?
provider_name = provider.basename.to_s.to_sym
@logger.debug("Box: #{box_name} (#{provider_name})")
@logger.debug("Box: #{box_name} (#{provider_name}, #{version})")
results << [box_name, version, provider_name]
else
@logger.debug("Invalid box, ignoring: #{provider}")
@logger.debug("Invalid box #{box_name}, ignoring: #{provider}")
end
end
end

View File

@ -68,11 +68,25 @@ module Vagrant
# Returns all the versions supported by this metadata. These
# versions are sorted so the last element of the list is the
# latest version.
# latest version. Optionally filter versions by a matching
# provider.
#
# @return[Array<String>]
def versions
@version_map.keys.sort.map(&:to_s)
def versions(**opts)
provider = nil
provider = opts[:provider].to_sym if opts[:provider]
if provider
@version_map.select do |version, raw|
if raw["providers"]
raw["providers"].detect do |p|
p["name"].to_sym == provider
end
end
end.keys.sort.map(&:to_s)
else
@version_map.keys.sort.map(&:to_s)
end
end
# Represents a single version within the metadata.

View File

@ -24,8 +24,8 @@ module Vagrant
# Default gem repositories
DEFAULT_GEM_SOURCES = [
"https://rubygems.org/".freeze,
HASHICORP_GEMSTORE
HASHICORP_GEMSTORE,
"https://rubygems.org/".freeze
].freeze
def self.instance
@ -40,6 +40,20 @@ module Vagrant
def initialize
@plugin_gem_path = Vagrant.user_data_path.join("gems", RUBY_VERSION).freeze
@logger = Log4r::Logger.new("vagrant::bundler")
# TODO: Remove fix when https://github.com/rubygems/rubygems/pull/2735
# gets merged and released
#
# Because of a rubygems bug, we need to set the gemrc file path
# through this method rather than relying on the environment varible
# GEMRC. On windows, that path gets split on `:`: and `;`, which means
# the drive letter gets treated as its own path. If that path exists locally,
# (like having a random folder called `c` where the library was invoked),
# it fails thinking the folder `c` is a gemrc file.
gemrc_val = ENV["GEMRC"]
ENV["GEMRC"] = ""
Gem.configuration = Gem::ConfigFile.new(["--config-file", gemrc_val])
ENV["GEMRC"] = gemrc_val
end
# Enable Vagrant environment specific plugins at given data path
@ -62,7 +76,8 @@ module Vagrant
# Add HashiCorp RubyGems source
if !Gem.sources.include?(HASHICORP_GEMSTORE)
Gem.sources << HASHICORP_GEMSTORE
sources = [HASHICORP_GEMSTORE] + Gem.sources.sources
Gem.sources.replace(sources)
end
# Generate dependencies for all registered plugins
@ -287,13 +302,19 @@ module Vagrant
end
source_list[name] << source
end
Gem::Dependency.new(name, gem_version)
Gem::Dependency.new(name, *gem_version.split(","))
end
if Vagrant.strict_dependency_enforcement
@logger.debug("Enabling strict dependency enforcement")
plugin_deps += vagrant_internal_specs.map do |spec|
next if system_plugins.include?(spec.name)
# If we are not running within the installer and
# we are not within a bundler environment then we
# only want activated specs
if !Vagrant.in_installer? && !Vagrant.in_bundler?
next if !spec.activated?
end
Gem::Dependency.new(spec.name, spec.version)
end.compact
else
@ -396,8 +417,13 @@ module Vagrant
Gem::Resolver.compose_sets(*sets)
end
# @return [Array<[Gem::Specification, String]>] spec and directory pairs
# @return [Array<[Gem::Specification]>] spec list
def vagrant_internal_specs
# activate any dependencies up front so we can always
# pin them when resolving
Gem::Specification.find { |s| s.name == "vagrant" && s.activated? }.
runtime_dependencies.each { |d| gem d.name, *d.requirement.as_list }
# discover all the gems we have available
list = {}
directories = [Gem::Specification.default_specifications_dir]
Gem::Specification.find_all{true}.each do |spec|

View File

@ -1,6 +1,8 @@
require 'log4r'
require 'optparse'
require 'vagrant/util/experimental'
module Vagrant
# Manages the command line interface to Vagrant.
class CLI < Vagrant.plugin("2", :command)
@ -11,6 +13,11 @@ module Vagrant
@logger = Log4r::Logger.new("vagrant::cli")
@main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
if Vagrant::Util::Experimental.feature_enabled?("typed_triggers")
ui = Vagrant::UI::Prefixed.new(env.ui, "vagrant")
@triggers = Vagrant::Plugin::V2::Trigger.new(env, env.vagrantfile.config.trigger, nil, ui)
end
Util::CheckpointClient.instance.setup(env).check
@logger.info("CLI: #{@main_args.inspect} #{@sub_command.inspect} #{@sub_args.inspect}")
end
@ -23,6 +30,10 @@ module Vagrant
return 0
end
if @sub_command == "login"
$stderr.puts "WARNING: This command has been deprecated and aliased to `vagrant cloud auth login`"
end
# If we reached this far then we must have a subcommand. If not,
# then we also just print the help and exit.
command_plugin = nil
@ -51,7 +62,9 @@ module Vagrant
# Initialize and execute the command class, returning the exit status.
result = 0
begin
@triggers.fire_triggers(@sub_command.to_sym, :before, nil, :command) if Vagrant::Util::Experimental.feature_enabled?("typed_triggers")
result = command_class.new(@sub_args, @env).execute
@triggers.fire_triggers(@sub_command.to_sym, :after, nil, :command) if Vagrant::Util::Experimental.feature_enabled?("typed_triggers")
rescue Interrupt
@env.ui.info(I18n.t("vagrant.cli_interrupt"))
result = 1

View File

@ -129,7 +129,7 @@ module Vagrant
path = "(unknown)"
if e.backtrace && e.backtrace[0]
backtrace_tokens = e.backtrace[0].split(":")
path = backtrace_tokens[0]
path = e.backtrace.first.slice(0, e.backtrace.first.rindex(':')).rpartition(':').first
backtrace_tokens.each do |part|
if part =~ /\d+/
line = part.to_i

View File

@ -60,14 +60,18 @@ module Vagrant
#
# @param [Environment] env
# @return [Hash]
def validate(machine)
def validate(machine, ignore_provider=nil)
# Go through each of the configuration keys and validate
errors = {}
@keys.each do |_key, instance|
if instance.respond_to?(:validate)
# Validate this single item, and if we have errors then
# we merge them into our total errors list.
result = instance.validate(machine)
if _key == :vm
result = instance.validate(machine, ignore_provider)
else
result = instance.validate(machine)
end
if result && !result.empty?
errors = Util.merge_errors(errors, result)
end

View File

@ -175,9 +175,7 @@ module Vagrant
# Load any global plugins
Vagrant::Plugin::Manager.instance.load_plugins(plugins)
if !vagrantfile.config.vagrant.plugins.empty?
plugins = process_configured_plugins
end
plugins = process_configured_plugins
# Call the hooks that does not require configurations to be loaded
# by using a "clean" action runner
@ -210,7 +208,8 @@ module Vagrant
home_path: home_path,
root_path: root_path,
tmp_path: tmp_path,
ui: @ui
ui: @ui,
env: self
}
end
end
@ -906,6 +905,13 @@ module Vagrant
begin
@logger.debug("Creating: #{@local_data_path}")
FileUtils.mkdir_p(@local_data_path)
# Create the rgloader/loader file so we can use encoded files.
loader_file = @local_data_path.join("rgloader", "loader.rb")
if !loader_file.file?
source_loader = Vagrant.source_root.join("templates/rgloader.rb")
FileUtils.mkdir_p(@local_data_path.join("rgloader").to_s)
FileUtils.cp(source_loader.to_s, loader_file.to_s)
end
rescue Errno::EACCES
raise Errors::LocalDataDirectoryNotAccessible,
local_data_path: @local_data_path.to_s
@ -914,6 +920,49 @@ module Vagrant
protected
# Attempt to guess the configured provider in use. Will fallback
# to the default provider if an explicit provider name is not
# provided. This can be pretty error prone, but is used during
# initial environment setup to allow loading plugins so it doesn't
# need to be perfect
#
# @return [String]
def guess_provider
gp = nil
ARGV.each_with_index do |val, idx|
if val.start_with?("--provider=")
gp = val.split("=", 2).last
break
elsif val == "--provider"
gp = ARGV[idx+1]
break
end
end
return gp.to_sym if gp
begin
default_provider
rescue Errors::NoDefaultProvider
# if a provider cannot be determined just return nil
nil
end
end
# Load any configuration provided by guests defined within
# the Vagrantfile to pull plugin information they may have
# defined.
def find_configured_plugins
plugins = []
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, false)[:config]
end
result = plugins.reverse.inject(Vagrant::Util::HashWithIndifferentAccess.new) do |memo, val|
Vagrant::Util::DeepMerge.deep_merge(memo, val.vagrant.plugins)
end
Vagrant::Util::DeepMerge.deep_merge(result, vagrantfile.config.vagrant.plugins)
end
# Check for any local plugins defined within the Vagrantfile. If
# found, validate they are available. If they are not available,
# request to install them, or raise an exception
@ -931,7 +980,7 @@ module Vagrant
# Check if defined plugins are installed
installed = Plugin::Manager.instance.installed_plugins
needs_install = []
config_plugins = vagrantfile.config.vagrant.plugins
config_plugins = find_configured_plugins
config_plugins.each do |name, info|
if !installed[name]
needs_install << name
@ -972,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

@ -160,6 +160,10 @@ module Vagrant
error_key(:box_config_changing_box)
end
class BoxFileNotExist < VagrantError
error_key(:box_file_not_exist)
end
class BoxMetadataCorrupted < VagrantError
error_key(:box_metadata_corrupted)
end
@ -432,6 +436,10 @@ module Vagrant
error_key(:machine_action_locked)
end
class MachineFolderNotAccessible < VagrantError
error_key(:machine_folder_not_accessible)
end
class MachineGuestNotReady < VagrantError
error_key(:machine_guest_not_ready)
end
@ -664,6 +672,10 @@ module Vagrant
error_key(:push_strategy_not_provided)
end
class RSyncPostCommandError < VagrantError
error_key(:rsync_post_command_error)
end
class RSyncError < VagrantError
error_key(:rsync_error)
end
@ -796,6 +808,10 @@ module Vagrant
error_key(:triggers_bad_exit_codes)
end
class TriggersGuestNotExist < VagrantError
error_key(:triggers_guest_not_exist)
end
class TriggersGuestNotRunning < VagrantError
error_key(:triggers_guest_not_running)
end
@ -816,6 +832,30 @@ module Vagrant
error_key(:unimplemented_provider_action)
end
class UploadInvalidCompressionType < VagrantError
error_key(:upload_invalid_compression_type)
end
class UploadMissingExtractCapability < VagrantError
error_key(:upload_missing_extract_capability)
end
class UploadMissingTempCapability < VagrantError
error_key(:upload_missing_temp_capability)
end
class UploadSourceMissing < VagrantError
error_key(:upload_source_missing)
end
class UploaderError < VagrantError
error_key(:uploader_error)
end
class UploaderInterrupted < UploaderError
error_key(:uploader_interrupted)
end
class VagrantInterrupt < VagrantError
error_key(:interrupted)
end
@ -968,6 +1008,10 @@ module Vagrant
error_key(:power_off, "vagrant.actions.vm.export")
end
class WinRMInvalidCommunicator < VagrantError
error_key(:winrm_invalid_communicator)
end
class WSLVagrantVersionMismatch < VagrantError
error_key(:wsl_vagrant_version_mismatch)
end

View File

@ -110,7 +110,7 @@ module Vagrant
@ui = Vagrant::UI::Prefixed.new(@env.ui, @name)
@ui_mutex = Mutex.new
@state_mutex = Mutex.new
@triggers = Vagrant::Plugin::V2::Trigger.new(@env, @config.trigger, self)
@triggers = Vagrant::Plugin::V2::Trigger.new(@env, @config.trigger, self, @ui)
# Read the ID, which is usually in local storage
@id = nil
@ -160,10 +160,7 @@ module Vagrant
# as extra data set on the environment hash for the middleware
# runner.
def action(name, opts=nil)
plugins = Vagrant::Plugin::Manager.instance.installed_plugins
if !plugins.keys.include?("vagrant-triggers")
@triggers.fire_triggers(name, :before, @name.to_s)
end
@triggers.fire_triggers(name, :before, @name.to_s, :action)
@logger.info("Calling action: #{name} on provider #{@provider}")
@ -175,6 +172,10 @@ module Vagrant
# Extra env keys are the remaining opts
extra_env = opts.dup
# An environment is required for triggers to function properly. This is
# passed in specifically for the `#Action::Warden` class triggers. We call it
# `:trigger_env` instead of `env` in case it collides with an existing environment
extra_env[:trigger_env] = @env
check_cwd # Warns the UI if the machine was last used on a different dir
@ -210,9 +211,7 @@ module Vagrant
action_result
end
if !plugins.keys.include?("vagrant-triggers")
@triggers.fire_triggers(name, :after, @name.to_s)
end
@triggers.fire_triggers(name, :after, @name.to_s, :action)
# preserve returning environment after machine action runs
return return_env
rescue Errors::EnvironmentLockedError
@ -400,7 +399,10 @@ module Vagrant
# Read the id file from the data directory if it exists as the
# ID for the pre-existing physical representation of this machine.
id_file = @data_dir.join("id")
@id = id_file.read.chomp if id_file.file?
id_content = id_file.read.strip if id_file.file?
if !id_content.to_s.empty?
@id = id_content
end
end
if @id != old_id && @provider
@ -452,9 +454,11 @@ module Vagrant
info[:keys_only] ||= @config.ssh.default.keys_only
info[:verify_host_key] ||= @config.ssh.default.verify_host_key
info[:username] ||= @config.ssh.default.username
info[:remote_user] ||= @config.ssh.default.remote_user
info[:compression] ||= @config.ssh.default.compression
info[:dsa_authentication] ||= @config.ssh.default.dsa_authentication
info[:extra_args] ||= @config.ssh.default.extra_args
info[:config] ||= @config.ssh.default.config
# We set overrides if they are set. These take precedence over
# provider-returned data.
@ -466,7 +470,9 @@ module Vagrant
info[:dsa_authentication] = @config.ssh.dsa_authentication
info[:username] = @config.ssh.username if @config.ssh.username
info[:password] = @config.ssh.password if @config.ssh.password
info[:remote_user] = @config.ssh.remote_user if @config.ssh.remote_user
info[:extra_args] = @config.ssh.extra_args if @config.ssh.extra_args
info[:config] = @config.ssh.config if @config.ssh.config
# We also set some fields that are purely controlled by Vagrant
info[:forward_agent] = @config.ssh.forward_agent
@ -593,7 +599,7 @@ module Vagrant
).chomp
end
if vagrant_cwd != @env.root_path.to_s
if !File.identical?(vagrant_cwd.to_s, @env.root_path.to_s)
if vagrant_cwd
ui.warn(I18n.t(
'vagrant.moved_cwd',

View File

@ -117,6 +117,13 @@ module Vagrant
# @see #execute
def test(command, opts=nil)
end
# Reset the communicator. For communicators which establish
# a persistent connection to the remote machine, this connection
# should be terminated and re-established. The communicator
# instance should be in a "fresh" state after calling this method.
def reset!
end
end
end
end

View File

@ -20,20 +20,35 @@ module Vagrant
# @param [Vagrant::Environment] env Vagrant environment
# @param [Kernel_V2::TriggerConfig] config Trigger configuration
# @param [Vagrant::Machine] machine Active Machine
def initialize(env, config, machine)
# @param [Vagrant::UI] ui Class for printing messages to user
def initialize(env, config, machine, ui)
@env = env
@config = config
@machine = machine
@ui = ui
@logger = Log4r::Logger.new("vagrant::trigger::#{self.class.to_s.downcase}")
end
# Fires all triggers, if any are defined for the action and guest
# Fires all triggers, if any are defined for the action and guest. Returns early
# and logs a warning if the community plugin `vagrant-triggers` is installed
#
# @param [Symbol] action Vagrant command to fire trigger on
# @param [Symbol] stage :before or :after
# @param [String] guest_name The guest that invoked firing the triggers
def fire_triggers(action, stage, guest_name)
def fire_triggers(action, stage, guest_name, type)
if community_plugin_detected?
@logger.warn("Community plugin `vagrant-triggers detected, so core triggers will not fire")
return
end
if !action
@logger.warn("Action given is nil, no triggers will fire")
return
else
action = action.to_sym
end
# get all triggers matching action
triggers = []
if stage == :before
@ -51,27 +66,41 @@ module Vagrant
guest_name: guest_name
end
triggers = filter_triggers(triggers, guest_name)
triggers = filter_triggers(triggers, guest_name, type)
if !triggers.empty?
@logger.info("Firing trigger for action #{action} on guest #{guest_name}")
@machine.ui.info(I18n.t("vagrant.trigger.start", stage: stage, action: action))
@ui.info(I18n.t("vagrant.trigger.start", type: type, stage: stage, action: action))
fire(triggers, guest_name)
end
end
protected
#-------------------------------------------------------------------
# Internal methods, don't call these.
#-------------------------------------------------------------------
# Looks up if the community plugin `vagrant-triggers` is installed
# and also caches the result
#
# @return [Boolean]
def community_plugin_detected?
if !defined?(@_triggers_enabled)
plugins = Vagrant::Plugin::Manager.instance.installed_plugins
@_triggers_enabled = plugins.keys.include?("vagrant-triggers")
end
@_triggers_enabled
end
# Filters triggers to be fired based on configured restraints
#
# @param [Array] triggers An array of triggers to be filtered
# @param [String] guest_name The name of the current guest
# @param [Symbol] type The type of trigger (:command or :type)
# @return [Array] The filtered array of triggers
def filter_triggers(triggers, guest_name)
def filter_triggers(triggers, guest_name, type)
# look for only_on trigger constraint and if it doesn't match guest
# name, throw it away also be sure to preserve order
filter = triggers.dup
@ -81,7 +110,7 @@ module Vagrant
match = false
if trigger.only_on
trigger.only_on.each do |o|
if o.match(guest_name)
if o.match(guest_name.to_s)
# trigger matches on current guest, so we're fine to use it
match = true
break
@ -91,6 +120,10 @@ module Vagrant
index = triggers.index(trigger) unless match == true
end
if trigger.type != type
index = triggers.index(trigger)
end
if index
@logger.debug("Trigger #{trigger.id} will be ignored for #{guest_name}")
triggers.delete_at(index)
@ -110,10 +143,10 @@ module Vagrant
@logger.debug("Running trigger #{trigger.id}...")
if trigger.name
@machine.ui.info(I18n.t("vagrant.trigger.fire_with_name",
@ui.info(I18n.t("vagrant.trigger.fire_with_name",
name: trigger.name))
else
@machine.ui.info(I18n.t("vagrant.trigger.fire"))
@ui.info(I18n.t("vagrant.trigger.fire"))
end
if trigger.info
@ -124,6 +157,10 @@ module Vagrant
warn(trigger.warn)
end
if trigger.abort
trigger_abort(trigger.abort)
end
if trigger.run
run(trigger.run, trigger.on_error, trigger.exit_codes)
end
@ -131,6 +168,10 @@ module Vagrant
if trigger.run_remote
run_remote(trigger.run_remote, trigger.on_error, trigger.exit_codes)
end
if trigger.ruby_block
execute_ruby(trigger.ruby_block)
end
end
end
@ -138,14 +179,14 @@ module Vagrant
#
# @param [String] message The string to be printed
def info(message)
@machine.ui.info(message)
@ui.info(message)
end
# Prints the given message at warn level for a trigger
#
# @param [String] message The string to be printed
def warn(message)
@machine.ui.warn(message)
@ui.warn(message)
end
# Runs a script on a guest
@ -153,16 +194,20 @@ module Vagrant
# @param [Provisioners::Shell::Config] config A Shell provisioner config
def run(config, on_error, exit_codes)
if config.inline
cmd = Shellwords.split(config.inline)
if Vagrant::Util::Platform.windows?
cmd = config.inline
else
cmd = Shellwords.split(config.inline)
end
@machine.ui.detail(I18n.t("vagrant.trigger.run.inline", command: config.inline))
@ui.detail(I18n.t("vagrant.trigger.run.inline", command: config.inline))
else
cmd = File.expand_path(config.path, @env.root_path).shellescape
args = Array(config.args)
cmd << " #{args.join(' ')}" if !args.empty?
cmd = Shellwords.split(cmd)
@machine.ui.detail(I18n.t("vagrant.trigger.run.script", path: config.path))
@ui.detail(I18n.t("vagrant.trigger.run.script", path: config.path))
end
# Pick an execution method to run the script or inline string with
@ -187,22 +232,22 @@ module Vagrant
options[:color] = :red if !config.keep_color
end
@machine.ui.detail(data, options)
@ui.detail(data, options)
end
if !exit_codes.include?(result.exit_code)
raise Errors::TriggersBadExitCodes,
code: result.exit_code
end
rescue => e
@machine.ui.error(I18n.t("vagrant.errors.triggers_run_fail"))
@machine.ui.error(e.message)
@ui.error(I18n.t("vagrant.errors.triggers_run_fail"))
@ui.error(e.message)
if on_error == :halt
@logger.debug("Trigger run encountered an error. Halting on error...")
raise e
else
@logger.debug("Trigger run encountered an error. Continuing on anyway...")
@machine.ui.warn(I18n.t("vagrant.trigger.on_error_continue"))
@ui.warn(I18n.t("vagrant.trigger.on_error_continue"))
end
end
end
@ -211,7 +256,16 @@ module Vagrant
#
# @param [ShellProvisioner/Config] config A Shell provisioner config
def run_remote(config, on_error, exit_codes)
unless @machine.state.id == :running
if !@machine
# machine doesn't even exist.
if on_error == :halt
raise Errors::TriggersGuestNotExist
else
@ui.warn(I18n.t("vagrant.errors.triggers_guest_not_exist"))
@ui.warn(I18n.t("vagrant.trigger.on_error_continue"))
return
end
elsif @machine.state.id != :running
if on_error == :halt
raise Errors::TriggersGuestNotRunning,
machine_name: @machine.name,
@ -241,6 +295,30 @@ module Vagrant
end
end
end
# Exits Vagrant immediately
#
# @param [Integer] code Code to exit Vagrant on
def trigger_abort(exit_code)
if Thread.current[:batch_parallel_action]
@ui.warn(I18n.t("vagrant.trigger.abort_threaded"))
@logger.debug("Trigger abort within parallel batch action. " \
"Setting exit code and terminating.")
Thread.current[:exit_code] = exit_code
Thread.current.terminate
else
@ui.warn(I18n.t("vagrant.trigger.abort"))
@logger.debug("Trigger abort within non-parallel action, exiting directly")
Process.exit!(exit_code)
end
end
# Calls the given ruby block for execution
#
# @param [Proc] ruby_block
def execute_ruby(ruby_block)
ruby_block.call(@env, @machine)
end
end
end
end

View File

@ -35,6 +35,14 @@ module Vagrant
!!ENV["VAGRANT_INSTALLER_ENV"]
end
# This returns a true/false if we are running within a bundler environment
#
# @return [Boolean]
def self.in_bundler?
!!ENV["BUNDLE_GEMFILE"] &&
!defined?(::Bundler).nil?
end
# Returns the path to the embedded directory of the Vagrant installer,
# if there is one (if we're running in an installer).
#

View File

@ -329,10 +329,15 @@ module Vagrant
target = opts[:target] if opts.key?(:target)
target = "#{target}:" if target != ""
# Get the lines. The first default is because if the message
# is an empty string, then we want to still use the empty string.
lines = [message]
lines = message.split("\n") if message != ""
if message != ""
lines = [].tap do |l|
message.scan(/(.*?)(\n|$)/).each do |m|
l << m.first if m.first != "" || (m.first == "" && m.last == "\n")
end
end
lines << "" if message.end_with?("\n")
end
# Otherwise, make sure to prefix every line properly
lines.map do |line|

View File

@ -162,8 +162,8 @@ module Vagrant
ui = Vagrant::UI::Prefixed.new(env.ui, "vagrant")
if latest_version > installed_version
@logger.info("new version of Vagrant available - #{latest_version}")
ui.info(I18n.t("vagrant.version_upgrade_available", latest_version: latest_version, installed_version: installed_version))
env.ui.info("")
ui.info(I18n.t("vagrant.version_upgrade_available", latest_version: latest_version, installed_version: installed_version), channel: :error)
env.ui.info("", channel: :error)
else
@logger.debug("vagrant is currently up to date")
end

View File

@ -0,0 +1,96 @@
module Vagrant
module Util
class CurlHelper
# Hosts that do not require notification on redirect
SILENCED_HOSTS = [
"vagrantcloud.com".freeze,
"vagrantup.com".freeze
].freeze
def self.capture_output_proc(logger, ui, source=nil)
progress_data = ""
progress_regexp = /^\r\s*(\d.+?)\r/m
# Setup the proc that'll receive the real-time data from
# the downloader.
data_proc = Proc.new do |type, data|
# Type will always be "stderr" because that is the only
# type of data we're subscribed for notifications.
# Accumulate progress_data
progress_data << data
while true
# If the download has been redirected and we are no longer downloading
# from the original host, notify the user that the target host has
# changed from the source.
if progress_data.include?("Location")
location = progress_data.scan(/(^|[^\w-])Location: (.+?)$/m).flatten.compact.last.to_s.strip
if !location.empty?
location_uri = URI.parse(location)
unless location_uri.host.nil?
redirect_notify = false
logger.info("download redirected to #{location}")
source_uri = URI.parse(source)
source_host = source_uri.host.to_s.split(".", 2).last
location_host = location_uri.host.to_s.split(".", 2).last
if !redirect_notify && location_host != source_host && !SILENCED_HOSTS.include?(location_host)
ui.clear_line
ui.detail "Download redirected to host: #{location_uri.host}"
end
redirect_notify = true
end
end
progress_data.replace("")
break
end
# If we have a full amount of column data (two "\r") then
# we report new progress reports. Otherwise, just keep
# accumulating.
match = nil
check_match = true
while check_match
check_match = progress_regexp.match(progress_data)
if check_match
data = check_match[1].to_s
stop = progress_data.index(data) + data.length
progress_data.slice!(0, stop)
match = check_match
end
end
break if !match
# Ignore the first \r and split by whitespace to grab the columns
columns = data.strip.split(/\s+/)
# COLUMN DATA:
#
# 0 - % total
# 1 - Total size
# 2 - % received
# 3 - Received size
# 4 - % transferred
# 5 - Transferred size
# 6 - Average download speed
# 7 - Average upload speed
# 9 - Total time
# 9 - Time spent
# 10 - Time left
# 11 - Current speed
output = "Progress: #{columns[0]}% (Rate: #{columns[11]}/s, Estimated time remaining: #{columns[10]})"
ui.clear_line
ui.detail(output, new_line: false)
end
end
return data_proc
end
end
end
end

View File

@ -1,11 +1,14 @@
require "uri"
require "log4r"
require "digest"
require "digest/md5"
require "digest/sha1"
require "vagrant/util/busy"
require "vagrant/util/platform"
require "vagrant/util/subprocess"
require "vagrant/util/curl_helper"
require "vagrant/util/file_checksum"
module Vagrant
module Util
@ -19,12 +22,6 @@ module Vagrant
# Vagrant/1.7.4 (+https://www.vagrantup.com; ruby2.1.0)
USER_AGENT = "Vagrant/#{VERSION} (+https://www.vagrantup.com; #{RUBY_ENGINE}#{RUBY_VERSION}) #{ENV['VAGRANT_USER_AGENT_PROVISIONAL_STRING']}".freeze
# Supported file checksum
CHECKSUM_MAP = {
:md5 => Digest::MD5,
:sha1 => Digest::SHA1
}.freeze
# Hosts that do not require notification on redirect
SILENCED_HOSTS = [
"vagrantcloud.com".freeze,
@ -67,8 +64,11 @@ module Vagrant
@location_trusted = options[:location_trusted]
@checksums = {
:md5 => options[:md5],
:sha1 => options[:sha1]
}
:sha1 => options[:sha1],
:sha256 => options[:sha256],
:sha384 => options[:sha384],
:sha512 => options[:sha512]
}.compact
end
# This executes the actual download, downloading the source file
@ -88,85 +88,7 @@ module Vagrant
# tell us output so we can parse it out.
extra_subprocess_opts[:notify] = :stderr
progress_data = ""
progress_regexp = /^\r\s*(\d.+?)\r/m
# Setup the proc that'll receive the real-time data from
# the downloader.
data_proc = Proc.new do |type, data|
# Type will always be "stderr" because that is the only
# type of data we're subscribed for notifications.
# Accumulate progress_data
progress_data << data
while true
# If the download has been redirected and we are no longer downloading
# from the original host, notify the user that the target host has
# changed from the source.
if progress_data.include?("Location")
location = progress_data.scan(/(^|[^\w-])Location: (.+?)$/m).flatten.compact.last.to_s.strip
if !location.empty?
location_uri = URI.parse(location)
unless location_uri.host.nil?
@logger.info("download redirected to #{location}")
source_uri = URI.parse(source)
source_host = source_uri.host.to_s.split(".", 2).last
location_host = location_uri.host.to_s.split(".", 2).last
if !@redirect_notify && location_host != source_host && !SILENCED_HOSTS.include?(location_host)
@ui.clear_line
@ui.detail "Download redirected to host: #{location_uri.host}"
end
@redirect_notify = true
end
end
progress_data.replace("")
break
end
# If we have a full amount of column data (two "\r") then
# we report new progress reports. Otherwise, just keep
# accumulating.
match = nil
check_match = true
while check_match
check_match = progress_regexp.match(progress_data)
if check_match
data = check_match[1].to_s
stop = progress_data.index(data) + data.length
progress_data.slice!(0, stop)
match = check_match
end
end
break if !match
# Ignore the first \r and split by whitespace to grab the columns
columns = data.strip.split(/\s+/)
# COLUMN DATA:
#
# 0 - % total
# 1 - Total size
# 2 - % received
# 3 - Received size
# 4 - % transferred
# 5 - Transferred size
# 6 - Average download speed
# 7 - Average upload speed
# 9 - Total time
# 9 - Time spent
# 10 - Time left
# 11 - Current speed
output = "Progress: #{columns[0]}% (Rate: #{columns[11]}/s, Estimated time remaining: #{columns[10]})"
@ui.clear_line
@ui.detail(output, new_line: false)
end
end
data_proc = Vagrant::Util::CurlHelper.capture_output_proc(@logger, @ui, @source)
end
@logger.info("Downloader starting download: ")
@ -242,36 +164,23 @@ module Vagrant
# @option checksums [String] :sha1 Compare SHA1 checksum
# @return [Boolean]
def validate_download!(source, path, checksums)
CHECKSUM_MAP.each do |type, klass|
if checksums[type]
result = checksum_file(klass, path)
@logger.debug("Validating checksum (#{type}) for #{source}. " \
"expected: #{checksums[type]} actual: #{result}")
if checksums[type] != result
raise Errors::DownloaderChecksumError.new(
source: source,
path: path,
type: type,
expected_checksum: checksums[type],
actual_checksum: result
)
end
checksums.each do |type, expected|
actual = FileChecksum.new(path, type).checksum
@logger.debug("Validating checksum (#{type}) for #{source}. " \
"expected: #{expected} actual: #{actual}")
if actual.casecmp(expected) != 0
raise Errors::DownloaderChecksumError.new(
source: source,
path: path,
type: type,
expected_checksum: expected,
actual_checksum: actual
)
end
end
true
end
# Generate checksum on given file
#
# @param digest_class [Class] Digest class to use for generating checksum
# @param path [String, Pathname] Path to file
# @return [String] hexdigest result
def checksum_file(digest_class, path)
digester = digest_class.new
digester.file(path)
digester.hexdigest
end
def execute_curl(options, subprocess_options, &data_proc)
options = options.dup
options << subprocess_options

View File

@ -0,0 +1,76 @@
module Vagrant
module Util
class Experimental
class << self
# A method for determining if the experimental flag has been enabled with
# any features
#
# @return [Boolean]
def enabled?
if !defined?(@_experimental)
experimental = features_requested
if experimental.size >= 1 && experimental.first != "0"
@_experimental = true
else
@_experimental = false
end
end
@_experimental
end
# A method for determining if all experimental features have been enabled
# by either a global enabled value "1" or all features explicitly enabled.
#
# @return [Boolean]
def global_enabled?
if !defined?(@_global_enabled)
experimental = features_requested
if experimental.size == 1 && experimental.first == "1"
@_global_enabled = true
else
@_global_enabled = false
end
end
@_global_enabled
end
# A method for Vagrant internals to determine if a given feature
# has been abled by the user, is a valid feature flag and can be used.
#
# @param [String] feature
# @return [Boolean] - A hash containing the original array and if it is valid
def feature_enabled?(feature)
experimental = features_requested
feature = feature.to_s
return global_enabled? || experimental.include?(feature)
end
# Returns the features requested for the experimental flag
#
# @return [Array] - Returns an array of requested experimental features
def features_requested
if !defined?(@_requested_features)
@_requested_features = ENV["VAGRANT_EXPERIMENTAL"].to_s.downcase.split(',')
end
@_requested_features
end
# A function to guard experimental blocks of code from being executed
#
# @param [Array] features - Array of features to guard a method with
# @param [Block] block - Block of ruby code to be guarded against
def guard_with(*features, &block)
yield if block_given? && features.any? {|f| feature_enabled?(f)}
end
# @private
# Reset the cached values for platform. This is not considered a public
# API and should only be used for testing.
def reset!
instance_variables.each(&method(:remove_instance_variable))
end
end
end
end
end

View File

@ -2,6 +2,9 @@
# passed into FileChecksum. Note that this isn't strictly enforced at
# the moment, and this class isn't directly used. It is merely here for
# documentation of structure of the class.
require "vagrant/errors"
class DigestClass
def update(string); end
def hexdigest; end
@ -10,13 +13,27 @@ end
class FileChecksum
BUFFER_SIZE = 1024 * 8
# Supported file checksum
CHECKSUM_MAP = {
:md5 => Digest::MD5,
:sha1 => Digest::SHA1,
:sha256 => Digest::SHA256,
:sha384 => Digest::SHA384,
:sha512 => Digest::SHA512
}.freeze
# Initializes an object to calculate the checksum of a file. The given
# ``digest_klass`` should implement the ``DigestClass`` interface. Note
# that the built-in Ruby digest classes duck type this properly:
# Digest::MD5, Digest::SHA1, etc.
def initialize(path, digest_klass)
@digest_klass = digest_klass
@path = path
if digest_klass.is_a?(Class)
@digest_klass = digest_klass
else
@digest_klass = load_digest(digest_klass)
end
@path = path
end
# This calculates the checksum of the file and returns it as a
@ -40,6 +57,18 @@ class FileChecksum
end
end
return digest.hexdigest
digest.hexdigest
end
private
def load_digest(type)
digest = CHECKSUM_MAP[type.to_s.to_sym]
if digest.nil?
raise Vagrant::Errors::BoxChecksumInvalidType,
type: type.to_s,
types: CHECKSUM_MAP.keys.join(', ')
end
digest
end
end

View File

@ -12,44 +12,80 @@ module Vagrant
#
# @return [Boolean]
def systemd?(comm)
comm.test("sudo ps -o comm= 1 | grep systemd")
comm.test("ps -o comm= 1 | grep systemd")
end
# systemd-networkd.service is in use
#
# @param [Vagrant::Plugin::V2::Communicator] comm Guest communicator
# @return [Boolean]
def systemd_networkd?(comm)
comm.test("sudo systemctl status systemd-networkd.service")
comm.test("systemctl -q is-active systemd-networkd.service", sudo: true)
end
# Check if a unit file with the given name is defined. Name can
# be a pattern or explicit name.
#
# @param [Vagrant::Plugin::V2::Communicator] comm Guest communicator
# @param [String] name Name or pattern to search
# @return [Boolean]
def systemd_unit_file?(comm, name)
comm.test("systemctl -q list-unit-files | grep \"#{name}\"")
end
# Check if a unit is currently active within systemd
#
# @param [Vagrant::Plugin::V2::Communicator] comm Guest communicator
# @param [String] name Name or pattern to search
# @return [Boolean]
def systemd_unit?(comm, name)
comm.test("systemctl -q list-units | grep \"#{name}\"")
end
# Check if given service is controlled by systemd
#
# @param [Vagrant::Plugin::V2::Communicator] comm Guest communicator
# @param [String] service_name Name of the service to check
# @return [Boolean]
def systemd_controlled?(comm, service_name)
comm.test("systemctl -q is-active #{service_name}", sudo: true)
end
# systemd hostname set is via hostnamectl
#
# @param [Vagrant::Plugin::V2::Communicator] comm Guest communicator
# @return [Boolean]
# NOTE: This test includes actually calling `hostnamectl` to verify
# that it is in working order. This prevents attempts to use the
# hostnamectl command when it is available, but dbus is not which
# renders the command useless
def hostnamectl?(comm)
comm.test("hostnamectl")
comm.test("command -v hostnamectl && hostnamectl")
end
## netplan helpers
# netplan is installed
#
# @param [Vagrant::Plugin::V2::Communicator] comm Guest communicator
# @return [Boolean]
def netplan?(comm)
comm.test("netplan -h")
comm.test("command -v netplan")
end
## nmcli helpers
# nmcli is installed
#
# @param [Vagrant::Plugin::V2::Communicator] comm Guest communicator
# @return [Boolean]
def nmcli?(comm)
comm.test("nmcli -t")
comm.test("command -v nmcli")
end
# NetworkManager currently controls device
#
# @param comm [Communicator]
# @param [Vagrant::Plugin::V2::Communicator] comm Guest communicator
# @param device_name [String]
# @return [Boolean]
def nm_controlled?(comm, device_name)

View File

@ -30,8 +30,7 @@ module Vagrant
return true
end
rescue Timeout::Error, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, \
Errno::ENETUNREACH, Errno::EACCES, Errno::ENOTCONN, \
Errno::EADDRNOTAVAIL
Errno::ENETUNREACH, Errno::EACCES, Errno::ENOTCONN
# Any of the above exceptions signal that the port is closed.
return false
end

View File

@ -5,34 +5,9 @@ module Vagrant
module NetworkIP
# Returns the network address of the given IP and subnet.
#
# If the IP address is an IPv6 address, subnet should be a prefix
# length such as "64".
#
# @return [String]
def network_address(ip, subnet)
# If this is an IPv6 address, then just mask it
if subnet.to_s =~ /^\d+$/
ip = IPAddr.new(ip)
return ip.mask(subnet.to_i).to_s
end
ip = ip_parts(ip)
netmask = ip_parts(subnet)
# Bitwise-AND each octet to get the network address
# in octets and join each part with a period to get
# the resulting network address.
ip.map { |part| part & netmask.shift }.join(".")
end
protected
# Splits an IP into the four octets and returns each as an
# integer in an array.
#
# @return [Array<Integer>]
def ip_parts(ip)
ip.split(".").map { |i| i.to_i }
IPAddr.new(ip).mask(subnet).to_s
end
end
end

View File

@ -0,0 +1,61 @@
require "log4r"
module Vagrant
module Util
class Numeric
# Authors Note: This conversion has been borrowed from the ActiveSupport Numeric class
# Conversion helper constants
KILOBYTE = 1024
MEGABYTE = KILOBYTE * 1024
GIGABYTE = MEGABYTE * 1024
TERABYTE = GIGABYTE * 1024
PETABYTE = TERABYTE * 1024
EXABYTE = PETABYTE * 1024
BYTES_CONVERSION_MAP = {KB: KILOBYTE, MB: MEGABYTE, GB: GIGABYTE, TB: TERABYTE,
PB: PETABYTE, EB: EXABYTE}
# Regex borrowed from the vagrant-disksize config class
SHORTHAND_MATCH_REGEX = /^(?<number>[0-9]+)\s?(?<unit>KB|MB|GB|TB)?$/
class << self
LOGGER = Log4r::Logger.new("vagrant::util::numeric")
# A helper that converts a shortcut string to its bytes representation.
# The expected format of `str` is essentially: "<Number>XX"
# Where `XX` is shorthand for KB, MB, GB, TB, PB, or EB. For example, 50 megabytes:
#
# str = "50MB"
#
# @param [String] - str
# @return [Integer,nil] - bytes - returns nil if method fails to convert to bytes
def string_to_bytes(str)
bytes = nil
str = str.to_s.strip
matches = SHORTHAND_MATCH_REGEX.match(str)
if matches
number = matches[:number].to_i
unit = matches[:unit].to_sym
if BYTES_CONVERSION_MAP.key?(unit)
bytes = number * BYTES_CONVERSION_MAP[unit]
else
LOGGER.error("An invalid unit or format was given, string_to_bytes cannot convert #{str}")
end
end
bytes
end
# @private
# Reset the cached values for platform. This is not considered a public
# API and should only be used for testing.
def reset!
instance_variables.each(&method(:remove_instance_variable))
end
end
end
end
end

View File

@ -13,6 +13,14 @@ module Vagrant
# This class just contains some platform checking code.
class Platform
class << self
def logger
if !defined?(@_logger)
@_logger = Log4r::Logger.new("vagrant::util::platform")
end
@_logger
end
def cygwin?
if !defined?(@_cygwin)
@_cygwin = ENV["VAGRANT_DETECTED_OS"].to_s.downcase.include?("cygwin") ||
@ -35,11 +43,10 @@ module Vagrant
if !defined?(@_wsl)
@_wsl = false
SilenceWarnings.silence! do
# Use PATH values to check for `/mnt/c` path indicative of WSL
if ENV.fetch("PATH", "").downcase.include?("/mnt/c")
# Validate WSL via uname output
uname = Subprocess.execute("uname", "-r")
if uname.exit_code == 0 && uname.stdout.downcase.include?("microsoft")
# Find 'microsoft' in /proc/version indicative of WSL
if File.file?('/proc/version')
osversion = File.open('/proc/version', &:gets)
if osversion.downcase.include?("microsoft")
@_wsl = true
end
end
@ -79,24 +86,49 @@ module Vagrant
return @_windows_admin
end
# Checks if the user running Vagrant on Windows is a member of the
# "Hyper-V Administrators" group.
# Checks if Hyper-V is accessible to the local user. It will check
# if user is in the "Hyper-V Administrators" group, is a Domain
# administrator, and finally will run a manual interaction with
# Hyper-V to determine if Hyper-V is usable for the current user.
#
# From: https://support.microsoft.com/en-us/kb/243330
# SID: S-1-5-32-578
# Name: BUILTIN\Hyper-V Administrators
# SID: S-1-5-21DOMAIN-512
# Name: Domain Admins
#
# @return [Boolean]
def windows_hyperv_admin?
return @_windows_hyperv_admin if defined?(@_windows_hyperv_admin)
@_windows_hyperv_admin = -> {
ps_cmd = "[System.Security.Principal.WindowsIdentity]::GetCurrent().Groups | ForEach-Object { if ($_.Value -eq 'S-1-5-32-578'){ Write-Host 'true'; break }}"
output = Vagrant::Util::PowerShell.execute_cmd(ps_cmd)
return output == 'true'
}.call
if ENV["VAGRANT_IS_HYPERV_ADMIN"]
return @_windows_hyperv_admin = true
end
return @_windows_hyperv_admin
ps_cmd = "Write-Output ([System.Security.Principal.WindowsIdentity]::GetCurrent().Groups | " \
"Select-Object Value | ConvertTo-JSON)"
output = Vagrant::Util::PowerShell.execute_cmd(ps_cmd)
if output
groups = begin
JSON.load(output)
rescue JSON::ParserError
[]
end
admin_group = groups.detect do |g|
g["Value"].to_s == "S-1-5-32-578" ||
(g["Value"].start_with?("S-1-5-21") && g["Value"].to_s.end_with?("-512"))
end
if admin_group
return @_windows_hyperv_admin = true
end
end
ps_cmd = "$x = (Get-VMHost).Name; if($x -eq [System.Net.Dns]::GetHostName()){ Write-Output 'true'}"
output = Vagrant::Util::PowerShell.execute_cmd(ps_cmd)
result = output == "true"
return @_windows_hyperv_admin = result
end
# Checks if Hyper-V is enabled on the host system and returns true
@ -109,8 +141,13 @@ module Vagrant
@_windows_hyperv_enabled = -> {
["Get-WindowsOptionalFeature", "Get-WindowsFeature"].each do |cmd_name|
ps_cmd = "$(#{cmd_name} -FeatureName Microsoft-Hyper-V-Hypervisor).State"
output = Vagrant::Util::PowerShell.execute_cmd(ps_cmd)
return true if output == "Enabled"
begin
output = Vagrant::Util::PowerShell.execute_cmd(ps_cmd)
return true if output == "Enabled"
rescue Errors::PowerShellInvalidVersion
logger.warn("Invalid PowerShell version detected during Hyper-V enable check")
return false
end
end
return false
}.call
@ -329,6 +366,12 @@ module Vagrant
# Lowercase the drive letter, skip the next symbol (which is a
# colon from a Windows path) and convert path to UNIX style.
check_path = "/mnt/#{path[0, 1].downcase}#{path[2..-1].tr('\\', '/')}/rootfs"
begin
process = Subprocess.execute("wslpath", "-u", "-a", path)
check_path = "#{process.stdout.chomp}/rootfs" if process.exit_code == 0
rescue Errors::CommandUnavailable => e
# pass
end
logger.debug("checking `#{path}` for current WSL instance")
begin
@ -395,6 +438,12 @@ module Vagrant
path = path.to_s
if wsl? && wsl_windows_access? && !path.match(/^[a-zA-Z]:/)
path = File.expand_path(path)
begin
process = Subprocess.execute("wslpath", "-w", "-a", path)
return process.stdout.chomp if process.exit_code == 0
rescue Errors::CommandUnavailable => e
# pass
end
if wsl_path?(path)
parts = path.split("/")
parts.delete_if(&:empty?)
@ -465,6 +514,14 @@ module Vagrant
def wsl_windows_accessible_path
if !defined?(@_wsl_windows_accessible_path)
access_path = ENV["VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH"]
if access_path.to_s.empty?
begin
process = Subprocess.execute("wslpath", "-u", "-a", wsl_windows_home)
access_path = process.stdout.chomp if process.exit_code == 0
rescue Errors::CommandUnavailable => e
# pass
end
end
if access_path.to_s.empty?
access_path = wsl_windows_home.gsub("\\", "/").sub(":", "")
access_path[0] = access_path[0].downcase

View File

@ -1,3 +1,4 @@
require "base64"
require "tmpdir"
require_relative "subprocess"
require_relative "which"
@ -208,18 +209,26 @@ module Vagrant
# @return [Array<String>]
def self.powerup_command(path, args, opts)
Dir.mktmpdir("vagrant") do |dpath|
all_args = ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", path] + args
arg_list = "@('" + all_args.join("', '") + "')"
all_args = [path] + args.flatten.map{ |a|
a.gsub(/^['"](.+)['"]$/, "\\1")
}
arg_list = "\"" + all_args.join("\" \"") + "\""
stdout = File.join(dpath, "stdout.txt")
stderr = File.join(dpath, "stderr.txt")
exitcode = File.join(dpath, "exitcode.txt")
script = "$sp = Start-Process -FilePath powershell -ArgumentList #{arg_list} " \
"-PassThru -Wait -RedirectStandardOutput '#{stdout}' -RedirectStandardError '#{stderr}' -WindowStyle Hidden; " \
"if($sp){ Set-Content -Path '#{exitcode}' -Value $sp.ExitCode;exit $sp.ExitCode; }else{ exit 1 }"
script = "& #{arg_list} ; exit $LASTEXITCODE;"
script_content = Base64.strict_encode64(script.encode("UTF-16LE", "UTF-8"))
# escape quotes so we can nest our script within a start-process
script.gsub!("'", "''")
# Wrap so we can redirect output to read later
wrapper = "$p = Start-Process -FilePath powershell -ArgumentList @('-NoLogo', '-NoProfile', " \
"'-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand', '#{script_content}') " \
"-PassThru -WindowStyle Hidden -Wait -RedirectStandardOutput '#{stdout}' -RedirectStandardError '#{stderr}'; " \
"if($p){ exit $p.ExitCode; }else{ exit 1 }"
wrapper_content = Base64.strict_encode64(wrapper.encode("UTF-16LE", "UTF-8"))
powerup = "$p = Start-Process -FilePath powershell -ArgumentList @('-NoLogo', '-NoProfile', " \
"'-NonInteractive', '-ExecutionPolicy', 'Bypass', '-EncodedCommand', '#{wrapper_content}') " \
"-PassThru -WindowStyle Hidden -Wait -Verb RunAs; if($p){ exit $p.ExitCode; }else{ exit 1 }"
cmd = [
"powershell",
@ -227,31 +236,20 @@ module Vagrant
"-NoProfile",
"-NonInteractive",
"-ExecutionPolicy", "Bypass",
"-Command", "$p = Start-Process -FilePath powershell -ArgumentList " \
"@('-NoLogo', '-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-Command', '#{script}') " \
"-PassThru -Wait -WindowStyle Hidden -Verb RunAs; if($p){ exit $p.ExitCode; }else{ exit 1 }"
"-Command", powerup
]
result = Subprocess.execute(*cmd.push(opts))
r_stdout = result.stdout
if File.exist?(stdout)
r_stdout = File.read(stdout)
else
r_stdout = result.stdout
r_stdout += File.read(stdout)
end
r_stderr = result.stderr
if File.exist?(stderr)
r_stderr = File.read(stderr)
else
r_stderr = result.stderr
r_stderr += File.read(stderr)
end
code = 1
if File.exist?(exitcode)
code_txt = File.read(exitcode).strip
if code_txt.match(/^\d+$/)
code = code_txt.to_i
end
end
Subprocess::Result.new(code, r_stdout, r_stderr)
Subprocess::Result.new(result.exit_code, r_stdout, r_stderr)
end
end

View File

@ -150,11 +150,24 @@ module Vagrant
if !plain_mode && options[:private_key_path]
options[:private_key_path].each do |path|
# Use '-o' instead of '-i' because '-i' does not call
# percent_expand in misc.c, but '-o' does. when passing the path,
# replace '%' in the path with '%%' to escape the '%'
path = path.to_s.gsub('%', '%%')
command_options += ["-o", "IdentityFile=\"#{path}\""]
private_key_arr = []
if path.include?('%')
if path.include?(' ') && Platform.windows?
LOGGER.warn("Paths with spaces and % on windows is not supported and will fail to read the file")
end
# Use '-o' instead of '-i' because '-i' does not call
# percent_expand in misc.c, but '-o' does. when passing the path,
# replace '%' in the path with '%%' to escape the '%'
path = path.to_s.gsub('%', '%%')
private_key_arr = ["-o", "IdentityFile=\"#{path}\""]
else
# Pass private key file directly with '-i', which properly supports
# paths with spaces on Windows guests
private_key_arr = ["-i", path]
end
command_options += private_key_arr
end
end
@ -165,6 +178,10 @@ module Vagrant
"-o", "ForwardX11Trusted=yes"]
end
if ssh_info[:config]
command_options += ["-F", ssh_info[:config]]
end
if ssh_info[:proxy_command]
command_options += ["-o", "ProxyCommand=#{ssh_info[:proxy_command]}"]
end

View File

@ -129,10 +129,10 @@ module Vagrant
if ENV["VAGRANT_APPIMAGE"]
embed_path = Pathname.new(Vagrant.installer_embedded_dir).expand_path.to_s
exec_path = Pathname.new(@command[0]).expand_path.to_s
if !exec_path.start_with?(embed_path) && ENV["VAGRANT_APPIMAGE_LD_LIBRARY_PATH"]
if !exec_path.start_with?(embed_path) && ENV["VAGRANT_APPIMAGE_HOST_LD_LIBRARY_PATH"]
@logger.info("Detected AppImage environment and request to external binary. Updating library path.")
@logger.debug("Setting LD_LIBRARY_PATH to #{ENV["VAGRANT_APPIMAGE_LD_LIBRARY_PATH"]}")
process.environment["LD_LIBRARY_PATH"] = ENV["VAGRANT_APPIMAGE_LD_LIBRARY_PATH"].to_s
@logger.debug("Setting LD_LIBRARY_PATH to #{ENV["VAGRANT_APPIMAGE_HOST_LD_LIBRARY_PATH"]}")
process.environment["LD_LIBRARY_PATH"] = ENV["VAGRANT_APPIMAGE_HOST_LD_LIBRARY_PATH"].to_s
end
end
else

View File

@ -0,0 +1,103 @@
require "uri"
require "log4r"
require "vagrant/util/busy"
require "vagrant/util/platform"
require "vagrant/util/subprocess"
require "vagrant/util/curl_helper"
module Vagrant
module Util
# This class uploads files using various protocols by subprocessing
# to cURL. cURL is a much more capable and complete download tool than
# a hand-rolled Ruby library, so we defer to its expertise.
class Uploader
# @param [String] destination - valid URL to upload file to
# @param [String] file - location of file to upload on disk
# @param [Hash] options
def initialize(destination, file, options=nil)
options ||= {}
@logger = Log4r::Logger.new("vagrant::util::uploader")
@destination = destination.to_s
@file = file.to_s
@ui = options[:ui]
@request_method = options[:method]
if !@request_method
@request_method = "PUT"
end
end
def upload!
data_proc = Vagrant::Util::CurlHelper.capture_output_proc(@logger, @ui)
@logger.info("Uploader starting upload: ")
@logger.info(" -- Source: #{@file}")
@logger.info(" -- Destination: #{@destination}")
options = build_options
subprocess_options = {notify: :stderr}
begin
execute_curl(options, subprocess_options, &data_proc)
rescue Errors::UploaderError => e
raise
ensure
@ui.clear_line if @ui
end
end
protected
def build_options
options = [@destination, "--request", @request_method, "--upload-file", @file]
return options
end
def execute_curl(options, subprocess_options, &data_proc)
options = options.dup
options << subprocess_options
# Create the callback that is called if we are interrupted
interrupted = false
int_callback = Proc.new do
@logger.info("Uploader interrupted!")
interrupted = true
end
# Execute!
result = Busy.busy(int_callback) do
Subprocess.execute("curl", *options, &data_proc)
end
# If the upload was interrupted, then raise a specific error
raise Errors::UploaderInterrupted if interrupted
# If it didn't exit successfully, we need to parse the data and
# show an error message.
if result.exit_code != 0
@logger.warn("Uploader exit code: #{result.exit_code}")
check = result.stderr.match(/\n*curl:\s+\((?<code>\d+)\)\s*(?<error>.*)$/)
if !check
err_msg = result.stderr
else
err_msg = check[:error]
end
raise Errors::UploaderError,
exit_code: result.exit_code,
message: err_msg
end
if @ui
@ui.clear_line
# Windows doesn't clear properly for some reason, so we just
# output one more newline.
@ui.detail("") if Platform.windows?
end
result
end
end
end
end

View File

@ -1,4 +1,5 @@
require "vagrant/util/template_renderer"
require "log4r"
module Vagrant
# This class provides a way to load and access the contents
@ -26,6 +27,7 @@ module Vagrant
@keys = keys
@loader = loader
@config, _ = loader.load(keys)
@logger = Log4r::Logger.new("vagrant::vagrantfile")
end
# Returns a {Machine} for the given name and provider that
@ -110,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]
@ -125,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(', ')
@ -143,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
@ -168,8 +174,8 @@ module Vagrant
# Track the original box so we know if we changed
box = nil
original_box = config.vm.box
original_version = config.vm.box_version
initial_box = original_box = config.vm.box
initial_version = original_version = config.vm.box_version
# Check if this machine has a local box metadata file
# describing the existing guest. If so, load it and
@ -195,12 +201,14 @@ module Vagrant
box = boxes.find(config.vm.box, box_formats, config.vm.box_version)
if box
box_vagrantfile = find_vagrantfile(box.directory)
if box_vagrantfile
if box_vagrantfile && !config.vm.ignore_box_vagrantfile
box_config_key =
"#{boxes.object_id}_#{box.name}_#{box.provider}".to_sym
@loader.set(box_config_key, box_vagrantfile)
local_keys.unshift(box_config_key)
config, config_warnings, config_errors = @loader.load(local_keys)
elsif box_vagrantfile && config.vm.ignore_box_vagrantfile
@logger.warn("Ignoring #{box.name} provided Vagrantfile inside box")
end
end
end
@ -228,6 +236,17 @@ module Vagrant
# Load the box and provider overrides
load_box_proc.call
# NOTE: In cases where the box_meta file contains stale information
# and the reference box no longer exists, fall back to initial
# configuration and attempt to load that
if box.nil?
@logger.warn("Failed to locate #{config.vm.box} with version #{config.vm.box_version}")
@logger.warn("Performing lookup with inital values #{initial_box} with version #{initial_version}")
config.vm.box = original_box = initial_box
config.vm.box_version = original_box = initial_version
load_box_proc.call
end
# Ensure box attributes are set to original values in
# case they were modified by the local box metadata
config.vm.box = original_box

View File

@ -86,7 +86,7 @@ module VagrantPlugins
box_force: options[:force],
box_download_ca_cert: options[:ca_cert],
box_download_ca_path: options[:ca_path],
box_client_cert: options[:client_cert],
box_download_client_cert: options[:client_cert],
box_download_insecure: options[:insecure],
box_download_location_trusted: options[:location_trusted],
ui: Vagrant::UI::Prefixed.new(@env.ui, "box"),

View File

@ -26,6 +26,10 @@ module VagrantPlugins
options[:global] = g
end
o.on("-f", "--force", "Force checks for latest box updates") do |f|
options[:force] = f
end
build_download_options(o, download_options)
end
@ -40,7 +44,7 @@ module VagrantPlugins
with_target_vms(argv) do |machine|
@env.action_runner.run(Vagrant::Action.action_box_outdated, {
box_outdated_force: true,
box_outdated_force: options[:force],
box_outdated_refresh: true,
box_outdated_success_ui: true,
machine: machine,
@ -73,7 +77,15 @@ module VagrantPlugins
end
current = Gem::Version.new(box.version)
latest = Gem::Version.new(md.versions.last)
box_versions = md.versions(provider: box.provider)
if box_versions.empty?
latest_box_version = box_versions.last.to_i
else
latest_box_version = box_versions.last
end
latest = Gem::Version.new(latest_box_version)
if latest <= current
@env.ui.success(I18n.t(
"vagrant.box_up_to_date",

View File

@ -30,6 +30,10 @@ module VagrantPlugins
o.on("-f", "--force", "Destroy without confirmation even when box is in use.") do |f|
options[:force] = f
end
o.on("-k", "--keep-active-boxes", "When combined with `--force`, will keep boxes still actively in use.") do |k|
options[:keep] = k
end
end
# Parse the options
@ -41,7 +45,7 @@ module VagrantPlugins
return @env.ui.warn(I18n.t("vagrant.commands.box.no_installed_boxes"), prefix: false)
end
delete_oldest_boxes(boxes, options[:provider], options[:force], options[:name], options[:dry_run])
delete_oldest_boxes(boxes, options[:provider], options[:force], options[:name], options[:dry_run], options[:keep])
# Success, exit status 0
0
@ -49,7 +53,7 @@ module VagrantPlugins
private
def delete_oldest_boxes(boxes, only_provider, skip_confirm, only_name, dry_run)
def delete_oldest_boxes(boxes, only_provider, skip_confirm, only_name, dry_run, keep_used_boxes)
# Find the longest box name
longest_box = boxes.max_by { |x| x[0].length }
longest_box_length = longest_box[0].length
@ -112,6 +116,7 @@ module VagrantPlugins
box_provider: provider,
box_version: version,
force_confirm_box_remove: skip_confirm,
keep_used_boxes: keep_used_boxes,
box_remove_all_versions: false,
})
end

View File

@ -80,7 +80,7 @@ module VagrantPlugins
end
to_update = [
[name, provider, boxes[name][provider].sort.last],
[name, provider, boxes[name][provider].sort_by{|n| Gem::Version.new(n)}.last],
]
to_update.each do |n, p, v|
@ -128,7 +128,13 @@ module VagrantPlugins
if download_options[:insecure].nil?
download_options[:insecure] = machine.config.vm.box_download_insecure
end
box_update(box, version, machine.ui, download_options, force)
begin
box_update(box, version, machine.ui, download_options, force)
rescue Vagrant::Errors::BoxUpdateNoMetadata => e
machine.ui.warn(e)
next
end
end
end
@ -158,7 +164,7 @@ module VagrantPlugins
box_version: update[1].version,
ui: ui,
box_force: force,
box_client_cert: download_options[:client_cert],
box_download_client_cert: download_options[:client_cert],
box_download_ca_cert: download_options[:ca_cert],
box_download_ca_path: download_options[:ca_path],
box_download_insecure: download_options[:insecure]

View File

@ -0,0 +1,90 @@
require 'optparse'
module VagrantPlugins
module CloudCommand
module AuthCommand
module Command
class Login < Vagrant.plugin("2", :command)
def execute
options = {}
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant cloud auth login [options]"
o.separator ""
o.separator "Options:"
o.separator ""
o.on("-c", "--check", "Checks if currently logged in") do |c|
options[:check] = c
end
o.on("-d", "--description DESCRIPTION", String, "Set description for the Vagrant Cloud token") do |d|
options[:description] = d
end
o.on("-k", "--logout", "Logout from Vagrant Cloud") do |k|
options[:logout] = k
end
o.on("-t", "--token TOKEN", String, "Set the Vagrant Cloud token") do |t|
options[:token] = t
end
o.on("-u", "--username USERNAME_OR_EMAIL", String, "Vagrant Cloud username or email address") do |l|
options[:login] = l
end
end
# Parse the options
argv = parse_options(opts)
return if !argv
@client = Client.new(@env)
@client.username_or_email = options[:login]
# Determine what task we're actually taking based on flags
if options[:check]
return execute_check
elsif options[:logout]
return execute_logout
elsif options[:token]
return execute_token(options[:token])
else
@client = VagrantPlugins::CloudCommand::Util.client_login(@env, options)
end
0
end
def execute_check
if @client.logged_in?
@env.ui.success(I18n.t("cloud_command.check_logged_in"))
return 0
else
@env.ui.error(I18n.t("cloud_command.check_not_logged_in"))
return 1
end
end
def execute_logout
@client.clear_token
@env.ui.success(I18n.t("cloud_command.logged_out"))
return 0
end
def execute_token(token)
@client.store_token(token)
@env.ui.success(I18n.t("cloud_command.token_saved"))
if @client.logged_in?
@env.ui.success(I18n.t("cloud_command.check_logged_in"))
return 0
else
@env.ui.error(I18n.t("cloud_command.invalid_token"))
return 1
end
end
end
end
end
end
end

View File

@ -0,0 +1,42 @@
require 'optparse'
module VagrantPlugins
module CloudCommand
module AuthCommand
module Command
class Logout < Vagrant.plugin("2", :command)
def execute
options = {}
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant cloud auth logout [options]"
o.separator ""
o.separator "Log out of Vagrant Cloud"
o.separator ""
o.separator "Options:"
o.separator ""
o.on("-u", "--username USERNAME_OR_EMAIL", String, "Vagrant Cloud username or email address") do |l|
options[:login] = l
end
end
# Parse the options
argv = parse_options(opts)
return if !argv
if !argv.empty?
raise Vagrant::Errors::CLIInvalidUsage,
help: opts.help.chomp
end
# Initializes client and deletes token on disk
@client = VagrantPlugins::CloudCommand::Util.client_login(@env, options[:username])
@client.clear_token
@env.ui.success(I18n.t("cloud_command.logged_out"))
return 0
end
end
end
end
end
end

View File

@ -1,10 +1,10 @@
require "cgi"
require "uri"
require_relative "../client"
require Vagrant.source_root.join("plugins/commands/cloud/client/client")
module VagrantPlugins
module LoginCommand
module CloudCommand
class AddAuthentication
REPLACEMENT_HOSTS = [
"app.vagrantup.com".freeze,
@ -27,7 +27,7 @@ module VagrantPlugins
def initialize(app, env)
@app = app
LoginCommand::Plugin.init!
CloudCommand::Plugin.init!
end
def call(env)
@ -56,7 +56,7 @@ module VagrantPlugins
if u.host == server_uri.host
if server_uri.host != TARGET_HOST && !self.class.custom_host_notified?
env[:ui].warn(I18n.t("login_command.middleware.authentication.different_target",
env[:ui].warn(I18n.t("cloud_command.middleware.authentication.different_target",
custom_host: server_uri.host, known_host: TARGET_HOST) + "\n")
sleep CUSTOM_HOST_NOTIFY_WAIT
self.class.custom_host_notified!

View File

@ -0,0 +1,20 @@
require "vagrant"
module VagrantPlugins
module CloudCommand
module AuthCommand
class Plugin < Vagrant.plugin("2")
name "vagrant cloud auth"
description <<-DESC
Authorization commands for Vagrant Cloud
DESC
command(:auth) do
require_relative "root"
Command::Root
end
end
end
end
end

View File

@ -0,0 +1,73 @@
module VagrantPlugins
module CloudCommand
module AuthCommand
module Command
class Root < Vagrant.plugin("2", :command)
def self.synopsis
"Manages Vagrant Cloud authorization related to Vagrant Cloud"
end
def initialize(argv, env)
super
@main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
@subcommands = Vagrant::Registry.new
@subcommands.register(:login) do
require File.expand_path("../login", __FILE__)
Command::Login
end
@subcommands.register(:logout) do
require File.expand_path("../logout", __FILE__)
Command::Logout
end
@subcommands.register(:whoami) do
require File.expand_path("../whoami", __FILE__)
Command::Whoami
end
end
def execute
if @main_args.include?("-h") || @main_args.include?("--help")
# Print the help for all the box commands.
return help
end
# If we reached this far then we must have a subcommand. If not,
# then we also just print the help and exit.
command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
return help if !command_class || !@sub_command
@logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
# Initialize and execute the command class
command_class.new(@sub_args, @env).execute
end
# Prints the help out for this command
def help
opts = OptionParser.new do |opts|
opts.banner = "Usage: vagrant cloud auth <subcommand> [<args>]"
opts.separator ""
opts.separator "Authorization with Vagrant Cloud"
opts.separator ""
opts.separator "Available subcommands:"
# Add the available subcommands as separators in order to print them
# out as well.
keys = []
@subcommands.each { |key, value| keys << key.to_s }
keys.sort.each do |key|
opts.separator " #{key}"
end
opts.separator ""
opts.separator "For help on any individual subcommand run `vagrant cloud auth <subcommand> -h`"
end
@env.ui.info(opts.help, prefix: false)
end
end
end
end
end
end

View File

@ -0,0 +1,62 @@
require 'optparse'
module VagrantPlugins
module CloudCommand
module AuthCommand
module Command
class Whoami < Vagrant.plugin("2", :command)
def execute
options = {}
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant cloud auth whoami [options] [token]"
o.separator ""
o.separator "Display currently logged in user"
o.separator ""
o.separator "Options:"
o.separator ""
o.on("-u", "--username USERNAME_OR_EMAIL", String, "Vagrant Cloud username or email address") do |l|
options[:login] = l
end
end
# Parse the options
argv = parse_options(opts)
return if !argv
if argv.size > 1
raise Vagrant::Errors::CLIInvalidUsage,
help: opts.help.chomp
end
@client = VagrantPlugins::CloudCommand::Util.client_login(@env, options[:login])
if argv.first
token = argv.first
else
token = @client.token
end
whoami(token, options[:username])
end
def whoami(access_token, username)
server_url = VagrantPlugins::CloudCommand::Util.api_server_url
account = VagrantPlugins::CloudCommand::Util.account(username, access_token, server_url)
begin
success = account.validate_token
user = success["user"]["username"]
@env.ui.success("Currently logged in as #{user}")
return 0
rescue VagrantCloud::ClientError => e
@env.ui.error(I18n.t("cloud_command.errors.whoami.read_error", org: username))
@env.ui.error(e)
return 1
end
return 1
end
end
end
end
end
end

View File

@ -0,0 +1,75 @@
require 'optparse'
module VagrantPlugins
module CloudCommand
module BoxCommand
module Command
class Create < Vagrant.plugin("2", :command)
def execute
options = {}
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant cloud box create [options] organization/box-name"
o.separator ""
o.separator "Creates an empty box entry on Vagrant Cloud"
o.separator ""
o.separator "Options:"
o.separator ""
o.on("-d", "--description DESCRIPTION", String, "Full description of the box") do |d|
options[:description] = d
end
o.on("-u", "--username USERNAME_OR_EMAIL", String, "Vagrant Cloud username or email address") do |u|
options[:username] = u
end
o.on("-s", "--short-description DESCRIPTION", String, "Short description of the box") do |s|
options[:short] = s
end
o.on("-p", "--private", "Makes box private") do |p|
options[:private] = p
end
end
# Parse the options
argv = parse_options(opts)
return if !argv
if argv.empty? || argv.length > 1
raise Vagrant::Errors::CLIInvalidUsage,
help: opts.help.chomp
end
@client = VagrantPlugins::CloudCommand::Util.client_login(@env, options[:username])
box = argv.first.split('/', 2)
org = box[0]
box_name = box[1]
create_box(org, box_name, options, @client.token)
end
# @param [String] - org
# @param [String] - box_name
# @param [Hash] - options
def create_box(org, box_name, options, access_token)
server_url = VagrantPlugins::CloudCommand::Util.api_server_url
account = VagrantPlugins::CloudCommand::Util.account(org, access_token, server_url)
box = VagrantCloud::Box.new(account, box_name, nil, options[:short], options[:description], access_token)
begin
success = box.create
@env.ui.success(I18n.t("cloud_command.box.create_success", org: org, box_name: box_name))
success = success.delete_if { |_, v| v.nil? }
VagrantPlugins::CloudCommand::Util.format_box_results(success, @env)
return 0
rescue VagrantCloud::ClientError => e
@env.ui.error(I18n.t("cloud_command.errors.box.create_fail", org: org, box_name: box_name))
@env.ui.error(e)
return 1
end
return 1
end
end
end
end
end
end

View File

@ -0,0 +1,65 @@
require 'optparse'
module VagrantPlugins
module CloudCommand
module BoxCommand
module Command
class Delete < Vagrant.plugin("2", :command)
def execute
options = {}
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant cloud box delete [options] organization/box-name"
o.separator ""
o.separator "Deletes box entry on Vagrant Cloud"
o.separator ""
o.separator "Options:"
o.separator ""
o.on("-u", "--username USERNAME_OR_EMAIL", String, "Vagrant Cloud username or email address") do |u|
options[:username] = u
end
end
# Parse the options
argv = parse_options(opts)
return if !argv
if argv.empty? || argv.length > 1
raise Vagrant::Errors::CLIInvalidUsage,
help: opts.help.chomp
end
@env.ui.warn(I18n.t("cloud_command.box.delete_warn", box: argv.first))
cont = @env.ui.ask(I18n.t("cloud_command.continue"))
return 1 if cont.strip.downcase != "y"
@client = VagrantPlugins::CloudCommand::Util.client_login(@env, options[:username])
box = argv.first.split('/', 2)
org = box[0]
box_name = box[1]
delete_box(org, box_name, options[:username], @client.token)
end
def delete_box(org, box_name, username, access_token)
server_url = VagrantPlugins::CloudCommand::Util.api_server_url
account = VagrantPlugins::CloudCommand::Util.account(username, access_token, server_url)
box = VagrantCloud::Box.new(account, box_name, nil, nil, nil, access_token)
begin
success = box.delete(org, box_name)
@env.ui.success(I18n.t("cloud_command.box.delete_success", org: org, box_name: box_name))
return 0
rescue VagrantCloud::ClientError => e
@env.ui.error(I18n.t("cloud_command.errors.box.delete_fail", org: org, box_name: box_name))
@env.ui.error(e)
return 1
end
return 1
end
end
end
end
end
end

View File

@ -0,0 +1,19 @@
require "vagrant"
module VagrantPlugins
module CloudCommand
module BoxCommand
class Plugin < Vagrant.plugin("2")
name "vagrant cloud box"
description <<-DESC
Box life cycle commands for Vagrant Cloud
DESC
command(:box) do
require_relative "root"
Command::Root
end
end
end
end
end

View File

@ -0,0 +1,77 @@
module VagrantPlugins
module CloudCommand
module BoxCommand
module Command
class Root < Vagrant.plugin("2", :command)
def self.synopsis
"Commands to manage boxes on Vagrant Cloud"
end
def initialize(argv, env)
super
@main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
@subcommands = Vagrant::Registry.new
@subcommands.register(:create) do
require File.expand_path("../create", __FILE__)
Command::Create
end
@subcommands.register(:delete) do
require File.expand_path("../delete", __FILE__)
Command::Delete
end
@subcommands.register(:show) do
require File.expand_path("../show", __FILE__)
Command::Show
end
@subcommands.register(:update) do
require File.expand_path("../update", __FILE__)
Command::Update
end
end
def execute
if @main_args.include?("-h") || @main_args.include?("--help")
# Print the help for all the box commands.
return help
end
# If we reached this far then we must have a subcommand. If not,
# then we also just print the help and exit.
command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
return help if !command_class || !@sub_command
@logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
# Initialize and execute the command class
command_class.new(@sub_args, @env).execute
end
# Prints the help out for this command
def help
opts = OptionParser.new do |opts|
opts.banner = "Usage: vagrant cloud box <subcommand> [<args>]"
opts.separator ""
opts.separator "Commands to manage boxes on Vagrant Cloud"
opts.separator ""
opts.separator "Available subcommands:"
# Add the available subcommands as separators in order to print them
# out as well.
keys = []
@subcommands.each { |key, value| keys << key.to_s }
keys.sort.each do |key|
opts.separator " #{key}"
end
opts.separator ""
opts.separator "For help on any individual subcommand run `vagrant cloud box <subcommand> -h`"
end
@env.ui.info(opts.help, prefix: false)
end
end
end
end
end
end

View File

@ -0,0 +1,74 @@
require 'optparse'
module VagrantPlugins
module CloudCommand
module BoxCommand
module Command
class Show < Vagrant.plugin("2", :command)
def execute
options = {}
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant cloud box show [options] organization/box-name"
o.separator ""
o.separator "Displays a boxes attributes on Vagrant Cloud"
o.separator ""
o.separator "Options:"
o.separator ""
o.on("-u", "--username USERNAME_OR_EMAIL", String, "Vagrant Cloud username or email address") do |u|
options[:username] = u
end
o.on("--versions VERSION", String, "Display box information for a specific version") do |v|
options[:version] = v
end
end
# Parse the options
argv = parse_options(opts)
return if !argv
if argv.empty? || argv.length > 1
raise Vagrant::Errors::CLIInvalidUsage,
help: opts.help.chomp
end
@client = VagrantPlugins::CloudCommand::Util.client_login(@env, options[:username])
box = argv.first.split('/', 2)
show_box(box[0], box[1], options, @client.token)
end
def show_box(org, box_name, options, access_token)
username = options[:username]
server_url = VagrantPlugins::CloudCommand::Util.api_server_url
account = VagrantPlugins::CloudCommand::Util.account(username, access_token, server_url)
box = VagrantCloud::Box.new(account, box_name, nil, nil, nil, access_token)
begin
success = box.read(org, box_name)
if options[:version]
# show *this* version only
results = success["versions"].select{ |v| v if v["version"] == options[:version] }.first
if !results
@env.ui.warn(I18n.t("cloud_command.box.show_filter_empty", version: options[:version], org: org, box_name: box_name))
return 0
end
else
results = success
end
results = results.delete_if { |_, v| v.nil? }
VagrantPlugins::CloudCommand::Util.format_box_results(results, @env)
return 0
rescue VagrantCloud::ClientError => e
@env.ui.error(I18n.t("cloud_command.errors.box.show_fail", org: org,box_name:box_name))
@env.ui.error(e)
return 1
end
end
end
end
end
end
end

View File

@ -0,0 +1,71 @@
require 'optparse'
module VagrantPlugins
module CloudCommand
module BoxCommand
module Command
class Update < Vagrant.plugin("2", :command)
def execute
options = {}
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant cloud box update [options] organization/box-name"
o.separator ""
o.separator "Updates a box entry on Vagrant Cloud"
o.separator ""
o.separator "Options:"
o.separator ""
o.on("-d", "--description DESCRIPTION", "Full description of the box") do |d|
options[:description] = d
end
o.on("-u", "--username", "The username of the organization that will own the box") do |u|
options[:username] = u
end
o.on("-s", "--short-description DESCRIPTION", "Short description of the box") do |s|
options[:short_description] = s
end
o.on("-p", "--private", "Makes box private") do |p|
options[:private] = p
end
end
# Parse the options
argv = parse_options(opts)
return if !argv
if argv.empty? || argv.length > 1 || options.length == 0
raise Vagrant::Errors::CLIInvalidUsage,
help: opts.help.chomp
end
@client = VagrantPlugins::CloudCommand::Util.client_login(@env, options[:username])
box = argv.first.split('/', 2)
update_box(box[0], box[1], options, @client.token)
end
def update_box(org, box_name, options, access_token)
server_url = VagrantPlugins::CloudCommand::Util.api_server_url
account = VagrantPlugins::CloudCommand::Util.account(options[:username], access_token, server_url)
box = VagrantCloud::Box.new(account, box_name, nil, nil, nil, access_token)
options[:organization] = org
options[:name] = box_name
begin
success = box.update(options)
@env.ui.success(I18n.t("cloud_command.box.update_success", org: org, box_name: box_name))
success = success.delete_if{|_, v|v.nil?}
VagrantPlugins::CloudCommand::Util.format_box_results(success, @env)
return 0
rescue VagrantCloud::ClientError => e
@env.ui.error(I18n.t("cloud_command.errors.box.update_fail", org: org, box_name: box_name))
@env.ui.error(e)
return 1
end
return 1
end
end
end
end
end
end

View File

@ -0,0 +1,264 @@
require "rest_client"
require "vagrant_cloud"
require "vagrant/util/downloader"
require "vagrant/util/presence"
require Vagrant.source_root.join("plugins/commands/cloud/errors")
module VagrantPlugins
module CloudCommand
class Client
######################################################################
# Class that deals with managing users 'local' token for Vagrant Cloud
######################################################################
APP = "app".freeze
include Vagrant::Util::Presence
attr_accessor :username_or_email
attr_accessor :password
attr_reader :two_factor_default_delivery_method
attr_reader :two_factor_delivery_methods
# Initializes a login client with the given Vagrant::Environment.
#
# @param [Vagrant::Environment] env
def initialize(env)
@logger = Log4r::Logger.new("vagrant::cloud::client")
@env = env
end
# Removes the token, effectively logging the user out.
def clear_token
@logger.info("Clearing token")
token_path.delete if token_path.file?
end
# Checks if the user is logged in by verifying their authentication
# token.
#
# @return [Boolean]
def logged_in?
token = self.token
return false if !token
Vagrant::Util::CredentialScrubber.sensitive(token)
with_error_handling do
url = "#{Vagrant.server_url}/api/v1/authenticate" +
"?access_token=#{token}"
RestClient.get(url, content_type: :json)
true
end
rescue Errors::Unauthorized
false
end
# Login logs a user in and returns the token for that user. The token
# is _not_ stored unless {#store_token} is called.
#
# @param [String] description
# @param [String] code
# @return [String] token The access token, or nil if auth failed.
def login(description: nil, code: nil)
@logger.info("Logging in '#{username_or_email}'")
Vagrant::Util::CredentialScrubber.sensitive(password)
response = post(
"/api/v1/authenticate", {
user: {
login: username_or_email,
password: password
},
token: {
description: description
},
two_factor: {
code: code
}
}
)
Vagrant::Util::CredentialScrubber.sensitive(response["token"])
response["token"]
end
# Requests a 2FA code
# @param [String] delivery_method
def request_code(delivery_method)
@env.ui.warn("Requesting 2FA code via #{delivery_method.upcase}...")
Vagrant::Util::CredentialScrubber.sensitive(password)
response = post(
"/api/v1/two-factor/request-code", {
user: {
login: username_or_email,
password: password
},
two_factor: {
delivery_method: delivery_method.downcase
}
}
)
two_factor = response['two_factor']
obfuscated_destination = two_factor['obfuscated_destination']
@env.ui.success("2FA code sent to #{obfuscated_destination}.")
end
# Issues a post to a Vagrant Cloud path with the given payload.
# @param [String] path
# @param [Hash] payload
# @return [Hash] response data
def post(path, payload)
with_error_handling do
url = File.join(Vagrant.server_url, path)
proxy = nil
proxy ||= ENV["HTTPS_PROXY"] || ENV["https_proxy"]
proxy ||= ENV["HTTP_PROXY"] || ENV["http_proxy"]
RestClient.proxy = proxy
response = RestClient::Request.execute(
method: :post,
url: url,
payload: JSON.dump(payload),
proxy: proxy,
headers: {
accept: :json,
content_type: :json,
user_agent: Vagrant::Util::Downloader::USER_AGENT,
},
)
JSON.load(response.to_s)
end
end
# Stores the given token locally, removing any previous tokens.
#
# @param [String] token
def store_token(token)
@logger.info("Storing token in #{token_path}")
token_path.open("w") do |f|
f.write(token)
end
nil
end
# Reads the access token if there is one. This will first read the
# `VAGRANT_CLOUD_TOKEN` environment variable and then fallback to the stored
# access token on disk.
#
# @return [String]
def token
if present?(ENV["VAGRANT_CLOUD_TOKEN"]) && token_path.exist?
@env.ui.warn <<-EOH.strip
Vagrant detected both the VAGRANT_CLOUD_TOKEN environment variable and a Vagrant login
token are present on this system. The VAGRANT_CLOUD_TOKEN environment variable takes
precedence over the locally stored token. To remove this error, either unset
the VAGRANT_CLOUD_TOKEN environment variable or remove the login token stored on disk:
~/.vagrant.d/data/vagrant_login_token
EOH
end
if present?(ENV["VAGRANT_CLOUD_TOKEN"])
@logger.debug("Using authentication token from environment variable")
return ENV["VAGRANT_CLOUD_TOKEN"]
end
if token_path.exist?
@logger.debug("Using authentication token from disk at #{token_path}")
return token_path.read.strip
end
if present?(ENV["ATLAS_TOKEN"])
@logger.warn("ATLAS_TOKEN detected within environment. Using ATLAS_TOKEN in place of VAGRANT_CLOUD_TOKEN.")
return ENV["ATLAS_TOKEN"]
end
@logger.debug("No authentication token in environment or #{token_path}")
nil
end
protected
def with_error_handling(&block)
yield
rescue RestClient::Unauthorized
@logger.debug("Unauthorized!")
raise Errors::Unauthorized
rescue RestClient::BadRequest => e
@logger.debug("Bad request:")
@logger.debug(e.message)
@logger.debug(e.backtrace.join("\n"))
parsed_response = JSON.parse(e.response)
errors = parsed_response["errors"].join("\n")
raise Errors::ServerError, errors: errors
rescue RestClient::NotAcceptable => e
@logger.debug("Got unacceptable response:")
@logger.debug(e.message)
@logger.debug(e.backtrace.join("\n"))
parsed_response = JSON.parse(e.response)
if two_factor = parsed_response['two_factor']
store_two_factor_information two_factor
if two_factor_default_delivery_method != APP
request_code two_factor_default_delivery_method
end
raise Errors::TwoFactorRequired
end
begin
errors = parsed_response["errors"].join("\n")
raise Errors::ServerError, errors: errors
rescue JSON::ParserError; end
@logger.debug("Got an unexpected error:")
@logger.debug(e.inspect)
raise Errors::Unexpected, error: e.inspect
rescue SocketError
@logger.info("Socket error")
raise Errors::ServerUnreachable, url: Vagrant.server_url.to_s
end
def token_path
@env.data_dir.join("vagrant_login_token")
end
def store_two_factor_information(two_factor)
@two_factor_default_delivery_method =
two_factor['default_delivery_method']
@two_factor_delivery_methods =
two_factor['delivery_methods']
@env.ui.warn "2FA is enabled for your account."
if two_factor_default_delivery_method == APP
@env.ui.info "Enter the code from your authenticator."
else
@env.ui.info "Default method is " \
"'#{two_factor_default_delivery_method}'."
end
other_delivery_methods =
two_factor_delivery_methods - [APP]
if other_delivery_methods.any?
other_delivery_methods_sentence = other_delivery_methods
.map { |word| "'#{word}'" }
.join(' or ')
@env.ui.info "You can also type #{other_delivery_methods_sentence} " \
"to request a new code."
end
end
end
end
end

View File

@ -0,0 +1,28 @@
module VagrantPlugins
module CloudCommand
module Errors
class Error < Vagrant::Errors::VagrantError
error_namespace("cloud_command.errors")
end
class ServerError < Error
error_key(:server_error)
end
class ServerUnreachable < Error
error_key(:server_unreachable)
end
class Unauthorized < Error
error_key(:unauthorized)
end
class Unexpected < Error
error_key(:unexpected_error)
end
class TwoFactorRequired < Error
end
end
end
end

View File

@ -0,0 +1,52 @@
require 'optparse'
module VagrantPlugins
module CloudCommand
module Command
class List < Vagrant.plugin("2", :command)
def execute
options = {}
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant cloud list [options] organization"
o.separator ""
o.separator "Search for boxes managed by a specific user/organization"
o.separator ""
o.separator "Options:"
o.separator ""
o.on("-j", "--json", "Formats results in JSON") do |j|
options[:check] = j
end
o.on("-l", "--limit", Integer, "Max number of search results (default is 25)") do |l|
options[:check] = l
end
o.on("-p", "--provider", "Comma separated list of providers to filter search. Defaults to all.") do |p|
options[:check] = p
end
o.on("-s", "--sort-by", "Column to sort list (created, downloads, updated)") do |s|
options[:check] = s
end
o.on("-u", "--username USERNAME_OR_EMAIL", String, "Vagrant Cloud username or email address") do |t|
options[:username] = u
end
end
# Parse the options
argv = parse_options(opts)
return if !argv
if argv.length > 1
raise Vagrant::Errors::CLIInvalidUsage,
help: opts.help.chomp
end
@client = VagrantPlugins::CloudCommand::Util.client_login(@env, options[:username])
# TODO: This endpoint is not implemented yet
0
end
end
end
end
end

View File

@ -0,0 +1,171 @@
en:
cloud_command:
middleware:
authentication:
different_target: |-
Vagrant has detected a custom Vagrant server in use for downloading
box files. An authentication token is currently set which will be
added to the box request. If the custom Vagrant server should not
be receiving the authentication token, please unset it.
Known Vagrant server: %{known_host}
Custom Vagrant server: %{custom_host}
Press ctrl-c to cancel...
publish:
update_continue: |-
%{obj} already exists, updating instead...
box_create:
Creating a box entry...
version_create:
Creating a version entry...
provider_create:
Creating a provider entry...
upload_provider:
Uploading provider with file %{file}
release:
Releasing box...
complete:
Complete! Published %{org}/%{box_name}
confirm:
warn: |-
You are about to publish a box on Vagrant Cloud with the following options:
box: |-
%{org}/%{box_name}: (v%{version}) for provider '%{provider_name}'
private: |-
Private: true
release: |-
Automatic Release: true
box_url: |-
Remote Box file: %{url}
box_description: |-
Box Description: %{description}
box_short_desc: |-
Box Short Description: %{short_description}
version_desc: |-
Version Description: %{version_description}
continue: |-
Do you wish to continue? [y/N]
box:
show_filter_empty: |-
No version matched %{version} for %{org}/%{box_name}
create_success: |-
Created box %{org}/%{box_name}
delete_success: |-
Deleted box %{org}/%{box_name}
delete_warn: |-
This will completely remove %{box} from Vagrant Cloud. This cannot be undone.
update_success: |-
Updated box %{org}/%{box_name}
search:
no_results: |-
No results found for `%{query}`
upload:
no_url: |-
No URL was provided to upload the provider
You will need to run the `vagrant cloud provider upload` command to provide a box
provider:
upload: |-
Uploading box file for '%{org}/%{box_name}' (v%{version}) for provider: '%{provider}'
upload_success: |-
Uploaded provider %{provider} on %{org}/%{box_name} for version %{version}
delete_warn: |-
This will completely remove provider %{provider} on version %{version} from %{box} on Vagrant Cloud. This cannot be undone.
create_success: |-
Created provider %{provider} on %{org}/%{box_name} for version %{version}
delete_success: |-
Deleted provider %{provider} on %{org}/%{box_name} for version %{version}
update_success: |-
Updated provider %{provider} on %{org}/%{box_name} for version %{version}
version:
create_success: |-
Created version %{version} on %{org}/%{box_name} for version %{version}
delete_success: |-
Deleted version %{version} on %{org}/%{box_name}
release_success: |-
Released version %{version} on %{org}/%{box_name}
revoke_success: |-
Revoked version %{version} on %{org}/%{box_name}
update_success: |-
Updated version %{version} on %{org}/%{box_name}
revoke_warn: |-
This will revoke version %{version} from %{box} from Vagrant Cloud. This cannot be undone.
release_warn: |-
This will release version %{version} from %{box} to Vagrant Cloud and be available to download.
delete_warn: |-
This will completely remove version %{version} from %{box} from Vagrant Cloud. This cannot be undone.
errors:
search:
fail: |-
Could not complete search request
publish:
fail: |-
Failed to create box %{org}/%{box_name}
box:
create_fail: |-
Failed to create box %{org}/%{box_name}
delete_fail: |-
Failed to delete box %{org}/%{box_name}
show_fail: |-
Could not get information about box %{org}/%{box_name}
update_fail: |-
Failed to update box %{org}/%{box_name}
whoami:
read_error: |-
Failed to read organization %{org}
provider:
create_fail: |-
Failed to create provider %{provider} on box %{org}/%{box_name} for version %{version}
update_fail: |-
Failed to update provider %{provider} on box %{org}/%{box_name} for version %{version}
delete_fail: |-
Failed to delete provider %{provider} on box %{org}/%{box_name} for version %{version}
upload_fail: |-
Failed to upload provider %{provider} on box %{org}/%{box_name} for version %{version}
version:
create_fail: |-
Failed to create version %{version} on box %{org}/%{box_name}
delete_fail: |-
Failed to delete version %{version} on box %{org}/%{box_name}
release_fail: |-
Failed to release version %{version} on box %{org}/%{box_name}
revoke_fail: |-
Failed to revoke version %{version} on box %{org}/%{box_name}
update_fail: |-
Failed to update version %{version} on box %{org}/%{box_name}
server_error: |-
The Vagrant Cloud server responded with a not-OK response:
%{errors}
server_unreachable: |-
The Vagrant Cloud server is not currently accepting connections. Please check
your network connection and try again later.
unauthorized: |-
Invalid username or password. Please try again.
unexpected_error: |-
An unexpected error occurred: %{error}
check_logged_in: |-
You are already logged in.
check_not_logged_in: |-
You are not currently logged in. Please run `vagrant login` and provide
your login information to authenticate.
command_header: |-
In a moment we will ask for your username and password to HashiCorp's
Vagrant Cloud. After authenticating, we will store an access token locally on
disk. Your login details will be transmitted over a secure connection, and
are never stored on disk locally.
If you do not have an Vagrant Cloud account, sign up at
https://www.vagrantcloud.com
invalid_login: |-
Invalid username or password. Please try again.
invalid_token: |-
Invalid token. Please try again.
logged_in: |-
You are now logged in.
logged_out: |-
You are logged out.
token_saved: |-
The token was successfully saved.

View File

@ -0,0 +1,35 @@
require "vagrant"
require 'vagrant_cloud'
require Vagrant.source_root.join("plugins/commands/cloud/util")
require Vagrant.source_root.join("plugins/commands/cloud/client/client")
module VagrantPlugins
module CloudCommand
class Plugin < Vagrant.plugin("2")
name "vagrant-cloud"
description <<-DESC
Provides the cloud command and internal API access to Vagrant Cloud.
DESC
command(:cloud) do
require_relative "root"
init!
Command::Root
end
action_hook(:cloud_authenticated_boxes, :authenticate_box_url) do |hook|
require_relative "auth/middleware/add_authentication"
hook.prepend(AddAuthentication)
end
protected
def self.init!
return if defined?(@_init)
I18n.load_path << File.expand_path("../locales/en.yml", __FILE__)
I18n.reload!
@_init = true
end
end
end
end

View File

@ -0,0 +1,80 @@
require 'optparse'
module VagrantPlugins
module CloudCommand
module ProviderCommand
module Command
class Create < Vagrant.plugin("2", :command)
def execute
options = {}
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant cloud provider create [options] organization/box-name provider-name version [url]"
o.separator ""
o.separator "Creates a provider entry on Vagrant Cloud"
o.separator ""
o.separator "Options:"
o.separator ""
o.on("-u", "--username USERNAME_OR_EMAIL", String, "Vagrant Cloud username or email address") do |u|
options[:username] = u
end
o.on("-c", "--checksum CHECKSUM_VALUE", String, "Checksum of the box for this provider. --checksum-type option is required.") do |c|
options[:checksum] = c
end
o.on("-C", "--checksum-type TYPE", String, "Type of checksum used (md5, sha1, sha256, sha384, sha512). --checksum option is required.") do |c|
options[:checksum_type] = c
end
end
# Parse the options
argv = parse_options(opts)
return if !argv
if argv.empty? || argv.length > 4
raise Vagrant::Errors::CLIInvalidUsage,
help: opts.help.chomp
end
@client = VagrantPlugins::CloudCommand::Util.client_login(@env, options[:username])
box = argv.first.split('/', 2)
org = box[0]
box_name = box[1]
provider_name = argv[1]
version = argv[2]
url = argv[3]
upload_provider(org, box_name, provider_name, version, url, @client.token, options)
end
def upload_provider(org, box_name, provider_name, version, url, access_token, options)
if !url
@env.ui.warn(I18n.t("cloud_command.upload.no_url"))
end
org = options[:username] if options[:username]
server_url = VagrantPlugins::CloudCommand::Util.api_server_url
account = VagrantPlugins::CloudCommand::Util.account(org, access_token, server_url)
box = VagrantCloud::Box.new(account, box_name, nil, nil, nil, access_token)
cloud_version = VagrantCloud::Version.new(box, version, nil, nil, access_token)
provider = VagrantCloud::Provider.new(cloud_version, provider_name, nil, url, org, box_name,
access_token, nil, options[:checksum], options[:checksum_type])
begin
success = provider.create_provider
@env.ui.success(I18n.t("cloud_command.provider.create_success", provider: provider_name, org: org, box_name: box_name, version: version))
success = success.compact
VagrantPlugins::CloudCommand::Util.format_box_results(success, @env)
return 0
rescue VagrantCloud::ClientError => e
@env.ui.error(I18n.t("cloud_command.errors.provider.create_fail", provider: provider_name, org: org, box_name: box_name, version: version))
@env.ui.error(e)
return 1
end
end
end
end
end
end
end

View File

@ -0,0 +1,70 @@
require 'optparse'
module VagrantPlugins
module CloudCommand
module ProviderCommand
module Command
class Delete < Vagrant.plugin("2", :command)
def execute
options = {}
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant cloud provider delete [options] organization/box-name provider-name version"
o.separator ""
o.separator "Deletes a provider entry on Vagrant Cloud"
o.separator ""
o.separator "Options:"
o.separator ""
o.on("-u", "--username USERNAME_OR_EMAIL", String, "Vagrant Cloud username or email address") do |u|
options[:username] = u
end
end
# Parse the options
argv = parse_options(opts)
return if !argv
if argv.empty? || argv.length > 3
raise Vagrant::Errors::CLIInvalidUsage,
help: opts.help.chomp
end
box = argv.first.split('/', 2)
org = box[0]
box_name = box[1]
provider_name = argv[1]
version = argv[2]
@env.ui.warn(I18n.t("cloud_command.provider.delete_warn", provider: provider_name, version:version, box: argv.first))
cont = @env.ui.ask(I18n.t("cloud_command.continue"))
return 1 if cont.strip.downcase != "y"
@client = VagrantPlugins::CloudCommand::Util.client_login(@env, options[:username])
delete_provider(org, box_name, provider_name, version, @client.token, options)
end
def delete_provider(org, box_name, provider_name, version, access_token, options)
org = options[:username] if options[:username]
server_url = VagrantPlugins::CloudCommand::Util.api_server_url
account = VagrantPlugins::CloudCommand::Util.account(org, access_token, server_url)
box = VagrantCloud::Box.new(account, box_name, nil, nil, nil, access_token)
cloud_version = VagrantCloud::Version.new(box, version, nil, nil, access_token)
provider = VagrantCloud::Provider.new(cloud_version, provider_name, nil, nil, nil, nil, access_token)
begin
success = provider.delete
@env.ui.error(I18n.t("cloud_command.provider.delete_success", provider: provider_name, org: org, box_name: box_name, version: version))
return 0
rescue VagrantCloud::ClientError => e
@env.ui.error(I18n.t("cloud_command.errors.provider.delete_fail", provider: provider_name, org: org, box_name: box_name, version: version))
@env.ui.error(e)
return 1
end
end
end
end
end
end
end

View File

@ -0,0 +1,19 @@
require "vagrant"
module VagrantPlugins
module CloudCommand
module ProviderCommand
class Plugin < Vagrant.plugin("2")
name "vagrant cloud box"
description <<-DESC
Provider life cycle commands for Vagrant Cloud
DESC
command(:provider) do
require_relative "root"
Command::Root
end
end
end
end
end

View File

@ -0,0 +1,77 @@
module VagrantPlugins
module CloudCommand
module ProviderCommand
module Command
class Root < Vagrant.plugin("2", :command)
def self.synopsis
"Provider commands"
end
def initialize(argv, env)
super
@main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
@subcommands = Vagrant::Registry.new
@subcommands.register(:create) do
require File.expand_path("../create", __FILE__)
Command::Create
end
@subcommands.register(:delete) do
require File.expand_path("../delete", __FILE__)
Command::Delete
end
@subcommands.register(:update) do
require File.expand_path("../update", __FILE__)
Command::Update
end
@subcommands.register(:upload) do
require File.expand_path("../upload", __FILE__)
Command::Upload
end
end
def execute
if @main_args.include?("-h") || @main_args.include?("--help")
# Print the help for all the provider commands.
return help
end
# If we reached this far then we must have a subcommand. If not,
# then we also just print the help and exit.
command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
return help if !command_class || !@sub_command
@logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
# Initialize and execute the command class
command_class.new(@sub_args, @env).execute
end
# Prints the help out for this command
def help
opts = OptionParser.new do |opts|
opts.banner = "Usage: vagrant cloud provider <subcommand> [<args>]"
opts.separator ""
opts.separator "For various provider actions with Vagrant Cloud"
opts.separator ""
opts.separator "Available subcommands:"
# Add the available subcommands as separators in order to print them
# out as well.
keys = []
@subcommands.each { |key, value| keys << key.to_s }
keys.sort.each do |key|
opts.separator " #{key}"
end
opts.separator ""
opts.separator "For help on any individual subcommand run `vagrant cloud provider <subcommand> -h`"
end
@env.ui.info(opts.help, prefix: false)
end
end
end
end
end
end

View File

@ -0,0 +1,80 @@
require 'optparse'
module VagrantPlugins
module CloudCommand
module ProviderCommand
module Command
class Update < Vagrant.plugin("2", :command)
def execute
options = {}
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant cloud provider update [options] organization/box-name provider-name version url"
o.separator ""
o.separator "Updates a provider entry on Vagrant Cloud"
o.separator ""
o.separator "Options:"
o.separator ""
o.on("-u", "--username USERNAME_OR_EMAIL", String, "Vagrant Cloud username or email address") do |u|
options[:username] = u
end
o.on("-c", "--checksum CHECKSUM_VALUE", String, "Checksum of the box for this provider. --checksum-type option is required.") do |c|
options[:checksum] = c
end
o.on("-C", "--checksum-type TYPE", String, "Type of checksum used (md5, sha1, sha256, sha384, sha512). --checksum option is required.") do |c|
options[:checksum_type] = c
end
end
# Parse the options
argv = parse_options(opts)
return if !argv
if argv.empty? || argv.length > 4
raise Vagrant::Errors::CLIInvalidUsage,
help: opts.help.chomp
end
@client = VagrantPlugins::CloudCommand::Util.client_login(@env, options[:username])
box = argv.first.split('/', 2)
org = box[0]
box_name = box[1]
provider_name = argv[1]
version = argv[2]
url = argv[3]
update_provider(org, box_name, provider_name, version, url, @client.token, options)
end
def update_provider(org, box_name, provider_name, version, url, access_token, options)
if !url
@env.ui.warn(I18n.t("cloud_command.upload.no_url"))
end
org = options[:username] if options[:username]
server_url = VagrantPlugins::CloudCommand::Util.api_server_url
account = VagrantPlugins::CloudCommand::Util.account(org, access_token, server_url)
box = VagrantCloud::Box.new(account, box_name, nil, nil, nil, access_token)
cloud_version = VagrantCloud::Version.new(box, version, nil, nil, access_token)
provider = VagrantCloud::Provider.new(cloud_version, provider_name, nil, url, org, box_name,
access_token, nil, options[:checksum], options[:checksum_type])
begin
success = provider.update
@env.ui.success(I18n.t("cloud_command.provider.update_success", provider:provider_name, org: org, box_name: box_name, version: version))
success = success.delete_if{|_, v|v.nil?}
VagrantPlugins::CloudCommand::Util.format_box_results(success, @env)
return 0
rescue VagrantCloud::ClientError => e
@env.ui.error(I18n.t("cloud_command.errors.provider.update_fail", provider:provider_name, org: org, box_name: box_name, version: version))
@env.ui.error(e)
return 1
end
end
end
end
end
end
end

View File

@ -0,0 +1,75 @@
require 'optparse'
require "vagrant/util/uploader"
module VagrantPlugins
module CloudCommand
module ProviderCommand
module Command
class Upload < Vagrant.plugin("2", :command)
def execute
options = {}
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant cloud provider upload [options] organization/box-name provider-name version box-file"
o.separator ""
o.separator "Uploads a box file to Vagrant Cloud for a specific provider"
o.separator ""
o.separator "Options:"
o.separator ""
o.on("-u", "--username USERNAME_OR_EMAIL", String, "Vagrant Cloud username or email address") do |u|
options[:username] = u
end
end
# Parse the options
argv = parse_options(opts)
return if !argv
if argv.empty? || argv.length > 4
raise Vagrant::Errors::CLIInvalidUsage,
help: opts.help.chomp
end
@client = VagrantPlugins::CloudCommand::Util.client_login(@env, options[:username])
box = argv.first.split('/', 2)
org = box[0]
box_name = box[1]
provider_name = argv[1]
version = argv[2]
file = argv[3] # path expand
upload_provider(org, box_name, provider_name, version, file, @client.token, options)
end
def upload_provider(org, box_name, provider_name, version, file, access_token, options)
org = options[:username] if options[:username]
server_url = VagrantPlugins::CloudCommand::Util.api_server_url
account = VagrantPlugins::CloudCommand::Util.account(org, access_token, server_url)
box = VagrantCloud::Box.new(account, box_name, nil, nil, nil, access_token)
cloud_version = VagrantCloud::Version.new(box, version, nil, nil, access_token)
provider = VagrantCloud::Provider.new(cloud_version, provider_name, nil, nil, org, box_name, access_token)
ul = Vagrant::Util::Uploader.new(provider.upload_url, file, ui: @env.ui)
ui = Vagrant::UI::Prefixed.new(@env.ui, "cloud")
begin
ui.output(I18n.t("cloud_command.provider.upload", org: org, box_name: box_name, version: version, provider: provider_name))
ui.info("Upload File: #{file}")
ul.upload!
ui.success("Successfully uploaded box '#{org}/#{box_name}' (v#{version}) for '#{provider_name}'")
return 0
rescue Vagrant::Errors::UploaderError, VagrantCloud::ClientError => e
@env.ui.error(I18n.t("cloud_command.errors.provider.upload_fail", provider: provider_name, org: org, box_name: box_name, version: version))
@env.ui.error(e)
return 1
end
end
end
end
end
end
end

View File

@ -0,0 +1,183 @@
require 'optparse'
require "vagrant/util/uploader"
module VagrantPlugins
module CloudCommand
module Command
class Publish < Vagrant.plugin("2", :command)
def execute
options = {}
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant cloud publish [options] organization/box-name version provider-name provider-file"
o.separator ""
o.separator "Create and release a new Vagrant Box on Vagrant Cloud"
o.separator ""
o.separator "Options:"
o.separator ""
o.on("--box-version VERSION", String, "Version of box to create") do |v|
options[:box_version] = v
end
o.on("--url URL", String, "Remote URL to download this provider") do |u|
options[:url] = u
end
o.on("-d", "--description DESCRIPTION", String, "Full description of box") do |d|
options[:description] = d
end
o.on("--version-description DESCRIPTION", String, "Description of the version to create") do |v|
options[:version_description] = v
end
o.on("-f", "--force", "Disables confirmation to create or update box") do |f|
options[:force] = f
end
o.on("-p", "--private", "Makes box private") do |p|
options[:private] = p
end
o.on("-r", "--release", "Releases box") do |p|
options[:release] = p
end
o.on("-s", "--short-description DESCRIPTION", String, "Short description of the box") do |s|
options[:short_description] = s
end
o.on("-u", "--username USERNAME_OR_EMAIL", String, "Vagrant Cloud username or email address") do |u|
options[:username] = u
end
o.on("-c", "--checksum CHECKSUM_VALUE", String, "Checksum of the box for this provider. --checksum-type option is required.") do |c|
options[:checksum] = c
end
o.on("-C", "--checksum-type TYPE", String, "Type of checksum used (md5, sha1, sha256, sha384, sha512). --checksum option is required.") do |c|
options[:checksum_type] = c
end
end
# Parse the options
argv = parse_options(opts)
return if !argv
if argv.empty? || argv.length > 4 || argv.length < 3 || (argv.length == 3 && !options[:url])
raise Vagrant::Errors::CLIInvalidUsage,
help: opts.help.chomp
end
box = argv.first.split('/', 2)
org = box[0]
box_name = box[1]
version = argv[1]
provider_name = argv[2]
box_file = argv[3]
if !options[:url] && !File.file?(box_file)
raise Vagrant::Errors::BoxFileNotExist,
file: box_file
end
@client = VagrantPlugins::CloudCommand::Util.client_login(@env, options[:username])
publish_box(org, box_name, version, provider_name, box_file, options, @client.token)
end
def publish_box(org, box_name, version, provider_name, box_file, options, access_token)
server_url = VagrantPlugins::CloudCommand::Util.api_server_url
@env.ui.warn(I18n.t("cloud_command.publish.confirm.warn"))
@env.ui.info(I18n.t("cloud_command.publish.confirm.box", org: org,
box_name: box_name, version: version, provider_name: provider_name))
@env.ui.info(I18n.t("cloud_command.publish.confirm.private")) if options[:private]
@env.ui.info(I18n.t("cloud_command.publish.confirm.release")) if options[:release]
@env.ui.info(I18n.t("cloud_command.publish.confirm.box_url",
url: options[:url])) if options[:url]
@env.ui.info(I18n.t("cloud_command.publish.confirm.box_description",
description: options[:description])) if options[:description]
@env.ui.info(I18n.t("cloud_command.publish.confirm.box_short_desc",
short_description: options[:short_description])) if options[:short_description]
@env.ui.info(I18n.t("cloud_command.publish.confirm.version_desc",
version_description: options[:version_description])) if options[:version_description]
if !options[:force]
cont = @env.ui.ask(I18n.t("cloud_command.continue"))
return 1 if cont.strip.downcase != "y"
end
account = VagrantPlugins::CloudCommand::Util.account(org, access_token, server_url)
box = VagrantCloud::Box.new(account, box_name, nil, options[:short_description], options[:description], access_token)
cloud_version = VagrantCloud::Version.new(box, version, nil, options[:version_description], access_token)
provider = VagrantCloud::Provider.new(cloud_version, provider_name, nil, options[:url], org, box_name,
access_token, nil, options[:checksum], options[:checksum_type])
ui = Vagrant::UI::Prefixed.new(@env.ui, "cloud")
begin
ui.info(I18n.t("cloud_command.publish.box_create"))
box.create
rescue VagrantCloud::ClientError => e
if e.error_code == 422
ui.warn(I18n.t("cloud_command.publish.update_continue", obj: "Box"))
box.update(options)
else
@env.ui.error(I18n.t("cloud_command.errors.publish.fail", org: org, box_name: box_name))
@env.ui.error(e)
return 1
end
end
begin
ui.info(I18n.t("cloud_command.publish.version_create"))
cloud_version.create_version
rescue VagrantCloud::ClientError => e
if e.error_code == 422
ui.warn(I18n.t("cloud_command.publish.update_continue", obj: "Version"))
cloud_version.update
else
@env.ui.error(I18n.t("cloud_command.errors.publish.fail", org: org, box_name: box_name))
@env.ui.error(e)
return 1
end
rescue VagrantCloud::InvalidVersion => e
@env.ui.error(I18n.t("cloud_command.errors.publish.fail", org: org, box_name: box_name))
@env.ui.error(e)
return 1
end
begin
ui.info(I18n.t("cloud_command.publish.provider_create"))
provider.create_provider
rescue VagrantCloud::ClientError => e
if e.error_code == 422
ui.warn(I18n.t("cloud_command.publish.update_continue", obj: "Provider"))
provider.update
else
@env.ui.error(I18n.t("cloud_command.errors.publish.fail", org: org, box_name: box_name))
@env.ui.error(e)
return 1
end
end
begin
if !options[:url]
box_file = File.absolute_path(box_file)
ui.info(I18n.t("cloud_command.publish.upload_provider", file: box_file))
ul = Vagrant::Util::Uploader.new(provider.upload_url, box_file, ui: @env.ui)
ul.upload!
end
if options[:release]
ui.info(I18n.t("cloud_command.publish.release"))
cloud_version.release
end
@env.ui.success(I18n.t("cloud_command.publish.complete", org: org, box_name: box_name))
success = box.read(org, box_name)
success = success.delete_if{|_, v|v.nil?}
VagrantPlugins::CloudCommand::Util.format_box_results(success, @env)
return 0
rescue Vagrant::Errors::UploaderError, VagrantCloud::ClientError => e
@env.ui.error(I18n.t("cloud_command.errors.publish.fail", org: org, box_name: box_name))
@env.ui.error(e)
return 1
end
return 1
end
end
end
end
end

View File

@ -0,0 +1,104 @@
module VagrantPlugins
module CloudCommand
module Command
class Root < Vagrant.plugin("2", :command)
def self.synopsis
"manages everything related to Vagrant Cloud"
end
def initialize(argv, env)
super
@main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
@subcommands = Vagrant::Registry.new
@subcommand_helptext = {}
@subcommands.register(:auth) do
require File.expand_path("../auth/root", __FILE__)
AuthCommand::Command::Root
end
@subcommand_helptext[:auth] = "For various authorization operations on Vagrant Cloud"
@subcommands.register(:box) do
require File.expand_path("../box/root", __FILE__)
BoxCommand::Command::Root
end
@subcommand_helptext[:box] = "For managing a Vagrant box entry on Vagrant Cloud"
# TODO: Uncomment this when API endpoint exists
#@subcommands.register(:list) do
# require File.expand_path("../list", __FILE__)
# List
#end
#@subcommand_helptext[:list] = "Displays a list of Vagrant boxes that the current user manages"
@subcommands.register(:search) do
require File.expand_path("../search", __FILE__)
Search
end
@subcommand_helptext[:search] = "Search Vagrant Cloud for available boxes"
@subcommands.register(:provider) do
require File.expand_path("../provider/root", __FILE__)
ProviderCommand::Command::Root
end
@subcommand_helptext[:provider] = "For managing a Vagrant box's provider options"
@subcommands.register(:publish) do
require File.expand_path("../publish", __FILE__)
Publish
end
@subcommand_helptext[:publish] = "A complete solution for creating or updating a new box on Vagrant Cloud"
@subcommands.register(:version) do
require File.expand_path("../version/root", __FILE__)
VersionCommand::Command::Root
end
@subcommand_helptext[:version] = "For managing a Vagrant box's versions"
end
def execute
if @main_args.include?("-h") || @main_args.include?("--help")
# Print the help for all the box commands.
return help
end
# If we reached this far then we must have a subcommand. If not,
# then we also just print the help and exit.
command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
return help if !command_class || !@sub_command
@logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
# Initialize and execute the command class
command_class.new(@sub_args, @env).execute
end
# Prints the help out for this command
def help
opts = OptionParser.new do |opts|
opts.banner = "Usage: vagrant cloud <subcommand> [<args>]"
opts.separator ""
opts.separator "The cloud command can be used for taking actions against"
opts.separator "Vagrant Cloud like searching or uploading a Vagrant Box"
opts.separator ""
opts.separator "Available subcommands:"
# Add the available subcommands as separators in order to print them
# out as well.
keys = []
@subcommands.each { |key, value| keys << key.to_s }
keys.sort.each do |key|
opts.separator " #{key.ljust(15)} #{@subcommand_helptext[key.to_sym]}"
end
opts.separator ""
opts.separator "For help on any individual subcommand run `vagrant cloud <subcommand> -h`"
end
@env.ui.info(opts.help, prefix: false)
end
end
end
end
end

View File

@ -0,0 +1,83 @@
require 'optparse'
module VagrantPlugins
module CloudCommand
module Command
class Search < Vagrant.plugin("2", :command)
def execute
options = {}
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant cloud search [options] query"
o.separator ""
o.separator "Search for boxes managed by a specific"
o.separator "user/organization on Vagrant Cloud"
o.separator ""
o.separator "Options:"
o.separator ""
o.on("-j", "--json", "Formats results in JSON") do |j|
options[:json] = j
end
o.on("-p", "--page PAGE", Integer, "The page to display Default: 1") do |j|
options[:page] = j
end
o.on("-s", "--short", "Shows a simple list of box names") do |s|
options[:short] = s
end
o.on("-o", "--order ORDER", String, "Order to display results ('desc' or 'asc') Default: 'desc'") do |o|
options[:order] = o
end
o.on("-l", "--limit LIMIT", Integer, "Max number of search results Default: 25") do |l|
options[:limit] = l
end
o.on("-p", "--provider PROVIDER", String, "Filter search results to a single provider. Defaults to all.") do |p|
options[:provider] = p
end
o.on("--sort-by SORT", "Field to sort results on (created, downloads, updated) Default: downloads") do |s|
options[:sort] = s
end
o.on("-u", "--username USERNAME_OR_EMAIL", String, "Vagrant Cloud username or email address to login with") do |u|
options[:username] = u
end
end
# Parse the options
argv = parse_options(opts)
return if !argv
if argv.length > 1
raise Vagrant::Errors::CLIInvalidUsage,
help: opts.help.chomp
end
@client = VagrantPlugins::CloudCommand::Util.client_login(@env, options[:username])
query = argv.first
options[:limit] = 25 if !(options[:limit].to_i < 1) && !options[:limit]
search(query, options, @client.token)
end
def search(query, options, access_token)
server_url = VagrantPlugins::CloudCommand::Util.api_server_url
search = VagrantCloud::Search.new(access_token, server_url)
begin
search_results = search.search(query, options[:provider], options[:sort], options[:order], options[:limit], options[:page])
if !search_results["boxes"].empty?
VagrantPlugins::CloudCommand::Util.format_search_results(search_results["boxes"], options[:short], options[:json], @env)
else
@env.ui.warn(I18n.t("cloud_command.search.no_results", query: query))
end
return 0
rescue VagrantCloud::ClientError => e
@env.ui.error(I18n.t("cloud_command.errors.search.fail"))
@env.ui.error(e)
return 1
end
return 1
end
end
end
end
end

View File

@ -0,0 +1,206 @@
module VagrantPlugins
module CloudCommand
class Util
class << self
# @param [String] username - Vagrant Cloud username
# @param [String] access_token - Vagrant Cloud Token used to authenticate
# @param [String] vagrant_cloud_server - Vagrant Cloud server to make API request
# @return [VagrantCloud::Account]
def account(username, access_token, vagrant_cloud_server)
if !defined?(@_account)
@_account = VagrantCloud::Account.new(username, access_token, vagrant_cloud_server)
end
@_account
end
def api_server_url
if Vagrant.server_url == Vagrant::DEFAULT_SERVER_URL
return "#{Vagrant.server_url}/api/v1"
else
return Vagrant.server_url
end
end
# @param [Vagrant::Environment] env
# @param [Hash] options
# @returns [VagrantPlugins::CloudCommand::Client]
def client_login(env, options)
if !defined?(@_client)
@_client = Client.new(env)
return @_client if @_client.logged_in?
# Let the user know what is going on.
env.ui.output(I18n.t("cloud_command.command_header") + "\n")
# If it is a private cloud installation, show that
if Vagrant.server_url != Vagrant::DEFAULT_SERVER_URL
env.ui.output("Vagrant Cloud URL: #{Vagrant.server_url}")
end
options = {} if !options
# Ask for the username
if options[:login]
@_client.username_or_email = options[:login]
env.ui.output("Vagrant Cloud username or email: #{@_client.username_or_email}")
else
@_client.username_or_email = env.ui.ask("Vagrant Cloud username or email: ")
end
@_client.password = env.ui.ask("Password (will be hidden): ", echo: false)
description_default = "Vagrant login from #{Socket.gethostname}"
if !options[:description]
description = env.ui.ask("Token description (Defaults to #{description_default.inspect}): ")
else
description = options[:description]
env.ui.output("Token description: #{description}")
end
description = description_default if description.empty?
code = nil
begin
token = @_client.login(description: description, code: code)
rescue Errors::TwoFactorRequired
until code
code = env.ui.ask("2FA code: ")
if @_client.two_factor_delivery_methods.include?(code.downcase)
delivery_method, code = code, nil
@_client.request_code delivery_method
end
end
retry
end
@_client.store_token(token)
Vagrant::Util::CredentialScrubber.sensitive(token)
env.ui.success(I18n.t("cloud_command.logged_in"))
@_client
end
@_client
end
# ===================================================
# Modified from https://stackoverflow.com/a/28685559
# for printing arrays of hashes in formatted tables
# ===================================================
# @param [Vagrant::Environment] - env
# @param [Hash] - column_labels - A hash of key values for table labels (i.e. {:col1=>"COL1", :col2=>"COL2"})
# @param [Array] - results - An array of hashes
# @param [Array] - to_jrust_keys - An array of column keys that should be right justified (default is left justified for all columns)
def print_search_table(env, column_labels, results, to_rjust_keys)
columns = column_labels.each_with_object({}) { |(col,label),h|
h[col] = { label: label,
width: [results.map { |g| g[col].size }.max, label.size].max
}}
write_header(env, columns)
write_divider(env, columns)
results.each { |h| write_line(env, columns, h,to_rjust_keys) }
write_divider(env, columns)
end
def write_header(env, columns)
env.ui.info "| #{ columns.map { |_,g| g[:label].ljust(g[:width]) }.join(' | ') } |"
end
def write_divider(env, columns)
env.ui.info "+-#{ columns.map { |_,g| "-"*g[:width] }.join("-+-") }-+"
end
def write_line(env, columns,h,to_rjust_keys)
str = h.keys.map { |k|
if to_rjust_keys.include?(k)
h[k].rjust(columns[k][:width])
else
h[k].ljust(columns[k][:width])
end
}.join(" | ")
env.ui.info "| #{str} |"
end
# ===================================================
# ===================================================
# Takes a "mostly" flat key=>value hash from Vagrant Cloud
# and prints its results in a list
#
# @param [Hash] - results - A response hash from vagrant cloud
# @param [Vagrant::Environment] - env
def format_box_results(results, env)
# TODO: remove other description fields? Maybe leave "short"?
results.delete("description_html")
if results["current_version"]
versions = results.delete("versions")
results["providers"] = results["current_version"]["providers"]
results["old_versions"] = versions.map{ |v| v["version"] }[1..5].join(", ") + "..."
end
width = results.keys.map{|k| k.size}.max
results.each do |k,v|
if k == "versions"
v = v.map{ |ver| ver["version"] }.join(", ")
elsif k == "current_version"
v = v["version"]
elsif k == "providers"
v = v.map{ |p| p["name"] }.join(", ")
elsif k == "downloads"
v = format_downloads(v.to_s)
end
whitespace = width-k.size
env.ui.info "#{k}:" + "".ljust(whitespace) + " #{v}"
end
end
# Converts a string of numbers into a formatted number
#
# 1234 -> 1,234
#
# @param [String] - download_string
def format_downloads(download_string)
return download_string.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse
end
# @param [Array] search_results - Box search results from Vagrant Cloud
# @param [String,nil] short - determines if short version will be printed
# @param [String,nil] json - determines if json version will be printed
# @param [Vagrant::Environment] - env
def format_search_results(search_results, short, json, env)
result = []
search_results.each do |b|
box = {}
box = {
name: b["tag"],
version: b["current_version"]["version"],
downloads: format_downloads(b["downloads"].to_s),
providers: b["current_version"]["providers"].map{ |p| p["name"] }.join(",")
}
result << box
end
if short
result.map {|b| env.ui.info(b[:name])}
elsif json
env.ui.info(result.to_json)
else
column_labels = {}
columns = result.first.keys
columns.each do |c|
column_labels[c] = c.to_s.upcase
end
print_search_table(env, column_labels, result, [:downloads])
end
end
end
end
end
end

View File

@ -0,0 +1,69 @@
require 'optparse'
module VagrantPlugins
module CloudCommand
module VersionCommand
module Command
class Create < Vagrant.plugin("2", :command)
def execute
options = {}
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant cloud version create [options] organization/box-name version"
o.separator ""
o.separator "Creates a version entry on Vagrant Cloud"
o.separator ""
o.separator "Options:"
o.separator ""
o.on("-d", "--description DESCRIPTION", String, "A description for this version") do |d|
options[:description] = d
end
o.on("-u", "--username USERNAME_OR_EMAIL", String, "Vagrant Cloud username or email address") do |u|
options[:username] = u
end
end
# Parse the options
argv = parse_options(opts)
return if !argv
if argv.empty? || argv.length > 2
raise Vagrant::Errors::CLIInvalidUsage,
help: opts.help.chomp
end
@client = VagrantPlugins::CloudCommand::Util.client_login(@env, options[:username])
box = argv.first.split('/', 2)
org = box[0]
box_name = box[1]
version = argv[1]
create_version(org, box_name, version, @client.token, options)
end
def create_version(org, box_name, box_version, access_token, options)
org = options[:username] if options[:username]
server_url = VagrantPlugins::CloudCommand::Util.api_server_url
account = VagrantPlugins::CloudCommand::Util.account(org, access_token, server_url)
box = VagrantCloud::Box.new(account, box_name, nil, nil, nil, access_token)
version = VagrantCloud::Version.new(box, box_version, nil, options[:description], access_token)
begin
success = version.create_version
@env.ui.success(I18n.t("cloud_command.version.create_success", version: box_version, org: org, box_name: box_name))
success = success.delete_if{|_, v|v.nil?}
VagrantPlugins::CloudCommand::Util.format_box_results(success, @env)
return 0
rescue VagrantCloud::ClientError => e
@env.ui.error(I18n.t("cloud_command.errors.version.create_fail", version: box_version, org: org, box_name: box_name))
@env.ui.error(e)
return 1
end
return 1
end
end
end
end
end
end

View File

@ -0,0 +1,68 @@
require 'optparse'
module VagrantPlugins
module CloudCommand
module VersionCommand
module Command
class Delete < Vagrant.plugin("2", :command)
def execute
options = {}
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant cloud version delete [options] organization/box-name version"
o.separator ""
o.separator "Deletes a version entry on Vagrant Cloud"
o.separator ""
o.separator "Options:"
o.separator ""
o.on("-u", "--username USERNAME_OR_EMAIL", String, "Vagrant Cloud username or email address") do |u|
options[:username] = u
end
end
# Parse the options
argv = parse_options(opts)
return if !argv
if argv.empty? || argv.length > 2
raise Vagrant::Errors::CLIInvalidUsage,
help: opts.help.chomp
end
box = argv.first.split('/', 2)
org = box[0]
box_name = box[1]
version = argv[1]
@env.ui.warn(I18n.t("cloud_command.version.delete_warn", version: version, box: argv.first))
cont = @env.ui.ask(I18n.t("cloud_command.continue"))
return 1 if cont.strip.downcase != "y"
@client = VagrantPlugins::CloudCommand::Util.client_login(@env, options[:username])
delete_version(org, box_name, version, options, @client.token)
end
def delete_version(org, box_name, box_version, options, access_token)
org = options[:username] if options[:username]
server_url = VagrantPlugins::CloudCommand::Util.api_server_url
account = VagrantPlugins::CloudCommand::Util.account(org, access_token, server_url)
box = VagrantCloud::Box.new(account, box_name, nil, nil, nil, access_token)
version = VagrantCloud::Version.new(box, box_version, nil, nil, access_token)
begin
success = version.delete
@env.ui.success(I18n.t("cloud_command.version.delete_success", version: box_version, org: org, box_name: box_name))
return 0
rescue VagrantCloud::ClientError => e
@env.ui.error(I18n.t("cloud_command.errors.version.delete_fail", version: box_version, org: org, box_name: box_name))
@env.ui.error(e)
return 1
end
return 1
end
end
end
end
end
end

View File

@ -0,0 +1,19 @@
require "vagrant"
module VagrantPlugins
module CloudCommand
module VersionCommand
class Plugin < Vagrant.plugin("2")
name "vagrant cloud version"
description <<-DESC
Version life cycle commands for Vagrant Cloud
DESC
command(:version) do
require_relative "root"
Command::Root
end
end
end
end
end

Some files were not shown because too many files have changed in this diff Show More