Commit Graph

38 Commits

Author SHA1 Message Date
Seth Vargo 49ce775b53
Prefix tempfiles with vagrant- 2016-05-31 00:18:16 -04:00
Seth Vargo 7014aa3bab
Remove custom tempfile class
This is not actually providing any additional utility and also causes
namespace conflicts with people trying to use the real Tempfile class.
2016-05-30 23:21:47 -04:00
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 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
Mitchell Hashimoto 601f7d41e5 synced_folders/smb: use cred files [GH-4230] 2015-11-23 11:11:50 -08:00
Maarten De Wispelaere cfd4270cdb FIX bug introduced in #6315 2015-09-28 09:08:20 +02:00
Seth Vargo 2801501262 Merge pull request #5325 from frankbb/master
vagrant duplicates >= eth2 when defining two private network ips
2015-05-30 11:50:48 -07:00
gpkfr 1eedc2b5f1 Added specific support for Debian 8 (aka jessie) to permit proper vagrant halt execution 2015-02-20 20:15:05 +01:00
Frank Baalbergen 90719dc82f vagrant duplicates >= eth2 when defining two config.vm.network :private_network
When a vagrant box has two private network ips /etc/network/interfaces
will duplicate eth2 and bigger. sed matches greedy, so the first
 #VAGRANT-END matches. This will result in:

/etc/network/interfaces:29: interface eth2 declared allow-auto twice
/sbin/ifup: couldn't read interfaces file "/etc/network/interfaces"
2015-02-11 15:37:41 +01:00
Barry Kelly 185740163c Don't reorder config in /etc/network/interfaces 2014-12-15 19:21:22 +00:00
Leo Simons fec14cf04c Use -f argument to rm to force-remove files.
When using pty=true, removing files using sudo may request confirmation,
which will hang the connection.

Similarly, sometimes assumptions about file existence may be wrong and
in those cases it seems better to continue on as long as the file does
not exist, so -f makes sense there, too.
2014-08-29 10:51:31 +02:00
Kalman Hazins bb052366f7 Change symbols inside hashes to 1.9 JSON-like syntax 2014-05-22 12:35:12 -04:00
Mitchell Hashimoto 19050d26cf guests/debian: setting hostname works without 127.0.1.1 [GH-3271] 2014-05-04 18:32:33 -07:00
Mitchell Hashimoto 9fc5540841 guests/debian: don't return from block [GH-3283] 2014-03-20 17:52:31 -07:00
Teemu Matilainen ee2ae94c25 synced_folders/rsync: Install `rsync` on guest if needed
Add new `rsync_installed` and `rsync_install` guest capabilities
to detect and install `rsync`.

Also copy `rsync_pre` capability to all Unix guests.
2014-01-31 02:12:57 -03:00
Teemu Matilainen e979b84d36 synced_folders/nfs: Register `nfs_client_install` caps to correct distros 2014-01-15 23:37:02 -03:00
Mitchell Hashimoto 91380c0650 synced_folders/nfs: automatically install NFS client if possible
If guests have the following capabilities, automatic NFS client
installation will be done:

  * nfs_client_installed - Checks if the NFS client is installed
  * nfs_client_install - Install the NFS client

Support is already in for Debian, Ubuntu, RedHat, CentOS, and Fedora
2014-01-09 16:58:20 -08:00
Paul Hinze abe0731d2e guests/{ubuntu,debian}: fix change_host_name for trailing dots [GH-2610]
When `/etc/hosts` contained a FQDN with a trailing dot, the `\b` in the
sed expression would not match, since dot is not considered to be a word
character.

Fix this by regexp-escaping the hostname search, and matching the end of
the line on optional space followed by additional characters.

Also add some tests that extract the regexp used by sed and verify that
it does what we want. These will hopefully serve us in the future if we
ever need to test additional edge cases.
2013-12-09 18:56:45 -06:00
Mathieu Lecarme 09a86bd70a Sometimes, ifdown is not enough. 2013-11-26 13:40:50 +01:00
phinze 688bca14f5 refactoring ubuntu/debian change_host_name
there's been a lot of churn around this code, so i figure it was worth
trying to clean it up.

 - the methods were doing a lot, so make them into template methods with
   one helper per step
 - spread out /etc/hosts regexp into a couple of helper variables for
   clarity
 - remove handling for broken hostname implementations (like basing all
   of the checks on name.split('.')[0]), since it seems reasonable to
   remove code dedicated only to handling broken boxes
 - DRY up the shared code between debian/ubuntu implementations, which
   clarifies the differences as well
 - add unit tests around the behavior; this will help us in the future
   to separate flaws in our understanding from flaws in implementation
 - includes a new DummyCommunicator in tests which should be useful in
   supporting additional unit testing of this kind
 - manually tested this on squeeze, wheezy, precise, quantal, raring,
   and saucy successfully.

handles the issue in #2333
2013-11-24 11:46:12 -06:00
Teemu Matilainen 2073a1a939 Fix hostname setting also in Debian, part N
Port #2384 / #2383 for Debian guests.
2013-10-31 21:39:45 -03:00
Teemu Matilainen 330f72eae2 Fix hostname setting also in Debian
Same fix as #2334.
2013-10-15 15:57:40 -03:00
Alan Braithwaite 7d53047a92 Fixed fqdn handling on debian/ubuntu
The issue was that the old method simply didn't work.  When the hosts
file should look like:
    127.0.1.1   host.fqdn.com host
It looked like:
    127.0.1.1   host.fqdn.com host old.fqdn.com old
Or this if the user didn't set a fqdn
    127.0.1.1   host host old.fqdn.com old

This patch fixes that.
2013-09-22 00:33:24 -07:00
Philipp Gysin b6f2443bd5 Forcing eth0 to come up 2013-08-05 18:02:12 +02:00
Mitchell Hashimoto bc7b481dbe Get the deb/ubuntu change host name correct 2013-07-17 13:39:32 -05:00
Mitchell Hashimoto 9d6a6cc9a1 Allow hotplug on deb/ubuntu change host name [GH-1929] 2013-07-17 05:03:48 -07:00
Franz Pletz 65f275a5a8 DHCP renewal on Debian/Ubuntu after setting hostname
On Debian and Ubuntu guests, when the new hostname of the guest box is
set, the DHCP client (isc-dhcp-client) won't renew its DHCP lease with
the new hostname. Executing "ifdown -a; ifup -a" to reinitialize all auto
interfaces fixes this issue.

Furthermore, as vagrant will now actually wait until a DHCP lease is
acquired, it is guaranteed that the the correct domainname is set from
DHCP before calling other provisioners like puppet, that rely on it.
This fixes puppet/facter sometimes failing to find the fqdn fact on an
LXC guest when the DHCP server is responding too slow.
2013-07-15 12:54:52 +02:00
Fabio Rehm 4625d77072 More reliable Ubuntu and Debian guest detection
When dealing with lxc containers, '/proc/version' will have information
about the host machine kernel that can possibly have information about
an Ubuntu / Debian host, messing up with guest container detection.
2013-05-01 21:00:39 -03:00
Mitchell Hashimoto fd157476b4 extend should be include for TemplateRenderer in caps 2013-04-08 10:47:19 -07:00
Mitchell Hashimoto 7b9e5fd4a7 Include should be extend for class methods 2013-04-04 12:25:40 -07:00
Mitchell Hashimoto 61d2f9f96f SetHostname uses new cap system 2013-04-03 23:18:12 -07:00
Mitchell Hashimoto 2a542dab02 Switch configure_networks to capabilities system 2013-04-03 23:08:33 -07:00
Mitchell Hashimoto 52f3847b0a Laying the foundation for the new guest plugin 2013-04-03 21:47:57 -07:00
Mitchell Hashimoto 1d2beff649 Guests to V2 2012-11-06 21:14:45 -08:00
Mitchell Hashimoto f193d69fbc Fix up the debian guest to work with the new machine API 2012-08-20 14:58:58 -07:00
Bob Maerten 3dda019cac change_host_name should change mailname too
On Debian systems config.hostname directive should change /etc/mailname
in order to prevent problems with default mailer trying to contact
default vm's name.
2012-07-13 15:07:56 +02:00
Mitchell Hashimoto 459d82689e Get rid of autoload use in Guests
I don't use `activated` here because I'd really like to optimize
performance as much as possible, and loading files from disk is
generally slow. So instead of using `activated` I load the file at the
last possible moment which is when the exact class is being requested.

I don't think many people will do this outside of the core, and I'm not
too concerned.
2012-05-23 15:57:43 -07:00
Mitchell Hashimoto 9956e6d012 Better directory structure for plugins 2012-04-20 16:53:01 -07:00