Commit Graph

44 Commits

Author SHA1 Message Date
Chris Roberts 913b5639e5 Do better handling given netmasks 2018-01-03 17:26:08 -08:00
Chris Roberts a36a84c85a Only apply netplan configuration if systemd is in use 2018-01-03 16:31:49 -08:00
Chris Roberts 75a03ff9e9 Update available debian networking options 2018-01-03 13:56:01 -08:00
Brian Cain f046482cfb [WIP] systemd networkd for debian guests 2017-12-20 16:42:51 -08:00
Chris Roberts 2f5e15da55 Fetch first network device and pass to template for rendering 2017-05-10 12:44:37 -07:00
Chris Roberts e62d71b645 Remove comment removal from /etc/hosts file on guests
Fixes: #7794
2017-04-20 17:07:56 -07:00
Chris Roberts fb4e4320b2 Remove `set -e` usage for better shell compatibility 2016-10-24 10:30:08 -07:00
Seth Vargo c4a0a86ee0
guests/debian: Do not restart networking
Restarting networking causes Vagrant to disconnect and fail.
2016-07-18 21:12:58 -04:00
Seth Vargo cb2f3a697f
guests/debian: Do not check if rsync is installed before installing
This is already done via the rsync_installed capability.
2016-07-18 21:12:57 -04:00
Seth Vargo 76bab1932e
guests/debian: Use set -e when configuring networks 2016-07-18 21:12:57 -04:00
Seth Vargo 7a7256b3ab
guests/debian: Exit on error when configuring hostname 2016-07-18 21:12:56 -04:00
Seth Vargo 9134172ce6
guests/debian: Move NFS into same file 2016-07-18 21:12:56 -04:00
Seth Vargo cf91bcf029
guests: Always search for FQDN without sudo 2016-07-18 21:12:54 -04:00
Seth Vargo 8f3b6511f2
guests/linux: Add shared cap for listing network interfaces 2016-07-18 21:12:54 -04:00
Seth Vargo 87d2b7fec8
guests/debian: Set hostname to short value
Refs GH-7488
2016-07-18 21:12:52 -04:00
Seth Vargo d9b8352a58
guests/debian: Use predictable naming for network configuration 2016-06-06 11:58:28 -04:00
Seth Vargo dbb2d99278
guests/debian: Update guest capabilities
This updates the guest capabilities to run in as few communicator
commands as possible. Additionally, it fixes a number of issues around
hostname and idempotency.

This patch was tested against:

- puphpet/debian75-x64
- debian/jessie64
- debian/wheezy64

with custom networking, custom hostname, and rsync shared folders.
2016-06-06 11:58:28 -04:00
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
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
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
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