Commit Graph

2815 Commits

Author SHA1 Message Date
Seth Vargo 5a4f345363
Use Util::Tempfile when configuring networks
This fixes a fairly large tempfile leak. Vagrant uses a template
renderer to write network configuration files locally to disk. Then,
that temporarily file is uploaded to the remote host and moved into
place. Since Vagrant is such a short-lived process, GC never came along
and cleaned up those tempfiles, resulting in many temporary files being
created through regular Vagrant usage.

The Util::Tempfile class uses a block to ensure the temporary file is
deleted when the block finishes. This API required small tweaks to the
usage, but provides more safety to ensure the files are deleted.
2016-05-28 23:22:34 -04:00
Seth Vargo 3d2390fc94
Give a unique, prefixed name to all tempfiles
This commit basically grepped the code base for all uses of Dir.mktmpdir
and Tempfile.new/open and ensures the value is unique within the
code base and also prefixed with `vagrant-`.

Previously, most invocations of these commands simply used "vagrant",
thus making them indistinguishable when trying to identify leaks.
2016-05-28 23:22:34 -04:00
Seth Vargo cee6e6c7bc
Fix file leaking in bundler 2016-05-28 17:01:59 -04:00
Seth Vargo fc8e97cd89
Style 2016-05-27 19:08:49 -04:00
Seth Vargo 01369342db Merge pull request #5670 from agdula/master
add RDP auto login with password
2016-05-27 19:08:10 -04:00
Ray Ruvinskiy e42f346b1d
Make `start` action run provisioners if VM is running
Previously, there was no one gesture that would start a VM if it was not
running and run the appropriate provisioners regardless of its original
state. `vagrant up` did nothing if the VM was running, while
`vagrant provision` did nothing if the VM was not running.

Change the semantics of `vagrant up`, via the start actions of the providers,
to go through the provisioning logic even if the VM is already running.
The semantics of `run: "once"` vs `run: "always"` are respected.

Tested with the VirtualBox provider but not the others.

Resolves #4421
2016-05-27 19:00:33 -04:00
Seth Vargo 68329817ad Merge pull request #7290 from phyber/fix/master/prepare_nfs_settings_machine_ip_fix
prepare_nfs_settings: Try harder to get all machine IPs.
2016-05-27 18:38:03 -04:00
Seth Vargo 8c11b537ba
Allow Mac/Windows users to use Docker native 2016-05-27 17:36:07 -04:00
Seth Vargo db1f98ffd6 Merge pull request #7298 from till/t/docker-for-mac-beta
Change: disable the linux switch (Docker for Mac/Windows, etc.)
2016-05-27 17:25:13 -04:00
Seth Vargo 171434bbf9 Merge pull request #7353 from mitchellh/sethvargo/package_preflight
Move pre-flight package validation to middleware
2016-05-27 17:16:40 -04:00
Seth Vargo f313c89d74 Merge pull request #7059 from markpeek/markpeek-no-provision-on-resume
Do not ignore the sentinal file when running resume
2016-05-27 17:07:41 -04:00
Seth Vargo efdb148f61
Move pre-flight package validation to middleware
This commit separates the scratch and output directory creation from the
main package middleware into its own PackageSetupFolders middleware.
Additionally, the validation that ensures an output file does not exist
is moved into a validation function that can be shared across multiple
methods.

This refactor permits a pre-flight check to ensure box packaging would
be successful before actually stopping the VM.

Fixes GH-7351
2016-05-27 17:07:04 -04:00
Seth Vargo 08550b6888 Merge pull request #7108 from jtopper/fix_hyperv_status_exception
HyperV: Reinstate compatibility with PowerShell 4
2016-05-20 10:46:01 -04:00
Seth Vargo b384ff98a5
Trailing comma 2016-05-19 11:35:53 -04:00
Thom May 693d4dd5f1
Support Chef Solo local + legacy modes
Signed-off-by: Thom May <thom@may.lt>
2016-05-19 15:27:17 +01:00
Jon Topper 0a7c20a93a Determine status behaviour based on PS version 2016-05-13 17:50:24 +01:00
Jon Topper df4caf0757 Add snapshots to Hyper-V driver 2016-05-13 16:58:08 +01:00
David O'Rourke 985f1d4dda prepare_nfs_settings: Fix add_ips_to_env!, spec test passes again. 2016-05-10 11:16:21 +01:00
till 647bd6114c Change: disable the linux switch (Docker for Mac/Windows, etc.) 2016-05-08 21:35:12 +02:00
David O'Rourke ed708645b2 prepare_nfs_settings: Try harder to get all machine IPs.
Vagrant was not behaving correctly in configurations where there was
a static IP on a VirtualBox `intnet` interface and a DHCP `:hostonly`
interface configured.

Since `machine_ip` attempted to get static addresses `||` dynamic
addresses, it would simply use the static machine address and
continue.

This commit corrects this behaviour by collecting all static and
dynamic addresses into the `machine_ip` array instead of just one or
the other.

The result of this is a correctly generated `/etc/exports` on the
host machine, allowing NFS mounts to work correctly in this type of
environment.
2016-05-05 14:41:03 +01:00
Gilles Cornu cf908d35e0 provisioners/ansible_local: Run galaxy from `provisioning_path` directory
Since it is now possible to specify some Galaxy settings in an
`ansible.cfg` file, it makes sense to run `ansible-galaxy` from the
same working directory as `ansible-playbook` execution does.

See http://docs.ansible.com/ansible/intro_configuration.html#galaxy-settings
2016-04-24 00:26:59 +02:00
Gilles Cornu b6a3f0e8f1 Merge pull request #7103 from mitchellh/gildegoma/fix-6726
ansible_local: use double quoting for 'extra-vars', 'limit' and 'start-at-task' options (except if defined via `raw_arguments` option)
2016-04-21 00:29:43 +02:00
Gilles Cornu b2286388f0 provisioners/ansible: add basic config validators
With this change, the `raw_arguments` and `raw_ssh_args` options are:
- STILL automatically converted as an Array when they are set a String
  (no behaviour change)
- rejected if they are not of Array data type otherwise

Additional Notes:
- the 'as_array' tiny helper has been removed since it was no longer
  used.
- there is for now no deeper validation (i.e. verifying that the Array
  elements are only *String* objects)
2016-04-20 23:54:19 +02:00
Gilles Cornu ab036ddd0b provisioners/ansible: don't format raw_arguments
With cb80286a4a, the helper function
stringify_ansible_playbook_command was also applied on the
`raw_arguments` content, which is not wanted. Given that users have used
the `raw_arguments` option as a workaround to avoid the bug GH-6726,
this new change ensure that any `--extra-vars` option passed as a raw
argument won't be additonally enquoted by the ansible_local
provisioner.

This change also improves the ansible remote provisioner verbose output,
but has no impact on its behaviour, which was already correct.

Note that this refactoring introduces some code duplications that are not
very elegant (see ansible_playbook_command_for_shell_execution in
host.rb and execute_ansible_playbook_from_host in base.rb). I hope we
can find a better implementation later, but it is good enough for now
since all these parts are covered by corresponding unit tests (the
`ansible_local` stuff being tested via the verbose output of the ansible
remote provisioner).
2016-04-20 23:50:42 +02:00
Seth Vargo 6c01aaf6ab Merge pull request #7090 from mac2000/master
hyperv differencing disk
2016-04-17 23:14:29 +05:30
Seth Vargo 2d0943b0ad Print a warning when token and envvar are set
Fixes GH-7206
2016-04-08 10:16:10 -04:00
Seth Vargo 0505771481 Do not return an error if ifdown fails
Ubuntu versions prior to 16.04 always returned a successful exit status,
even if one tried to down an interface that does not exist. This
behavior changed in Ubuntu 16.04 to return an error. This commit
preserves the old behavior.

Fixes GH-7155
2016-03-20 18:21:03 +02:00
Seth Vargo 76e7a980a8 Use a hash for directory lookups 2016-03-17 20:48:08 -05:00
Phivos Stylianides a27e7e106a push via sftp issue when file parent directory does not exist
Overcomes exception Net::SFTP::StatusException (2, "no such file") when using: "vagrant push" via sftp and a file parent directory does not exist. Function "upload" does not create the directory before uploading a file ('mkdir: true' seems to have no effect as zero directories are created while files are uploaded normally).
2016-03-17 20:46:47 -05:00
Seth Vargo 8319f159b6 Use hostname if no node_name is set
Fixes GH-7063
2016-03-17 20:15:11 -05:00
Seth Vargo d565c2f07e Check both stderr and stdout
Different vbox versions print this to different streams, so check both
just to be sure
2016-03-17 10:52:10 -04:00
Seth Vargo 5b336949b5 Merge pull request #7050 from md55/snapshots-in-virtualbox41
Adds snapshot commands in VirtualBox 4.1
2016-03-17 10:48:03 -04:00
Lars Christensen a6565199ff Restart network after reconfiguration
Fixes #7119.
2016-03-08 16:24:24 +01:00
Seth Vargo c6c9942e2e Merge pull request #7104 from altexdim/fix_centos_networks
Fixed centos 7 networks if using more than 3 ethernet adapters.
2016-03-07 11:30:26 -05:00
Altex 9e9909536c fix 2016-03-07 19:25:57 +03:00
Altex e998d6b0f4 Fixed centos 7 networks if using more than 3 ethernet adapters. 2016-03-05 22:25:59 +03:00
Gilles Cornu 47c0833277 ansible_local: use double quotes instead of single quotes
Before this minor change, the '--limit' and '--start-at-task'
ansible-playbook command line arguments were enclosed into single
quotes. Using double quotes adds a bit more flexibility, especially
about the task name referred by `start_at_task` option.

It also aligns with the handling of the '--extra-vars' parameter
(see cb80286).
2016-03-05 17:25:54 +01:00
Gilles Cornu cb80286a4a ansible_local: put json extra-vars in double quotes
Without this change, the JSON string generated from the `extra_vars`
Ruby hash is passed without enclosing quotes and is then not parseable
by the ansible-playbook command when exectuted in a usual shell context.

In this changeset, the ansible (remote) unit test coverage is improved
to cover both usage of `extra_vars` (ansible_local unit tests are still
missing).

Additional Notes:

 - Double quotes are favored to single quotes in order to allow usage of
   any character for the variable values. For this reason additional
   escaping is appended to JSON-inner double quotes and backslashes.

 - This problem was not affecting the `ansible` remote provisioner
   (which is running the ansible-playbook command via the childprocess
   Ruby library). But with this change, the `verbose` output will also
   now be correct for a copy-paste reuse.

 - After this change, all the "--extra-vars" arguments (also a var
   file passed with the @-syntax or anything coming via the
   `raw_arguments` option) are "blindly" and systematically enclosed
   in double quoted and double-escaped.
   This is not optimal and can potentially break with peculiar values
   (e.g. a double quote character (") cannot be used in a json value
   when using `raw_arguments`). That said, I think that the current
   solution is a reasonable trade-off, since the official `extra_vars`
   option should now be able to cover a great majority of use cases.

Fix #6726
2016-03-05 17:24:28 +01:00
Matt Wrock 508492faae fixes #7098 only specifying Hyper-V generation if the parameter is supported 2016-03-04 23:42:17 -08:00
Paul Hinze 32519b226c Merge pull request #6879 from jtopper/allow_no_delete_snapshot_on_pop
Add missing features to snapshot restore/pop
2016-03-04 11:40:54 -06:00
Jon Topper a7008ef5ec Fix up style nit. 2016-03-04 17:35:54 +00:00
Andres Montalban 492ba40fd1 [MOD] Change the way FreeBSD network interfaces are configured. Fixes #5852 2016-03-01 19:28:09 -03:00
Marchenko Alexandr 51d7c98d49 hyperv differencing disk 2016-03-01 17:23:38 +02:00
Seth Vargo fbd765acc1 Do not interpolate in SMB linux heredoc
Fixes GH-6906
2016-02-29 07:19:45 -05:00
Kamjar Gerami fc6bc723f7 #7074 - fixes does not allow provisioning when container name is specifed - since recent versions of Docker stores it's full container ID we no longer need to use the short version 2016-02-28 13:00:35 +01:00
Kamjar Gerami 6754f8db14 #7084 - fixes-7084-notrunc-command-is-wrong-in-client.rb : corrected the -notrunc command to --no-trunc 2016-02-27 02:16:46 +01:00
Donald Guy 52c95ce291 Correctly detect chefdk install 2016-02-25 19:42:58 -05:00
Mark Peek 563ce33738 Do not ignore the sentinal file when running resume
The sentinal file was always being ignored when running the
resume command. This is fixed along with allowing provision
options to be used with resume. Fixes #6787
2016-02-19 18:24:48 -08:00
Evgeniy N 890820eaf6 Add snapshot commands
Fixed error remains in other versions:
  return [] if e.extra_data[:stdout].include?("does not have")
should be
  return [] if e.extra_data[:stderr].include?("does not have")

Many methods are the same in different version_X, and should be moved to Base class.
2016-02-18 11:47:07 +06:00
Kevin Blair 026243c88b Typo
Changed message to match HyperV terminology
2016-02-16 14:58:42 +00:00