We're using snapshots in a CI set-up so that a Vagrant cluster can be built
once, then each push to the repository only checked as an incremental
update to the cluster. We copy each LXC VM to a master image, then re-create
the original names as snapshots.
This change corrects a method which assumes the LXC root path in the config
file is a simple directory name, which is only true for directory-backed
instances.
Conflicts:
spec/unit/driver_spec.rb
The LXC provider issues the "fetch_ip" action to look up the IP address
of the container as part of its "ssh_info" action.
Vagrant::LXC::Action.action_fetch_ip checks the machine state using
Builtin::IsState, which calls Vagrant::Machine.state, which also updates
the state in the machine index and acquires a machine index entry lock to do that.
A race condition ensues in WaitForCommunicator.call, where ready_thr tries
to acquire the machine index lock while running ssh_info, and states_thr tries
to acquire the same lock doing its own state look up (env[:machine].state.id).
If they both try to acquire the lock at the same time, one will fail, and
an exception will be raised.
Work around this issue by checking for the desired machine state (:running) in
Vagrant::LXC::Provider.ssh_info, which can get the state from
Vagrant::LXC::Provider.state, which in turn does not write out the state into
the index file and does not acquire the index entry lock.
* for lxc to 1.0.0 using constant Vagrant::LXC::Driver::DEFAULT_CONTAINERS_PATH
* change method Vagrant::LXC::Driver::CLI#version to call lxc-create if lxc-version command not exists (to lxc version 1.0.0)
This action apparently needs to be added to every provider. See
lib/vagrant/plugins/providers/virtualbox/action.rb from the Vagrant
source for reference how the virtualbox provider is doing it.
Since the wrapper is versioned, we would end up having multiple `LXC`
command aliases, making `sudo` unusable:
```
>>> /etc/sudoers.d/vagrant-lxc-1-0-0-alpha-3-dev: Alias `LXC' already
>>> defined near line 2 <<<
sudo: parse error in /etc/sudoers.d/vagrant-lxc-1-0-0-alpha-3-dev near
line 2
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin
```
Some platforms (most notably CentOS and RHEL) use a kernel without
'attach' support. This patch detects this absence and falls back
to the alternative ways of doing things like detection of IP address
and halting the container.
It does so by running the command "true" through lxc-attach.
The regex check for the container MAC address presence in the
dnsmasq leases file is case sensitive. Dnsmasq outputs uppercase
addresses in the leases file.
As MAC addresses are generally considered case insensitive, it
makes sense to relax the regular expression check to allow for this.
Sudoers now creates a safe wrapper script that performs sanity checks on sudo :
* wrapper generated in /usr/local/bin (name includes version to allow multiple wrappers on the same system)
* sudoers command now generates a one-line file in /etc/sudoers.d
* SudoWrapper use the new wrapper
* Removed unused Config#validate method
It's useful if you want to mount something inside /vagrant or if you
have some another mount in some synced folder.
This piece of code is extracted from virtualbox driver.
Previously, the utsname of a machine was set to the vagrant machine ID.
As the utsname represents the hostname of the machine and is independent
from the name of the actual LXC container, the hostname that was
specified in the Vagrantfile should be used instead. If no hostname is
provided, the machine ID will be used like before.
Additionally, this will trigger the DHCP client in the container to send
the correct hostname to the DHCP server on the first request at boot.
Vagrant sets the configured hostname only after the network is up. If
for example automatic DNS updates are configured, the right DNS record
will be created every time.