vagrant-lxc 1.4.0 → 1.4.1
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 +5 -5
- data/.travis.yml +1 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +2 -2
- data/README.md +1 -1
- data/lib/vagrant-lxc/action/boot.rb +7 -3
- data/lib/vagrant-lxc/action/create.rb +9 -1
- data/lib/vagrant-lxc/action/forward_ports.rb +15 -2
- data/lib/vagrant-lxc/action/handle_box_metadata.rb +2 -0
- data/lib/vagrant-lxc/driver.rb +8 -2
- data/lib/vagrant-lxc/driver/cli.rb +1 -1
- data/lib/vagrant-lxc/version.rb +1 -1
- data/scripts/lxc-template +11 -2
- data/spec/unit/action/forward_ports_spec.rb +16 -6
- data/spec/unit/driver_spec.rb +6 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 73218c6a794374a682e74972ea67214bd099f23de97c559ab8eea60550c9e3e7
|
4
|
+
data.tar.gz: 1f3e74d08fc10118458b5f0f0de19fc86e766bac9de2601e378c70d909dbf403
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df22280938f9a3f685260c891363b558c5b2eb052bedf5a7bfc5c43aabf0dd890c44308288cf4516e6dfe42e2ba9011d14d94ae00b29311a4a9e1575c74efb1d
|
7
|
+
data.tar.gz: 8ab355586daea42c581bb624c0de1beb769f70d719bbc0114398be954315c32af8552971fe12067d57817e5fa5858a7e3779a72c62bf9fab7a649c6c838b5fc4
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [1.4.1](https://github.com/fgrehm/vagrant-lxc/compare/v1.4.0...v1.4.1) (Apr 30, 2018)
|
2
|
+
|
3
|
+
FEATURES:
|
4
|
+
- Add support for LXC v3.0
|
5
|
+
- Add support for `redir` 3.x command line. [[GH-460]]
|
6
|
+
|
7
|
+
[GH-460]: https://github.com/fgrehm/vagrant-lxc/issues/460
|
8
|
+
|
1
9
|
## [1.4.0](https://github.com/fgrehm/vagrant-lxc/compare/v1.3.1...v1.4.0) (Mar 04, 2018)
|
2
10
|
|
3
11
|
FEATURES:
|
data/Gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
group :development do
|
4
|
-
gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git', tag: '
|
4
|
+
gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git', tag: 'v2.0.4'
|
5
5
|
gem 'guard'
|
6
6
|
gem 'guard-rspec'
|
7
7
|
gem 'rb-inotify'
|
@@ -12,7 +12,7 @@ group :development, :test do
|
|
12
12
|
gem 'rspec', '~> 2.99.0'
|
13
13
|
gem 'coveralls', '~> 0.7.2', require: (ENV['COVERAGE'] == 'true')
|
14
14
|
# The is the ref *just* before we switch to childprocess 0.6, which conflicts with vagrant 1.8 deps.
|
15
|
-
gem 'vagrant-spec', git: 'https://github.com/mitchellh/vagrant-spec.git', ref: '5006bc73cd8796465ca09307d4774f8ec8375aa0'
|
15
|
+
# gem 'vagrant-spec', git: 'https://github.com/mitchellh/vagrant-spec.git', ref: '5006bc73cd8796465ca09307d4774f8ec8375aa0'
|
16
16
|
end
|
17
17
|
|
18
18
|
group :plugins do
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ to see it in action.
|
|
12
12
|
## Features
|
13
13
|
|
14
14
|
* Provides the same workflow as the Vagrant VirtualBox provider
|
15
|
-
* Port forwarding via [`redir`](
|
15
|
+
* Port forwarding via [`redir`](https://github.com/troglobit/redir)
|
16
16
|
* Private networking via [`pipework`](https://github.com/jpetazzo/pipework)
|
17
17
|
|
18
18
|
## Requirements
|
@@ -8,11 +8,15 @@ module Vagrant
|
|
8
8
|
|
9
9
|
def call(env)
|
10
10
|
@env = env
|
11
|
-
|
11
|
+
driver = env[:machine].provider.driver
|
12
12
|
config = env[:machine].provider_config
|
13
13
|
|
14
14
|
utsname = env[:machine].config.vm.hostname || env[:machine].id
|
15
|
-
|
15
|
+
if driver.supports_new_config_format
|
16
|
+
config.customize 'uts.name', utsname
|
17
|
+
else
|
18
|
+
config.customize 'utsname', utsname
|
19
|
+
end
|
16
20
|
|
17
21
|
# Fix apparmor issues when starting Ubuntu 14.04 containers
|
18
22
|
# See https://github.com/fgrehm/vagrant-lxc/issues/278 for more information
|
@@ -32,7 +36,7 @@ module Vagrant
|
|
32
36
|
end
|
33
37
|
|
34
38
|
env[:ui].info I18n.t("vagrant_lxc.messages.starting")
|
35
|
-
|
39
|
+
driver.start(config.customizations)
|
36
40
|
|
37
41
|
@app.call env
|
38
42
|
end
|
@@ -24,13 +24,21 @@ module Vagrant
|
|
24
24
|
backingstore = config.privileged ? "best" : "dir"
|
25
25
|
end
|
26
26
|
driver = env[:machine].provider.driver
|
27
|
+
template_options = env[:lxc_template_opts]
|
28
|
+
if driver.supports_new_config_format
|
29
|
+
if env[:lxc_box_config]
|
30
|
+
driver.update_config_keys(env[:lxc_box_config])
|
31
|
+
end
|
32
|
+
else
|
33
|
+
template_options['--oldconfig'] = ''
|
34
|
+
end
|
27
35
|
driver.create(
|
28
36
|
container_name,
|
29
37
|
backingstore,
|
30
38
|
config.backingstore_options,
|
31
39
|
env[:lxc_template_src],
|
32
40
|
env[:lxc_template_config],
|
33
|
-
|
41
|
+
template_options
|
34
42
|
)
|
35
43
|
driver.update_config_keys
|
36
44
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
1
3
|
module Vagrant
|
2
4
|
module LXC
|
3
5
|
module Action
|
@@ -78,8 +80,13 @@ module Vagrant
|
|
78
80
|
end
|
79
81
|
|
80
82
|
def redirect_port(host_ip, host_port, guest_ip, guest_port)
|
81
|
-
|
82
|
-
|
83
|
+
if redir_version >= 3
|
84
|
+
params = %W( :#{host_port} #{guest_ip}:#{guest_port} )
|
85
|
+
params[0] = "#{host_ip}:#{host_port}" if host_ip
|
86
|
+
else
|
87
|
+
params = %W( --lport=#{host_port} --caddr=#{guest_ip} --cport=#{guest_port} )
|
88
|
+
params.unshift "--laddr=#{host_ip}" if host_ip
|
89
|
+
end
|
83
90
|
params << '--syslog' if ENV['REDIR_LOG']
|
84
91
|
if host_port < 1024
|
85
92
|
redir_cmd = "sudo redir #{params.join(' ')} 2>/dev/null"
|
@@ -99,6 +106,12 @@ module Vagrant
|
|
99
106
|
end
|
100
107
|
end
|
101
108
|
|
109
|
+
def redir_version
|
110
|
+
# For some weird reason redir prints version information in STDERR
|
111
|
+
_, version, _ = Open3.capture3 "redir --version"
|
112
|
+
version.split('.')[0].to_i
|
113
|
+
end
|
114
|
+
|
102
115
|
def redir_installed?
|
103
116
|
system "which redir > /dev/null"
|
104
117
|
end
|
@@ -33,8 +33,10 @@ module Vagrant
|
|
33
33
|
end
|
34
34
|
|
35
35
|
if template_config_file.exist?
|
36
|
+
@env[:lxc_box_config] = template_config_file.to_s
|
36
37
|
@env[:lxc_template_opts].merge!('--config' => template_config_file.to_s)
|
37
38
|
elsif old_template_config_file.exist?
|
39
|
+
@env[:lxc_box_config] = old_template_config_file.to_s
|
38
40
|
@env[:lxc_template_config] = old_template_config_file.to_s
|
39
41
|
end
|
40
42
|
|
data/lib/vagrant-lxc/driver.rb
CHANGED
@@ -83,6 +83,7 @@ module Vagrant
|
|
83
83
|
@cli.name = @container_name = name
|
84
84
|
|
85
85
|
@logger.debug "Creating container..."
|
86
|
+
|
86
87
|
@cli.create template_path, backingstore, backingstore_options, config_file, template_options
|
87
88
|
end
|
88
89
|
|
@@ -214,6 +215,10 @@ module Vagrant
|
|
214
215
|
@version ||= @cli.version
|
215
216
|
end
|
216
217
|
|
218
|
+
def supports_new_config_format
|
219
|
+
Gem::Version.new(version) >= Gem::Version.new('2.1.0')
|
220
|
+
end
|
221
|
+
|
217
222
|
# TODO: This needs to be reviewed and specs needs to be written
|
218
223
|
def compress_rootfs
|
219
224
|
# TODO: Pass in tmpdir so we can clean up from outside
|
@@ -244,8 +249,9 @@ module Vagrant
|
|
244
249
|
write_config(contents)
|
245
250
|
end
|
246
251
|
|
247
|
-
def update_config_keys
|
248
|
-
|
252
|
+
def update_config_keys(path = nil)
|
253
|
+
path = path || config_path
|
254
|
+
@cli.update_config(path)
|
249
255
|
rescue Errors::ExecuteError
|
250
256
|
# not on LXC 2.1+. Doesn't matter, ignore.
|
251
257
|
end
|
data/lib/vagrant-lxc/version.rb
CHANGED
data/scripts/lxc-template
CHANGED
@@ -33,8 +33,10 @@ LXC_PATH=
|
|
33
33
|
LXC_ROOTFS=
|
34
34
|
LXC_TARBALL=
|
35
35
|
LXC_CONFIG=
|
36
|
+
LXC_USE_OLDCONFIG=
|
36
37
|
LXC_STRIP_COMPONENTS=2
|
37
38
|
|
39
|
+
|
38
40
|
usage() {
|
39
41
|
cat <<EOF
|
40
42
|
vagrant-lxc default template
|
@@ -44,6 +46,7 @@ Required arguments:
|
|
44
46
|
|
45
47
|
Optional arguments:
|
46
48
|
[ --config ]: Configuration file to be used when building the container
|
49
|
+
[ --oldconfig ]: Use pre LXC 2.1 config format
|
47
50
|
[ -h | --help ]: This help message
|
48
51
|
|
49
52
|
LXC internal arguments (do not pass manually!):
|
@@ -57,7 +60,7 @@ EOF
|
|
57
60
|
return 0
|
58
61
|
}
|
59
62
|
|
60
|
-
options=$(getopt -o h -l tarball:,config:,help:,name:,path:,rootfs:,mapped-uid:,mapped-gid:,strip-components: -- "$@")SS
|
63
|
+
options=$(getopt -o h -l tarball:,config:,oldconfig,help:,name:,path:,rootfs:,mapped-uid:,mapped-gid:,strip-components: -- "$@")SS
|
61
64
|
|
62
65
|
if [ $? -ne 0 ]; then
|
63
66
|
usage $(basename $0)
|
@@ -70,6 +73,7 @@ do
|
|
70
73
|
case "$1" in
|
71
74
|
-h|--help) usage $0 && exit 0;;
|
72
75
|
--config) LXC_CONFIG=$2; shift 2;;
|
76
|
+
--oldconfig) LXC_USE_OLDCONFIG=1; shift 1;;
|
73
77
|
--tarball) LXC_TARBALL=$2; shift 2;;
|
74
78
|
--name) LXC_NAME=$2; shift 2;;
|
75
79
|
--path) LXC_PATH=$2; shift 2;;
|
@@ -144,7 +148,12 @@ if [ -e "${LXC_PATH}/config-auto" ]; then
|
|
144
148
|
cat ${LXC_PATH}/config-auto >> ${LXC_PATH}/config
|
145
149
|
rm ${LXC_PATH}/config-auto
|
146
150
|
fi
|
147
|
-
|
151
|
+
|
152
|
+
if [ $LXC_USE_OLDCONFIG ]; then
|
153
|
+
echo "lxc.utsname = ${LXC_NAME}" >> ${LXC_PATH}/config
|
154
|
+
else
|
155
|
+
echo "lxc.uts.name = ${LXC_NAME}" >> ${LXC_PATH}/config
|
156
|
+
fi
|
148
157
|
|
149
158
|
## Re-add the previously removed network config
|
150
159
|
if [ -e "${LXC_PATH}/config-network" ]; then
|
@@ -24,6 +24,7 @@ describe Vagrant::LXC::Action::ForwardPorts do
|
|
24
24
|
machine.stub_chain(:config, :vm, :networks).and_return(networks)
|
25
25
|
machine.stub(provider: provider, data_dir: data_dir)
|
26
26
|
|
27
|
+
subject.stub(redir_version: 3)
|
27
28
|
subject.stub(exec: true)
|
28
29
|
subject.stub(spawn: pid)
|
29
30
|
end
|
@@ -34,7 +35,7 @@ describe Vagrant::LXC::Action::ForwardPorts do
|
|
34
35
|
subject.stub(system: true)
|
35
36
|
subject.call(env)
|
36
37
|
expect(subject).to have_received(:spawn).with(
|
37
|
-
"redir
|
38
|
+
"redir #{host_ip}:#{host_port} #{container_ip}:#{guest_port} 2>/dev/null"
|
38
39
|
)
|
39
40
|
end
|
40
41
|
|
@@ -43,7 +44,7 @@ describe Vagrant::LXC::Action::ForwardPorts do
|
|
43
44
|
subject.stub(system: true)
|
44
45
|
subject.call(env)
|
45
46
|
expect(subject).to have_received(:spawn).with(
|
46
|
-
"redir
|
47
|
+
"redir 127.0.0.1:#{host_port} #{container_ip}:#{guest_port} 2>/dev/null"
|
47
48
|
)
|
48
49
|
end
|
49
50
|
|
@@ -52,7 +53,7 @@ describe Vagrant::LXC::Action::ForwardPorts do
|
|
52
53
|
subject.stub(system: true)
|
53
54
|
subject.call(env)
|
54
55
|
expect(subject).to have_received(:spawn).with(
|
55
|
-
"redir
|
56
|
+
"redir 127.0.0.1:#{host_port} #{container_ip}:#{guest_port} 2>/dev/null"
|
56
57
|
)
|
57
58
|
end
|
58
59
|
|
@@ -70,6 +71,15 @@ describe Vagrant::LXC::Action::ForwardPorts do
|
|
70
71
|
expect(subject).not_to have_received(:spawn)
|
71
72
|
end
|
72
73
|
|
74
|
+
it 'uses redir 2.x command line interface' do
|
75
|
+
subject.stub(system: true)
|
76
|
+
subject.stub(redir_version: 2)
|
77
|
+
subject.call(env)
|
78
|
+
expect(subject).to have_received(:spawn).with(
|
79
|
+
"redir --laddr=#{host_ip} --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null"
|
80
|
+
)
|
81
|
+
end
|
82
|
+
|
73
83
|
it 'raises RedirNotInstalled error if `redir` is not installed' do
|
74
84
|
subject.stub(system: false)
|
75
85
|
expect { subject.call(env) }.to raise_error(Vagrant::LXC::Errors::RedirNotInstalled)
|
@@ -82,7 +92,7 @@ describe Vagrant::LXC::Action::ForwardPorts do
|
|
82
92
|
subject.stub(system: true)
|
83
93
|
subject.call(env)
|
84
94
|
expect(subject).to have_received(:spawn).with(
|
85
|
-
"sudo redir
|
95
|
+
"sudo redir #{host_ip}:#{host_port} #{container_ip}:#{guest_port} 2>/dev/null"
|
86
96
|
)
|
87
97
|
end
|
88
98
|
|
@@ -91,7 +101,7 @@ describe Vagrant::LXC::Action::ForwardPorts do
|
|
91
101
|
subject.stub(system: true)
|
92
102
|
subject.call(env)
|
93
103
|
expect(subject).to have_received(:spawn).with(
|
94
|
-
"sudo redir
|
104
|
+
"sudo redir 127.0.0.1:#{host_port} #{container_ip}:#{guest_port} 2>/dev/null"
|
95
105
|
)
|
96
106
|
end
|
97
107
|
|
@@ -100,7 +110,7 @@ describe Vagrant::LXC::Action::ForwardPorts do
|
|
100
110
|
subject.stub(system: true)
|
101
111
|
subject.call(env)
|
102
112
|
expect(subject).to have_received(:spawn).with(
|
103
|
-
"sudo redir
|
113
|
+
"sudo redir 127.0.0.1:#{host_port} #{container_ip}:#{guest_port} 2>/dev/null"
|
104
114
|
)
|
105
115
|
end
|
106
116
|
end
|
data/spec/unit/driver_spec.rb
CHANGED
@@ -211,9 +211,9 @@ describe Vagrant::LXC::Driver do
|
|
211
211
|
# Blah blah comment
|
212
212
|
lxc.mount.entry = proc proc proc nodev,noexec,nosuid 0 0
|
213
213
|
lxc.mount.entry = sysfs sys sysfs defaults 0 0
|
214
|
-
lxc.tty = 4
|
215
|
-
lxc.
|
216
|
-
lxc.rootfs = #{rootfs_path}
|
214
|
+
lxc.tty.max = 4
|
215
|
+
lxc.pty.max = 1024
|
216
|
+
lxc.rootfs.path = #{rootfs_path}
|
217
217
|
# VAGRANT-BEGIN
|
218
218
|
lxc.network.type=veth
|
219
219
|
lxc.network.name=eth1
|
@@ -241,9 +241,9 @@ describe Vagrant::LXC::Driver do
|
|
241
241
|
# Blah blah comment
|
242
242
|
lxc.mount.entry = proc proc proc nodev,noexec,nosuid 0 0
|
243
243
|
lxc.mount.entry = sysfs sys sysfs defaults 0 0
|
244
|
-
lxc.tty = 4
|
245
|
-
lxc.
|
246
|
-
lxc.rootfs = overlayfs:/path/to/master/directory:#{rootfs_path}
|
244
|
+
lxc.tty.max = 4
|
245
|
+
lxc.pty.max = 1024
|
246
|
+
lxc.rootfs.path = overlayfs:/path/to/master/directory:#{rootfs_path}
|
247
247
|
# VAGRANT-BEGIN
|
248
248
|
lxc.network.type=veth
|
249
249
|
lxc.network.name=eth1
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-lxc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabio Rehm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Linux Containers provider for Vagrant
|
14
14
|
email:
|
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
101
|
rubyforge_project:
|
102
|
-
rubygems_version: 2.6
|
102
|
+
rubygems_version: 2.7.6
|
103
103
|
signing_key:
|
104
104
|
specification_version: 4
|
105
105
|
summary: Linux Containers provider for Vagrant
|