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.
/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.
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.
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.
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
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"
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.
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
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.
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