vagrant-lxc 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +9 -9
- data/README.md +51 -27
- data/boxes/common/install-salt +11 -0
- data/boxes/ubuntu/finalize +7 -1
- data/example/Vagrantfile +0 -1
- data/lib/vagrant-lxc/action.rb +13 -11
- data/lib/vagrant-lxc/action/clear_forwarded_ports.rb +1 -1
- data/lib/vagrant-lxc/action/create.rb +1 -1
- data/lib/vagrant-lxc/action/fetch_ip_from_dnsmasq_leases.rb +48 -0
- data/lib/vagrant-lxc/action/fetch_ip_with_lxc_attach.rb +46 -0
- data/lib/vagrant-lxc/action/forward_ports.rb +22 -8
- data/lib/vagrant-lxc/action/remove_temporary_files.rb +1 -1
- data/lib/vagrant-lxc/config.rb +25 -1
- data/lib/vagrant-lxc/driver.rb +42 -14
- data/lib/vagrant-lxc/driver/cli.rb +7 -60
- data/lib/vagrant-lxc/errors.rb +7 -0
- data/lib/vagrant-lxc/provider.rb +26 -3
- data/lib/vagrant-lxc/sudo_wrapper.rb +79 -0
- data/lib/vagrant-lxc/version.rb +1 -1
- data/locales/en.yml +6 -0
- data/spec/unit/action/clear_forwarded_ports_spec.rb +2 -2
- data/spec/unit/action/forward_ports_spec.rb +25 -5
- data/spec/unit/driver/cli_spec.rb +10 -14
- data/spec/unit/driver_spec.rb +17 -36
- data/tasks/boxes.rake +13 -7
- data/tasks/boxes.v2.rake +15 -8
- data/vagrant-lxc.gemspec +1 -0
- metadata +8 -6
- data/lib/vagrant-lxc/driver/builder.rb +0 -21
- data/lib/vagrant-lxc/driver/fetch_ip_from_dnsmasq.rb +0 -41
- data/lib/vagrant-lxc/driver/fetch_ip_with_attach.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53e892dfb1ea3897de7672db8cee129a7f5b65c8
|
4
|
+
data.tar.gz: 9a2767f8b694f2c3a9bbb94674c9cef9c5eec8bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca4237b0ce604a2e66e0c53252d5d5b6491e764dee60ff76e224eb0669a6171b3321422ebcf84ad6ef4c99f756d807d9987a52e28f3050c5f5f9bbc85aa5dcc0
|
7
|
+
data.tar.gz: 1db202a14678a2a86cab86d4c0cc607d676b30d29b0a125193dc610f7452f19cd0dc0b43c0b0b5111d3cc43c5d6bf1a031e14b8b6d34d4c75be251b138ea5677
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,29 @@
|
|
1
|
-
## [0.
|
1
|
+
## [0.5.0](https://github.com/fgrehm/vagrant-lxc/compare/v0.4.0...v0.5.0) (Aug 1, 2013)
|
2
|
+
|
3
|
+
BACKWARDS INCOMPATIBILITIES:
|
4
|
+
|
5
|
+
- To align with Vagrant's core behaviour, forwarded ports are no longer attached
|
6
|
+
to 127.0.0.1 and `redir`'s `--laddr` parameter is skipped in case the `:host_ip`
|
7
|
+
config is not provided, that means `redir` will listen on connections coming
|
8
|
+
from any of the host's IPs.
|
9
|
+
|
10
|
+
FEATURES:
|
11
|
+
|
12
|
+
- Add support for salt-minion and add latest dev release for ubuntu codenamed saucy [#116](https://github.com/fgrehm/vagrant-lxc/pull/116)
|
13
|
+
- Add support for using a sudo wrapper script [#90](https://github.com/fgrehm/vagrant-lxc/issues/90)
|
14
|
+
- `redir` will log to `/var/log/syslog` if `REDIR_LOG` env var is provided
|
15
|
+
|
16
|
+
IMPROVEMENTS:
|
17
|
+
|
18
|
+
- Error out if dependencies are not installed [#11](https://github.com/fgrehm/vagrant-lxc/issues/11) / [#112](https://github.com/fgrehm/vagrant-lxc/issues/112)
|
19
|
+
- Support for specifying host interface/ip for binding `redir` [#76](https://github.com/fgrehm/vagrant-lxc/issues/76)
|
20
|
+
- Add Vagrantfile VM name to the container name [#115](https://github.com/fgrehm/vagrant-lxc/issues/115)
|
21
|
+
- Properly handle forwarded port collisions [#5](https://github.com/fgrehm/vagrant-lxc/issues/5)
|
22
|
+
- Container's customizations are now written to the config file (usually
|
23
|
+
kept under `/var/lib/lxc/CONTAINER/config`) instead of passed in as a `-s`
|
24
|
+
parameter to `lxc-start`
|
25
|
+
|
26
|
+
## [0.4.0](https://github.com/fgrehm/vagrant-lxc/compare/v0.3.4...v0.4.0) (Jul 18, 2013)
|
2
27
|
|
3
28
|
FEATURES:
|
4
29
|
|
data/Gemfile
CHANGED
@@ -15,6 +15,8 @@ end
|
|
15
15
|
|
16
16
|
group :development, :test do
|
17
17
|
gem 'rake'
|
18
|
+
# Update https://github.com/fgrehm/vagrant-lxc/issues/111 once we are able to
|
19
|
+
# upgrade to a newer release
|
18
20
|
gem 'rspec', '~> 2.13.0'
|
19
21
|
gem 'rspec-fire', require: 'rspec/fire'
|
20
22
|
gem 'rspec-spies', require: false
|
data/Gemfile.lock
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
GIT
|
2
2
|
remote: git://github.com/fgrehm/vagrant-cachier.git
|
3
|
-
revision:
|
3
|
+
revision: f5d9ce507239535326a0a0395c890cc7a27d73f1
|
4
4
|
specs:
|
5
|
-
vagrant-cachier (0.
|
5
|
+
vagrant-cachier (0.3.0.dev)
|
6
6
|
|
7
7
|
GIT
|
8
8
|
remote: git://github.com/fgrehm/vagrant-pristine.git
|
9
|
-
revision:
|
9
|
+
revision: 5c400d7850fc5f98d9601b59f4c3bd74818650de
|
10
10
|
specs:
|
11
|
-
vagrant-pristine (0.
|
11
|
+
vagrant-pristine (0.2.0)
|
12
12
|
|
13
13
|
GIT
|
14
14
|
remote: git://github.com/mitchellh/vagrant.git
|
15
|
-
revision:
|
15
|
+
revision: 2282a88f3dfde65b881758b4643480cba4468c4a
|
16
16
|
specs:
|
17
|
-
vagrant (1.2.
|
17
|
+
vagrant (1.2.7.dev)
|
18
18
|
childprocess (~> 0.3.7)
|
19
19
|
erubis (~> 2.7.0)
|
20
20
|
i18n (~> 0.6.0)
|
@@ -25,7 +25,7 @@ GIT
|
|
25
25
|
PATH
|
26
26
|
remote: .
|
27
27
|
specs:
|
28
|
-
vagrant-lxc (0.
|
28
|
+
vagrant-lxc (0.5.0)
|
29
29
|
|
30
30
|
GEM
|
31
31
|
remote: https://rubygems.org/
|
@@ -60,7 +60,7 @@ GEM
|
|
60
60
|
rb-kqueue (>= 0.2)
|
61
61
|
log4r (1.1.10)
|
62
62
|
lumberjack (1.0.4)
|
63
|
-
method_source (0.8.
|
63
|
+
method_source (0.8.2)
|
64
64
|
mime-types (1.23)
|
65
65
|
multi_json (1.7.7)
|
66
66
|
net-scp (1.1.2)
|
@@ -94,7 +94,7 @@ GEM
|
|
94
94
|
multi_json (~> 1.0)
|
95
95
|
simplecov-html (~> 0.7.1)
|
96
96
|
simplecov-html (0.7.1)
|
97
|
-
slop (3.4.
|
97
|
+
slop (3.4.6)
|
98
98
|
thor (0.18.1)
|
99
99
|
vagrant-omnibus (1.1.0)
|
100
100
|
|
data/README.md
CHANGED
@@ -5,18 +5,16 @@
|
|
5
5
|
[LXC](http://lxc.sourceforge.net/) provider for [Vagrant](http://www.vagrantup.com/) 1.1+
|
6
6
|
|
7
7
|
This is a Vagrant plugin that allows it to control and provision Linux Containers
|
8
|
-
as an alternative to the built in
|
8
|
+
as an alternative to the built in VirtualBox provider for Linux hosts.
|
9
9
|
|
10
10
|
Check out this [blog post](http://fabiorehm.com/blog/2013/04/28/lxc-provider-for-vagrant)
|
11
11
|
to see the plugin in action and find out more about it.
|
12
12
|
|
13
|
-
## Features
|
13
|
+
## Features / Limitations
|
14
14
|
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
* Port forwarding
|
19
|
-
* Setting container's host name
|
15
|
+
* Provides the same workflow as the Vagrant VirtualBox provider
|
16
|
+
* Port forwarding via [`redir`](http://linux.die.net/man/1/redir)
|
17
|
+
* Does not support private networks
|
20
18
|
|
21
19
|
*Please refer to the [closed issues](https://github.com/fgrehm/vagrant-lxc/issues?labels=&milestone=&page=1&state=closed)
|
22
20
|
and the [changelog](CHANGELOG.md) for most up to date information.*
|
@@ -27,7 +25,7 @@ and the [changelog](CHANGELOG.md) for most up to date information.*
|
|
27
25
|
* [Vagrant 1.1+](http://downloads.vagrantup.com/)
|
28
26
|
* lxc 0.7.5+
|
29
27
|
* redir (if you are planning to use port forwarding)
|
30
|
-
* A [bug-free](#
|
28
|
+
* A [bug-free](https://github.com/fgrehm/vagrant-lxc/wiki/Troubleshooting#im-unable-to-restart-containers) kernel
|
31
29
|
|
32
30
|
The plugin is known to work better and pretty much out of the box on Ubuntu 12.04+
|
33
31
|
hosts and installing the dependencies on it basically means a `apt-get install lxc redir`
|
@@ -35,8 +33,8 @@ and a `apt-get update && apt-get dist-upgrade` to upgrade the kernel.
|
|
35
33
|
|
36
34
|
Some manual steps are required to set up a Linode machine prior to using this
|
37
35
|
plugin, please check https://github.com/fgrehm/vagrant-lxc/wiki/Usage-on-Linode
|
38
|
-
for more information.
|
39
|
-
|
36
|
+
for more information. Documentation on how to set things up for other distros
|
37
|
+
[are welcome](https://github.com/fgrehm/vagrant-lxc/wiki) :)
|
40
38
|
|
41
39
|
If you are on a Mac or Windows machine, you might want to have a look at this
|
42
40
|
blog post for some ideas on how to set things up: http://the.taoofmac.com/space/HOWTO/Vagrant
|
@@ -89,12 +87,50 @@ Vagrant.configure("2") do |config|
|
|
89
87
|
end
|
90
88
|
```
|
91
89
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
`/var/lib/lxc/<container-name>/config`.
|
90
|
+
vagrant-lxc will then write out `lxc.cgroup.memory.limit_in_bytes='1024M'` to the
|
91
|
+
container config file (usually kept under `/var/lib/lxc/<container-name>/config`)
|
92
|
+
prior to starting it.
|
96
93
|
|
97
|
-
For other configuration options, please check [lxc.conf manpages](http://manpages.ubuntu.com/manpages/quantal/man5/lxc.conf.5.html).
|
94
|
+
For other configuration options, please check the [lxc.conf manpages](http://manpages.ubuntu.com/manpages/quantal/man5/lxc.conf.5.html).
|
95
|
+
|
96
|
+
|
97
|
+
### Avoiding `sudo` passwords
|
98
|
+
|
99
|
+
This plugin requires **a lot** of `sudo`ing since [user namespaces](https://wiki.ubuntu.com/UserNamespace)
|
100
|
+
are not supported on mainstream kernels. In order to work around that we can use
|
101
|
+
a really dumb **AND INSECURE** Ruby wrapper script like the one below and add
|
102
|
+
a `NOPASSWD` entry to our `/etc/sudoers` file:
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
#!/usr/bin/env ruby
|
106
|
+
exec ARGV.join(' ')
|
107
|
+
```
|
108
|
+
|
109
|
+
For example, you can save the code above under your `/usr/bin/lxc-vagrant-wrapper`,
|
110
|
+
turn it into an executable script by running `chmod +x /usr/bin/lxc-vagrant-wrapper`
|
111
|
+
and add the line below to your `/etc/sudoers` file:
|
112
|
+
|
113
|
+
```
|
114
|
+
USERNAME ALL=NOPASSWD:/usr/bin/lxc-vagrant-wrapper
|
115
|
+
```
|
116
|
+
|
117
|
+
*__WARNING__: the `/usr/bin/lxc-vagrant-wrapper` + `/etc/sudoers` combination
|
118
|
+
above allows `USERNAME` to run any privileged command without a password. You
|
119
|
+
might want to think twice before using that on a machine with sensitive data.*
|
120
|
+
|
121
|
+
In order to tell vagrant-lxc to use that script when `sudo` is needed, you can
|
122
|
+
pass in the path to the script as a configuration for the provider:
|
123
|
+
|
124
|
+
```ruby
|
125
|
+
Vagrant.configure("2") do |config|
|
126
|
+
config.vm.provider :lxc do |lxc|
|
127
|
+
lxc.sudo_wrapper = '/usr/bin/lxc-vagrant-wrapper'
|
128
|
+
end
|
129
|
+
end
|
130
|
+
```
|
131
|
+
|
132
|
+
If you want to set the `sudo_wrapper` globally, just add the code above to your
|
133
|
+
`~/.vagrant.d/Vagrantfile`.
|
98
134
|
|
99
135
|
|
100
136
|
### Base boxes
|
@@ -104,18 +140,6 @@ for a list of [pre built](https://github.com/fgrehm/vagrant-lxc/wiki/Base-boxes#
|
|
104
140
|
base boxes and information on [how to build your own](https://github.com/fgrehm/vagrant-lxc/wiki/Base-boxes#building-your-own).
|
105
141
|
|
106
142
|
|
107
|
-
## Current limitations
|
108
|
-
|
109
|
-
* The plugin does not detect forwarded ports collision, right now you are
|
110
|
-
responsible for taking care of that.
|
111
|
-
* There is a hell lot of `sudo`s involved and this will probably be around until
|
112
|
-
[user namespaces](https://wiki.ubuntu.com/LxcSecurity) are supported or I'm able to handle [#90](https://github.com/fgrehm/vagrant-lxc/issues/90)
|
113
|
-
* [Does not tell you if dependencies are not met](https://github.com/fgrehm/vagrant-lxc/issues/11)
|
114
|
-
(will probably just throw up some random error)
|
115
|
-
* + bunch of other [core features](https://github.com/fgrehm/vagrant-lxc/issues?labels=core&milestone=&page=1&state=open)
|
116
|
-
and some known [bugs](https://github.com/fgrehm/vagrant-lxc/issues?labels=bug&page=1&state=open)
|
117
|
-
|
118
|
-
|
119
143
|
## More information
|
120
144
|
|
121
145
|
Please refer the [wiki](https://github.com/fgrehm/vagrant-lxc/wiki) for more
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
cache=`readlink -f .`
|
4
|
+
rootfs="${cache}/rootfs"
|
5
|
+
|
6
|
+
echo "installing salt"
|
7
|
+
chroot $rootfs apt-add-repository -y ppa:saltstack/salt
|
8
|
+
chroot $rootfs apt-get update
|
9
|
+
chroot $rootfs apt-get install salt-minion -y --force-yes
|
10
|
+
|
11
|
+
rm -rf $rootfs/tmp/*
|
data/boxes/ubuntu/finalize
CHANGED
@@ -148,12 +148,18 @@ write_sourceslist()
|
|
148
148
|
deb [arch=$2] $MIRROR ${release} main restricted universe multiverse
|
149
149
|
deb [arch=$2] $MIRROR ${release}-updates main restricted universe multiverse
|
150
150
|
deb [arch=$2] $SECURITY_MIRROR ${release}-security main restricted universe multiverse
|
151
|
+
deb-src [arch=$2] $MIRROR ${release} main restricted universe multiverse
|
152
|
+
deb-src [arch=$2] $MIRROR ${release}-updates main restricted universe multiverse
|
153
|
+
deb-src [arch=$2] $SECURITY_MIRROR ${release}-security main restricted universe multiverse
|
151
154
|
EOF
|
152
155
|
else
|
153
156
|
cat >> "$1/etc/apt/sources.list" << EOF
|
154
157
|
deb $MIRROR ${release} main restricted universe multiverse
|
155
158
|
deb $MIRROR ${release}-updates main restricted universe multiverse
|
156
159
|
deb $SECURITY_MIRROR ${release}-security main restricted universe multiverse
|
160
|
+
deb-src $MIRROR ${release} main restricted universe multiverse
|
161
|
+
deb-src $MIRROR ${release}-updates main restricted universe multiverse
|
162
|
+
deb-src $SECURITY_MIRROR ${release}-security main restricted universe multiverse
|
157
163
|
EOF
|
158
164
|
fi
|
159
165
|
}
|
@@ -248,7 +254,7 @@ post_process()
|
|
248
254
|
release=$2
|
249
255
|
trim_container=$3
|
250
256
|
|
251
|
-
if [ $trim_container -eq 1 ]; then
|
257
|
+
if [[ $trim_container -eq 1 ]]; then
|
252
258
|
trim $rootfs $release
|
253
259
|
elif [ ! -f $rootfs/etc/init/container-detect.conf ]; then
|
254
260
|
# Make sure we have a working resolv.conf
|
data/example/Vagrantfile
CHANGED
data/lib/vagrant-lxc/action.rb
CHANGED
@@ -8,6 +8,8 @@ require 'vagrant-lxc/action/destroy'
|
|
8
8
|
require 'vagrant-lxc/action/destroy_confirm'
|
9
9
|
require 'vagrant-lxc/action/disconnect'
|
10
10
|
require 'vagrant-lxc/action/compress_rootfs'
|
11
|
+
require 'vagrant-lxc/action/fetch_ip_with_lxc_attach'
|
12
|
+
require 'vagrant-lxc/action/fetch_ip_from_dnsmasq_leases'
|
11
13
|
require 'vagrant-lxc/action/forced_halt'
|
12
14
|
require 'vagrant-lxc/action/forward_ports'
|
13
15
|
require 'vagrant-lxc/action/handle_box_metadata'
|
@@ -25,7 +27,6 @@ module Vagrant
|
|
25
27
|
# machine back up with the new configuration.
|
26
28
|
def self.action_reload
|
27
29
|
Vagrant::Action::Builder.new.tap do |b|
|
28
|
-
# b.use CheckDependencies
|
29
30
|
b.use Vagrant::Action::Builtin::Call, Created do |env1, b2|
|
30
31
|
if !env1[:result]
|
31
32
|
b2.use Message, :not_created
|
@@ -44,10 +45,9 @@ module Vagrant
|
|
44
45
|
# a bootup (i.e. not saved).
|
45
46
|
def self.action_boot
|
46
47
|
Vagrant::Action::Builder.new.tap do |b|
|
47
|
-
# b.use ClearForwardedPorts
|
48
48
|
b.use Vagrant::Action::Builtin::Provision
|
49
49
|
b.use Vagrant::Action::Builtin::EnvSet, :port_collision_repair => true
|
50
|
-
|
50
|
+
b.use Vagrant::Action::Builtin::HandleForwardedPortCollisions
|
51
51
|
b.use ShareFolders
|
52
52
|
b.use Vagrant::Action::Builtin::SetHostname
|
53
53
|
b.use ForwardPorts
|
@@ -58,7 +58,6 @@ module Vagrant
|
|
58
58
|
# This action just runs the provisioners on the machine.
|
59
59
|
def self.action_provision
|
60
60
|
Vagrant::Action::Builder.new.tap do |b|
|
61
|
-
# b.use CheckDependencies
|
62
61
|
b.use Vagrant::Action::Builtin::ConfigValidate
|
63
62
|
b.use Vagrant::Action::Builtin::Call, Created do |env1, b2|
|
64
63
|
if !env1[:result]
|
@@ -82,7 +81,6 @@ module Vagrant
|
|
82
81
|
# A precondition of this action is that the container exists.
|
83
82
|
def self.action_start
|
84
83
|
Vagrant::Action::Builder.new.tap do |b|
|
85
|
-
# b.use CheckDependencies
|
86
84
|
b.use Vagrant::Action::Builtin::ConfigValidate
|
87
85
|
b.use Vagrant::Action::Builtin::Call, IsRunning do |env, b2|
|
88
86
|
# If the VM is running, then our work here is done, exit
|
@@ -97,7 +95,6 @@ module Vagrant
|
|
97
95
|
# container, configuring metadata, and booting.
|
98
96
|
def self.action_up
|
99
97
|
Vagrant::Action::Builder.new.tap do |b|
|
100
|
-
# b.use CheckDependencies
|
101
98
|
b.use Vagrant::Action::Builtin::ConfigValidate
|
102
99
|
b.use Vagrant::Action::Builtin::Call, Created do |env, b2|
|
103
100
|
# If the VM is NOT created yet, then do the setup steps
|
@@ -115,7 +112,6 @@ module Vagrant
|
|
115
112
|
# the virtual machine, gracefully or by force.
|
116
113
|
def self.action_halt
|
117
114
|
Vagrant::Action::Builder.new.tap do |b|
|
118
|
-
# b.use CheckDependencies
|
119
115
|
b.use Vagrant::Action::Builtin::Call, Created do |env, b2|
|
120
116
|
if env[:result]
|
121
117
|
# TODO: Remove this on / after 0.4
|
@@ -138,7 +134,6 @@ module Vagrant
|
|
138
134
|
# freeing the resources of the underlying virtual machine.
|
139
135
|
def self.action_destroy
|
140
136
|
Vagrant::Action::Builder.new.tap do |b|
|
141
|
-
# b.use CheckDependencies
|
142
137
|
b.use Vagrant::Action::Builtin::Call, Created do |env1, b2|
|
143
138
|
if !env1[:result]
|
144
139
|
b2.use Message, :not_created
|
@@ -162,7 +157,6 @@ module Vagrant
|
|
162
157
|
# This action packages the virtual machine into a single box file.
|
163
158
|
def self.action_package
|
164
159
|
Vagrant::Action::Builder.new.tap do |b|
|
165
|
-
# b.use CheckDependencies
|
166
160
|
b.use Vagrant::Action::Builtin::Call, Created do |env1, b2|
|
167
161
|
if !env1[:result]
|
168
162
|
b2.use Message, :not_created
|
@@ -177,10 +171,19 @@ module Vagrant
|
|
177
171
|
end
|
178
172
|
end
|
179
173
|
|
174
|
+
# This action is called to read the IP of the container. The IP found
|
175
|
+
# is expected to be put into the `:machine_ip` key.
|
176
|
+
def self.action_fetch_ip
|
177
|
+
Vagrant::Action::Builder.new.tap do |b|
|
178
|
+
b.use Vagrant::Action::Builtin::ConfigValidate
|
179
|
+
b.use FetchIpWithLxcAttach
|
180
|
+
b.use FetchIpFromDnsmasqLeases
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
180
184
|
# This is the action that will exec into an SSH shell.
|
181
185
|
def self.action_ssh
|
182
186
|
Vagrant::Action::Builder.new.tap do |b|
|
183
|
-
# b.use CheckDependencies
|
184
187
|
b.use CheckCreated
|
185
188
|
b.use CheckRunning
|
186
189
|
b.use Vagrant::Action::Builtin::SSHExec
|
@@ -190,7 +193,6 @@ module Vagrant
|
|
190
193
|
# This is the action that will run a single SSH command.
|
191
194
|
def self.action_ssh_run
|
192
195
|
Vagrant::Action::Builder.new.tap do |b|
|
193
|
-
# b.use CheckDependencies
|
194
196
|
b.use CheckCreated
|
195
197
|
b.use CheckRunning
|
196
198
|
b.use Vagrant::Action::Builtin::SSHRun
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module LXC
|
3
|
+
module Action
|
4
|
+
class FetchIpFromDnsmasqLeases
|
5
|
+
def initialize(app, env)
|
6
|
+
@app = app
|
7
|
+
@logger = Log4r::Logger.new("vagrant::lxc::action::fetch_ip_from_dnsmasq_leases")
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
env[:machine_ip] ||= assigned_ip(env)
|
12
|
+
@app.call(env)
|
13
|
+
end
|
14
|
+
|
15
|
+
def assigned_ip(env)
|
16
|
+
mac_address = env[:machine].provider.driver.mac_address
|
17
|
+
ip = nil
|
18
|
+
10.times do
|
19
|
+
dnsmasq_leases = read_dnsmasq_leases
|
20
|
+
@logger.debug 'Attempting to load ip from dnsmasq leases'
|
21
|
+
@logger.debug dnsmasq_leases
|
22
|
+
if dnsmasq_leases =~ /#{Regexp.escape mac_address}\s+([0-9.]+)\s+/
|
23
|
+
ip = $1.to_s
|
24
|
+
break
|
25
|
+
else
|
26
|
+
@logger.debug 'Ip could not be parsed from dnsmasq leases file'
|
27
|
+
sleep 2
|
28
|
+
end
|
29
|
+
end
|
30
|
+
ip
|
31
|
+
end
|
32
|
+
|
33
|
+
LEASES_PATHS = %w(
|
34
|
+
/var/lib/misc/dnsmasq.*.leases
|
35
|
+
/var/lib/misc/dnsmasq.leases
|
36
|
+
/var/lib/dnsmasq/dnsmasq.leases
|
37
|
+
/var/db/dnsmasq.leases
|
38
|
+
)
|
39
|
+
|
40
|
+
def read_dnsmasq_leases
|
41
|
+
Dir["{#{LEASES_PATHS.join(',')}}"].map do |file|
|
42
|
+
File.read(file)
|
43
|
+
end.join("\n")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|