Commit Graph

74 Commits

Author SHA1 Message Date
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
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 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
Trey Tabner c218267436
Merge branch 'master' into debian-systemd-networkd 2018-06-13 12:49:50 -05:00
Chris Roberts 6f76275f9e
Merge pull request #9867 from jnahorny/fix-9592-systemd-networkd
Fix issue 9592 when systemd-networkd is used by Debian guest
2018-06-08 16:08:27 -07:00
Trey Tabner 59474f80fd Increase priority and support multiple networks 2018-05-30 10:10:36 -05:00
Jaroslaw Gorny 995c43dd0c Fix issue 9592 when systemd-networkd is used by Debian guest 2018-05-25 00:06:20 +02:00
Igor Mazur 66b2866373
Shorten if 2018-05-23 11:17:40 +03:00
Igor Mazur 07bbaf9ac5
Fix fo tests (symbol and string dhcp) 2018-05-22 23:29:53 +03:00
Igor Mazur be096c3ef4
Fix for ubuntu 17.10+ netplan
https://github.com/hashicorp/vagrant/issues/9570
2018-05-21 23:48:40 +03:00
Brian Cain 728a9135c8
(#9726) Update netplan config generation to detect NetworkManager
Prior to this commit, when setting up private networks on Ubuntu using
netplan, it assumed that the guest was using systemd, the suggested
default tool to manage networking, and did not take into account devices
that could be managed with NetworkManager. This commit fixes that by
looking at the devices managed on the guest to see if its managed by
NetworkManager, and if so, use that renderer for netplan instead of
networkd.
2018-05-10 13:02:05 -07:00
Chris Roberts 97dd9e0469 Adjust priority of network configuration file for debian guests
This adjusts the priority of the network configuration file from 99
to 50 making it easier for customized configuration.

Fixes #9592
2018-04-02 12:08:06 -07:00
Hannes Körber 3082ea502e
Debian: Point hostname to 127.0.1.1 in /etc/hosts
Closes #9403
2018-02-10 20:54:51 +01:00
Hannes Körber 3fa3e995a9 Debian: Renew DHCP lease on hostname change 2018-02-01 16:46:23 +01:00
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
Chris Roberts d0549d6e11 guests/linux: Provide common linux detection style
Defines a common and generic linux detection strategy which can be
subclassed and easily reused by providing a custom detection constant.
2016-10-11 07:50:34 -07:00
Reto Gantenbein 6050b13f43 Make Debian guest detection more reliable
/etc/issue is far from being a reliable source for OS detection as it
can be changed by a user without affecting any OS functionality. As
newer Debian systems run systemd by default, check for /etc/os-release
and fallback to lsb_release for older Debian versions. Check #7625 for
a similar issue. Even lsb_release is not manatory, therefore keep the
current code of parsing /etc/issue to avoid regressions.
2016-10-11 07:49:35 -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 b29864f450
Use symbols for defining guest capabilities 2016-06-17 19:55:04 -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
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