vagrant-lxc 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ac8726c09c9ffb849e24a02ddc77e19933177f61
4
- data.tar.gz: 6d46c754650c72a3437723209b37934186c10682
3
+ metadata.gz: d13771d03e03d167212fc77722f3a47c1c5a6b69
4
+ data.tar.gz: 96ba8582b996a0e8edddfd41684925894e1e6534
5
5
  SHA512:
6
- metadata.gz: 4a4c71775855fc653c039cee3c13749751f3954388c8d78309093241867c7dce5a1dc33c61fbdfb61c51e611674c87273e0f2acce0cdc291049edaf0a8feb039
7
- data.tar.gz: 9a33dfee5ec2abe7d0fe6a8f02a24ea0c92526fcf7820c1717b789789ed57754f711d9158b7527f717cc16a7f3d95635049ba46fd0c546e66b6b724c4e8b01a9
6
+ metadata.gz: 932f8882afd3af567c01f696fc4af60c5e6150e1b7c909dc6a8ef48ac6ed3d36407532c0053cfab626620d90c20c14f71bad6995cac5a0e301a490637d4ef827
7
+ data.tar.gz: 6d9ede0184afdd8514bd091a72768562ced78e5c9debab0ca80e1f6eeedeee58dc2150cbd4f54f8d114dc2f101e076f23bb76d19aaa169b64cb377ffb1d328e4
data/CHANGELOG.md CHANGED
@@ -1,4 +1,28 @@
1
- ## [1.1.0](https://github.com/fgrehm/vagrant-lxc/compare/v1.0.1...1.1.0) (Jan 14, 2015)
1
+ ## [1.2.0](https://github.com/fgrehm/vagrant-lxc/compare/v1.1.0...v1.2.0) (Sep 15, 2015)
2
+
3
+ FEATURES:
4
+ - Support private networking using DHCP [[GH-352]]
5
+
6
+ [GH-352]: https://github.com/fgrehm/vagrant-lxc/pull/352
7
+
8
+ IMPROVEMENTS:
9
+
10
+ - Move mountpoint creation to lxc template for lvm rootfs support [[GH-361]] / [[GH-359]]
11
+ - Mount selinux sys dir read-only [[GH-357]] / [[GH-301]]
12
+ - Use correct ruby interpreter when generating sudoers file [[GH-355]]
13
+ - Fix shebangs to be more portable [[GH-376]]
14
+ - Fix removal of lxcbr0/virbr0 when using private networking [[GH-383]]
15
+ - Improve /tmp handling by using tmpfs [[GH-362]]
16
+ [GH-301]: https://github.com/fgrehm/vagrant-lxc/issues/301
17
+ [GH-355]: https://github.com/fgrehm/vagrant-lxc/pull/355
18
+ [GH-357]: https://github.com/fgrehm/vagrant-lxc/pull/357
19
+ [GH-359]: https://github.com/fgrehm/vagrant-lxc/issues/359
20
+ [GH-361]: https://github.com/fgrehm/vagrant-lxc/pull/361
21
+ [GH-376]: https://github.com/fgrehm/vagrant-lxc/pull/376
22
+ [GH-383]: https://github.com/fgrehm/vagrant-lxc/pull/383
23
+ [GH-362]: https://github.com/fgrehm/vagrant-lxc/pull/362
24
+
25
+ ## [1.1.0](https://github.com/fgrehm/vagrant-lxc/compare/v1.0.1...v1.1.0) (Jan 14, 2015)
2
26
 
3
27
  BACKWARDS INCOMPATIBILITIES:
4
28
 
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: 'v1.7.2'
4
+ gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git', tag: 'v1.7.4'
5
5
  gem 'guard'
6
6
  gem 'guard-rspec'
7
7
  gem 'rb-inotify'
data/Gemfile.lock CHANGED
@@ -1,12 +1,12 @@
1
1
  GIT
2
2
  remote: https://github.com/fgrehm/vagrant-cachier.git
3
- revision: 9f6b615e84364b851939a8e7ee8229fc0d276c73
3
+ revision: 40dddfb368526948e769492a00a7937c5a044a4d
4
4
  specs:
5
- vagrant-cachier (1.1.0)
5
+ vagrant-cachier (1.2.1)
6
6
 
7
7
  GIT
8
8
  remote: https://github.com/fgrehm/vagrant-pristine.git
9
- revision: 503dbc47848c81d0fbfa6840491856f518d244a1
9
+ revision: 6d044265db17451c606f000bf43437e95a742bb4
10
10
  specs:
11
11
  vagrant-pristine (0.3.0)
12
12
 
@@ -22,16 +22,16 @@ GIT
22
22
 
23
23
  GIT
24
24
  remote: https://github.com/mitchellh/vagrant.git
25
- revision: 1cd667b243f4a263cd5322b6455165cc676b6f7f
26
- tag: v1.7.2
25
+ revision: 78ea5e4a78ce644717ab16d8001ab77430168f0f
26
+ tag: v1.7.4
27
27
  specs:
28
- vagrant (1.7.2)
29
- bundler (>= 1.5.2, < 1.8.0)
28
+ vagrant (1.7.4)
29
+ bundler (>= 1.5.2, <= 1.10.5)
30
30
  childprocess (~> 0.5.0)
31
31
  erubis (~> 2.7.0)
32
32
  hashicorp-checkpoint (~> 0.1.1)
33
- i18n (~> 0.6.0)
34
- listen (~> 2.8.0)
33
+ i18n (>= 0.6.0, <= 0.8.0)
34
+ listen (~> 3.0.2)
35
35
  log4r (~> 1.1.9, < 1.1.11)
36
36
  net-scp (~> 1.1.0)
37
37
  net-sftp (~> 2.1)
@@ -40,62 +40,55 @@ GIT
40
40
  rb-kqueue (~> 0.2.0)
41
41
  rest-client (>= 1.6.0, < 2.0)
42
42
  wdm (~> 0.1.0)
43
- winrm (~> 1.1.3)
43
+ winrm (~> 1.3)
44
+ winrm-fs (~> 0.2.0)
44
45
 
45
46
  PATH
46
47
  remote: .
47
48
  specs:
48
- vagrant-lxc (1.1.0)
49
+ vagrant-lxc (1.2.0)
49
50
 
50
51
  GEM
51
52
  remote: https://rubygems.org/
52
53
  specs:
53
- akami (1.2.2)
54
- gyoku (>= 0.4.0)
55
- nokogiri
56
54
  builder (3.2.2)
57
- celluloid (0.16.0)
58
- timers (~> 4.0.0)
59
- childprocess (0.5.5)
55
+ childprocess (0.5.6)
60
56
  ffi (~> 1.0, >= 1.0.11)
61
57
  coderay (1.1.0)
62
- coveralls (0.7.1)
58
+ coveralls (0.7.2)
63
59
  multi_json (~> 1.3)
64
- rest-client
60
+ rest-client (= 1.6.7)
65
61
  simplecov (>= 0.7)
66
- term-ansicolor
67
- thor
62
+ term-ansicolor (= 1.2.2)
63
+ thor (= 0.18.1)
68
64
  diff-lcs (1.2.5)
69
65
  docile (1.1.5)
70
66
  erubis (2.7.0)
71
- ffi (1.9.6)
67
+ ffi (1.9.10)
72
68
  formatador (0.2.5)
73
- gssapi (1.0.3)
69
+ gssapi (1.2.0)
74
70
  ffi (>= 1.0.1)
75
- guard (2.11.1)
71
+ guard (2.12.8)
76
72
  formatador (>= 0.2.4)
77
- listen (~> 2.7)
73
+ listen (>= 2.7, <= 4.0)
78
74
  lumberjack (~> 1.0)
79
75
  nenv (~> 0.1)
80
76
  notiffany (~> 0.0)
81
77
  pry (>= 0.9.12)
82
78
  shellany (~> 0.0)
83
79
  thor (>= 0.18.1)
84
- guard-compat (1.2.0)
85
- guard-rspec (4.5.0)
80
+ guard-compat (1.2.1)
81
+ guard-rspec (4.6.2)
86
82
  guard (~> 2.1)
87
83
  guard-compat (~> 1.1)
88
84
  rspec (>= 2.99.0, < 4.0)
89
- gyoku (1.2.2)
85
+ gyoku (1.3.1)
90
86
  builder (>= 2.1.2)
91
87
  hashicorp-checkpoint (0.1.4)
92
- hitimes (1.2.2)
93
88
  httpclient (2.6.0.1)
94
- httpi (0.9.7)
95
- rack
96
- i18n (0.6.11)
97
- listen (2.8.5)
98
- celluloid (>= 0.15.2)
89
+ i18n (0.7.0)
90
+ json (1.8.3)
91
+ listen (3.0.2)
99
92
  rb-fsevent (>= 0.9.3)
100
93
  rb-inotify (>= 0.9)
101
94
  little-plugger (1.1.3)
@@ -105,36 +98,33 @@ GEM
105
98
  multi_json (>= 1.8.4)
106
99
  lumberjack (1.0.9)
107
100
  method_source (0.8.2)
108
- mime-types (2.4.3)
101
+ mime-types (2.6.1)
109
102
  mini_portile (0.6.0)
110
- multi_json (1.10.1)
111
- nenv (0.1.1)
103
+ multi_json (1.11.2)
104
+ nenv (0.2.0)
112
105
  net-scp (1.1.2)
113
106
  net-ssh (>= 2.6.5)
114
107
  net-sftp (2.1.2)
115
108
  net-ssh (>= 2.6.5)
116
- net-ssh (2.9.1)
117
- netrc (0.10.2)
109
+ net-ssh (2.9.2)
118
110
  nokogiri (1.6.3.1)
119
111
  mini_portile (= 0.6.0)
120
- nori (1.1.5)
121
- notiffany (0.0.2)
112
+ nori (2.6.0)
113
+ notiffany (0.0.6)
122
114
  nenv (~> 0.1)
123
115
  shellany (~> 0.0)
124
116
  pry (0.10.1)
125
117
  coderay (~> 1.1.0)
126
118
  method_source (~> 0.8.1)
127
119
  slop (~> 3.4)
128
- rack (1.6.0)
129
120
  rake (10.4.2)
130
- rb-fsevent (0.9.4)
121
+ rb-fsevent (0.9.5)
131
122
  rb-inotify (0.9.5)
132
123
  ffi (>= 0.5.0)
133
- rb-kqueue (0.2.3)
124
+ rb-kqueue (0.2.4)
134
125
  ffi (>= 0.5.0)
135
- rest-client (1.7.2)
136
- mime-types (>= 1.16, < 3.0)
137
- netrc (~> 0.7)
126
+ rest-client (1.6.7)
127
+ mime-types (>= 1.16)
138
128
  rspec (2.99.0)
139
129
  rspec-core (~> 2.99.0)
140
130
  rspec-expectations (~> 2.99.0)
@@ -142,42 +132,37 @@ GEM
142
132
  rspec-core (2.99.2)
143
133
  rspec-expectations (2.99.2)
144
134
  diff-lcs (>= 1.1.3, < 2.0)
145
- rspec-mocks (2.99.2)
146
- rubyntlm (0.1.1)
147
- savon (0.9.5)
148
- akami (~> 1.0)
149
- builder (>= 2.1.2)
150
- gyoku (>= 0.4.0)
151
- httpi (~> 0.9)
152
- nokogiri (>= 1.4.0)
153
- nori (~> 1.0)
154
- wasabi (~> 1.0)
135
+ rspec-mocks (2.99.4)
136
+ rubyntlm (0.4.0)
137
+ rubyzip (1.1.7)
155
138
  shellany (0.0.1)
156
- simplecov (0.9.1)
139
+ simplecov (0.10.0)
157
140
  docile (~> 1.1.0)
158
- multi_json (~> 1.0)
159
- simplecov-html (~> 0.8.0)
160
- simplecov-html (0.8.0)
141
+ json (~> 1.8)
142
+ simplecov-html (~> 0.10.0)
143
+ simplecov-html (0.10.0)
161
144
  slop (3.6.0)
162
- term-ansicolor (1.3.0)
163
- tins (~> 1.0)
145
+ term-ansicolor (1.2.2)
146
+ tins (~> 0.8)
164
147
  thor (0.18.1)
165
- timers (4.0.1)
166
- hitimes
167
- tins (1.3.3)
148
+ tins (0.13.2)
168
149
  uuidtools (2.1.5)
169
150
  vagrant-omnibus (1.4.1)
170
- wasabi (1.0.0)
171
- nokogiri (>= 1.4.0)
172
- wdm (0.1.0)
173
- winrm (1.1.3)
174
- gssapi (~> 1.0.0)
151
+ wdm (0.1.1)
152
+ winrm (1.3.3)
153
+ builder (>= 2.1.2)
154
+ gssapi (~> 1.2)
155
+ gyoku (~> 1.0)
175
156
  httpclient (~> 2.2, >= 2.2.0.2)
176
157
  logging (~> 1.6, >= 1.6.1)
177
- nokogiri (~> 1.5)
178
- rubyntlm (~> 0.1.1)
179
- savon (= 0.9.5)
158
+ nori (~> 2.0)
159
+ rubyntlm (~> 0.4.0)
180
160
  uuidtools (~> 2.1.2)
161
+ winrm-fs (0.2.0)
162
+ erubis (~> 2.7)
163
+ logging (~> 1.6, >= 1.6.1)
164
+ rubyzip (~> 1.1)
165
+ winrm (~> 1.3.0)
181
166
 
182
167
  PLATFORMS
183
168
  ruby
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # vagrant-lxc
2
2
 
3
- [![Build Status](https://travis-ci.org/fgrehm/vagrant-lxc.png?branch=master)](https://travis-ci.org/fgrehm/vagrant-lxc) [![Gem Version](https://badge.fury.io/rb/vagrant-lxc.png)](http://badge.fury.io/rb/vagrant-lxc) [![Code Climate](https://codeclimate.com/github/fgrehm/vagrant-lxc.png)](https://codeclimate.com/github/fgrehm/vagrant-lxc) [![Coverage Status](https://coveralls.io/repos/fgrehm/vagrant-lxc/badge.png?branch=master)](https://coveralls.io/r/fgrehm/vagrant-lxc) [![Gittip](http://img.shields.io/gittip/fgrehm.svg)](https://www.gittip.com/fgrehm/) [![Gitter chat](https://badges.gitter.im/fgrehm/vagrant-lxc.png)](https://gitter.im/fgrehm/vagrant-lxc)
3
+ [![Build Status](https://travis-ci.org/fgrehm/vagrant-lxc.png?branch=master)](https://travis-ci.org/fgrehm/vagrant-lxc) [![Gem Version](https://badge.fury.io/rb/vagrant-lxc.png)](http://badge.fury.io/rb/vagrant-lxc) [![Code Climate](https://codeclimate.com/github/fgrehm/vagrant-lxc.png)](https://codeclimate.com/github/fgrehm/vagrant-lxc) [![Coverage Status](https://coveralls.io/repos/fgrehm/vagrant-lxc/badge.png?branch=master)](https://coveralls.io/r/fgrehm/vagrant-lxc) [![Gitter chat](https://badges.gitter.im/fgrehm/vagrant-lxc.png)](https://gitter.im/fgrehm/vagrant-lxc)
4
4
 
5
5
  [LXC](http://lxc.sourceforge.net/) provider for [Vagrant](http://www.vagrantup.com/) 1.6+
6
6
 
@@ -9,6 +9,9 @@ as an alternative to the built in VirtualBox provider for Linux hosts. Check out
9
9
  [this blog post](http://fabiorehm.com/blog/2013/04/28/lxc-provider-for-vagrant/)
10
10
  to see it in action.
11
11
 
12
+ ## Help Needed!
13
+
14
+ This project is looking for maintainers, please see [GH-375](https://github.com/fgrehm/vagrant-lxc/issues/375) for more.
12
15
 
13
16
  ## Features
14
17
 
@@ -131,7 +134,7 @@ specified from the provider block and it defaults to `best`, to change it:
131
134
  ```ruby
132
135
  Vagrant.configure("2") do |config|
133
136
  config.vm.provider :lxc do |lxc|
134
- lxc.backingstore = 'lvm' # or 'btrfs',...
137
+ lxc.backingstore = 'lvm' # or 'btrfs', 'overlayfs', ...
135
138
  # lvm specific options
136
139
  lxc.backingstore_option '--vgname', 'schroots'
137
140
  lxc.backingstore_option '--fssize', '5G'
@@ -13,7 +13,6 @@ require 'vagrant-lxc/action/handle_box_metadata'
13
13
  require 'vagrant-lxc/action/prepare_nfs_settings'
14
14
  require 'vagrant-lxc/action/prepare_nfs_valid_ids'
15
15
  require 'vagrant-lxc/action/private_networks'
16
- require 'vagrant-lxc/action/remove_temporary_files'
17
16
  require 'vagrant-lxc/action/setup_package_files'
18
17
  require 'vagrant-lxc/action/warn_networks'
19
18
 
@@ -126,7 +125,6 @@ module Vagrant
126
125
  end
127
126
 
128
127
  b2.use ClearForwardedPorts
129
- b2.use RemoveTemporaryFiles
130
128
  b2.use GcPrivateNetworkBridges
131
129
  b2.use Builtin::Call, Builtin::GracefulHalt, :stopped, :running do |env2, b3|
132
130
  if !env2[:result]
@@ -20,6 +20,15 @@ module Vagrant
20
20
  config.customize 'mount.entry', '/sys/fs/pstore sys/fs/pstore none bind,optional 0 0'
21
21
  end
22
22
 
23
+ # Make selinux read-only, see
24
+ # https://github.com/fgrehm/vagrant-lxc/issues/301
25
+ if Dir.exists?('/sys/fs/selinux')
26
+ config.customize 'mount.entry', '/sys/fs/selinux sys/fs/selinux none bind,ro 0 0'
27
+ end
28
+
29
+ # Make /tmp a tmpfs to prevent init scripts from nuking synced folders mounted in here
30
+ config.customize 'mount.entry', 'tmpfs tmp tmpfs nodev,nosuid,size=2G 0 0'
31
+
23
32
  env[:ui].info I18n.t("vagrant_lxc.messages.starting")
24
33
  env[:machine].provider.driver.start(config.customizations)
25
34
 
@@ -67,7 +67,9 @@ module Vagrant
67
67
 
68
68
  # TODO: Deprecate this behavior of "automagically" skipping ssh forwarded ports
69
69
  if type == :forwarded_port && options[:id] != 'ssh'
70
- options.delete(:host_ip) if options.fetch(:host_ip, '').to_s.strip.empty?
70
+ if options.fetch(:host_ip, '').to_s.strip.empty?
71
+ options[:host_ip] = '127.0.0.1'
72
+ end
71
73
  mappings[options[:host]] = options
72
74
  end
73
75
  end
@@ -35,8 +35,9 @@ module Vagrant
35
35
 
36
36
  if ! driver.bridge_is_in_use?(bridge)
37
37
  env[:ui].info I18n.t("vagrant_lxc.messages.remove_bridge", name: bridge)
38
- # TODO: Output that bridge is being removed
39
- driver.remove_bridge(bridge)
38
+ unless ['lxcbr0', 'virbr0'].include? bridge
39
+ driver.remove_bridge(bridge)
40
+ end
40
41
  end
41
42
  end
42
43
  end
@@ -26,16 +26,19 @@ module Vagrant
26
26
  next if type.to_sym != :private_network
27
27
 
28
28
  container_name = env[:machine].provider.driver.container_name
29
+ address_type = config[:type]
29
30
  ip = config[:ip]
30
31
  bridge_ip = config.fetch(:lxc__bridge_ip) { build_bridge_ip(ip) }
31
32
  bridge = config.fetch(:lxc__bridge_name)
32
33
 
33
- env[:machine].provider.driver.configure_private_network(bridge, bridge_ip, container_name, ip)
34
+ env[:machine].provider.driver.configure_private_network(bridge, bridge_ip, container_name, address_type, ip)
34
35
  end
35
36
  end
36
37
 
37
38
  def build_bridge_ip(ip)
38
- ip.sub(/^(\d+\.\d+\.\d+)\.\d+/, '\1.254')
39
+ if ip
40
+ ip.sub(/^(\d+\.\d+\.\d+)\.\d+/, '\1.254')
41
+ end
39
42
  end
40
43
  end
41
44
  end
@@ -83,6 +83,7 @@ module Vagrant
83
83
  hash[cmd] = `which #{cmd}`.strip
84
84
  end
85
85
  hash['lxc_bin'] = Pathname(`which lxc-create`.strip).parent.to_s
86
+ hash['ruby'] = Gem.ruby
86
87
  end
87
88
  end
88
89
  end
@@ -79,34 +79,20 @@ module Vagrant
79
79
  def create(name, backingstore, backingstore_options, template_path, config_file, template_options = {})
80
80
  @cli.name = @container_name = name
81
81
 
82
- import_template(template_path) do |template_name|
83
- @logger.debug "Creating container..."
84
- @cli.create template_name, backingstore, backingstore_options, config_file, template_options
85
- end
82
+ @logger.debug "Creating container..."
83
+ @cli.create template_path, backingstore, backingstore_options, config_file, template_options
86
84
  end
87
85
 
88
86
  def share_folders(folders)
89
87
  folders.each do |f|
90
- share_folder(f[:hostpath], f[:guestpath], f.fetch(:mount_options, 'bind'))
88
+ share_folder(f[:hostpath], f[:guestpath], f.fetch(:mount_options, nil))
91
89
  end
92
90
  end
93
91
 
94
92
  def share_folder(host_path, guest_path, mount_options = nil)
95
- guest_path = guest_path.gsub(/^\//, '')
96
- guest_full_path = rootfs_path.join(guest_path)
97
-
98
- unless guest_full_path.directory?
99
- begin
100
- @logger.debug("Guest path doesn't exist, creating: #{guest_full_path}")
101
- @sudo_wrapper.run('mkdir', '-p', guest_full_path.to_s)
102
- rescue Errno::EACCES
103
- raise Vagrant::Errors::SharedFolderCreateFailed, :path => guest_path.to_s
104
- end
105
- end
106
-
107
- mount_options = Array(mount_options || ['bind'])
93
+ guest_path = guest_path.gsub(/^\//, '').gsub(' ', '\\\040')
94
+ mount_options = Array(mount_options || ['bind', 'create=dir'])
108
95
  host_path = host_path.to_s.gsub(' ', '\\\040')
109
- guest_path = guest_path.gsub(' ', '\\\040')
110
96
  @customizations << ['mount.entry', "#{host_path} #{guest_path} none #{mount_options.join(',')} 0 0"]
111
97
  end
112
98
 
@@ -140,17 +126,30 @@ module Vagrant
140
126
  @cli.attach(*command)
141
127
  end
142
128
 
143
- def configure_private_network(bridge_name, bridge_ip, container_name, ip)
129
+ def configure_private_network(bridge_name, bridge_ip, container_name, address_type, ip)
144
130
  @logger.info "Configuring network interface for #{container_name} using #{ip} and bridge #{bridge_name}"
145
- cmd = [
146
- Vagrant::LXC.source_root.join('scripts/pipework').to_s,
147
- bridge_name,
148
- container_name,
149
- "#{ip}/24"
150
- ]
151
- @sudo_wrapper.run(*cmd)
131
+ if ip
132
+ ip += '/24'
133
+ end
134
+
135
+ if ! bridge_exists?(bridge_name)
136
+ if not bridge_ip
137
+ raise "Bridge is missing and no IP was specified!"
138
+ end
139
+
140
+ @logger.info "Creating the bridge #{bridge_name}"
141
+ cmd = [
142
+ 'brctl',
143
+ 'addbr',
144
+ bridge_name
145
+ ]
146
+ @sudo_wrapper.run(*cmd)
147
+ end
152
148
 
153
149
  if ! bridge_has_an_ip?(bridge_name)
150
+ if not bridge_ip
151
+ raise "Bridge has no IP and none was specified!"
152
+ end
154
153
  @logger.info "Adding #{bridge_ip} to the bridge #{bridge_name}"
155
154
  cmd = [
156
155
  'ip',
@@ -161,7 +160,16 @@ module Vagrant
161
160
  bridge_name
162
161
  ]
163
162
  @sudo_wrapper.run(*cmd)
163
+ @sudo_wrapper.run('ip', 'link', 'set', bridge_name, 'up')
164
164
  end
165
+
166
+ cmd = [
167
+ Vagrant::LXC.source_root.join('scripts/pipework').to_s,
168
+ bridge_name,
169
+ container_name,
170
+ ip ||= "dhcp"
171
+ ]
172
+ @sudo_wrapper.run(*cmd)
165
173
  end
166
174
 
167
175
  def bridge_has_an_ip?(bridge_name)
@@ -169,6 +177,12 @@ module Vagrant
169
177
  `ip -4 addr show scope global #{bridge_name}` =~ /^\s+inet ([0-9.]+)\/[0-9]+\s+/
170
178
  end
171
179
 
180
+ def bridge_exists?(bridge_name)
181
+ @logger.info "Checking whether bridge #{bridge_name} exists"
182
+ brctl_output = `ip link | egrep -q " #{bridge_name}:"`
183
+ $?.to_i == 0
184
+ end
185
+
172
186
  def bridge_is_in_use?(bridge_name)
173
187
  # REFACTOR: This method is **VERY** hacky
174
188
  @logger.info "Checking if bridge #{bridge_name} is in use"
@@ -177,12 +191,15 @@ module Vagrant
177
191
  end
178
192
 
179
193
  def remove_bridge(bridge_name)
180
- @logger.info "Checking whether bridge #{bridge_name} exists"
181
- brctl_output = `ifconfig -a | grep -q #{bridge_name}`
182
- return if $?.to_i != 0
194
+ if ['lxcbr0', 'virbr0'].include? bridge_name
195
+ @logger.info "Skipping removal of system bridge #{bridge_name}"
196
+ return
197
+ end
198
+
199
+ return unless bridge_exists?(bridge_name)
183
200
 
184
201
  @logger.info "Removing bridge #{bridge_name}"
185
- @sudo_wrapper.run('ifconfig', bridge_name, 'down')
202
+ @sudo_wrapper.run('ip', 'link', 'set', bridge_name, 'down')
186
203
  @sudo_wrapper.run('brctl', 'delbr', bridge_name)
187
204
  end
188
205
 
@@ -244,39 +261,6 @@ module Vagrant
244
261
  @sudo_wrapper.run 'chown', 'root:root', base_path.join('config').to_s
245
262
  end
246
263
  end
247
-
248
- def import_template(path)
249
- template_name = "vagrant-tmp-#{@container_name}"
250
- tmp_template_path = templates_path.join("lxc-#{template_name}").to_s
251
-
252
- @logger.info 'Copying LXC template into place'
253
- @sudo_wrapper.run('cp', path, tmp_template_path)
254
- @sudo_wrapper.run('chmod', '+x', tmp_template_path)
255
-
256
- yield template_name
257
- ensure
258
- @logger.info 'Removing LXC template'
259
- if tmp_template_path
260
- @sudo_wrapper.run('rm', tmp_template_path)
261
- end
262
- end
263
-
264
- TEMPLATES_PATH_LOOKUP = %w(
265
- /usr/share/lxc/templates
266
- /usr/lib/lxc/templates
267
- /usr/lib64/lxc/templates
268
- /usr/local/lib/lxc/templates
269
- )
270
- def templates_path
271
- return @templates_path if @templates_path
272
-
273
- path = TEMPLATES_PATH_LOOKUP.find { |candidate| File.directory?(candidate) }
274
- if !path
275
- raise Errors::TemplatesDirMissing.new paths: TEMPLATES_PATH_LOOKUP.inspect
276
- end
277
-
278
- @templates_path = Pathname(path)
279
- end
280
264
  end
281
265
  end
282
266
  end
@@ -36,7 +36,7 @@ module Vagrant
36
36
 
37
37
  def ensure_lxc_installed!
38
38
  begin
39
- sudo_wrapper.run("/usr/bin/which", "lxc-create")
39
+ sudo_wrapper.run("which", "lxc-create")
40
40
  rescue Vagrant::LXC::Errors::ExecuteError
41
41
  raise Errors::LxcNotInstalled
42
42
  end
@@ -14,7 +14,7 @@ module Vagrant
14
14
  def run(*command)
15
15
  options = command.last.is_a?(Hash) ? command.last : {}
16
16
  command.unshift @wrapper_path if @wrapper_path && !options[:no_wrapper]
17
- execute *(['sudo'] + command)
17
+ execute *(['sudo', '/usr/bin/env'] + command)
18
18
  end
19
19
 
20
20
  private
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module LXC
3
- VERSION = "1.1.0"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
data/scripts/lxc-template CHANGED
@@ -1,4 +1,4 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  # This is a modified version of /usr/share/lxc/templates/lxc-download
4
4
  # that comes with ubuntu-lxc 1.0.0 stable from ppa changed to suit vagrant-lxc needs
data/scripts/pipework CHANGED
@@ -1,4 +1,4 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
 
3
3
  # Borrowed from https://github.com/jpetazzo/pipework
4
4
 
@@ -38,21 +38,21 @@ describe Vagrant::LXC::Action::ForwardPorts do
38
38
  )
39
39
  end
40
40
 
41
- it 'skips --laddr parameter if host_ip is nil' do
41
+ it 'Uses 127.0.0.1 as default if host_ip is nil' do
42
42
  forward_conf.delete(:host_ip)
43
43
  subject.stub(system: true)
44
44
  subject.call(env)
45
45
  expect(subject).to have_received(:spawn).with(
46
- "redir --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null"
46
+ "redir --laddr=127.0.0.1 --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null"
47
47
  )
48
48
  end
49
49
 
50
- it 'skips --laddr parameter if host_ip is a blank string' do
50
+ it 'Uses 127.0.0.1 by default if host_ip is a blank string' do
51
51
  forward_conf[:host_ip] = ' '
52
52
  subject.stub(system: true)
53
53
  subject.call(env)
54
54
  expect(subject).to have_received(:spawn).with(
55
- "redir --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null"
55
+ "redir --laddr=127.0.0.1 --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null"
56
56
  )
57
57
  end
58
58
 
@@ -86,21 +86,21 @@ describe Vagrant::LXC::Action::ForwardPorts do
86
86
  )
87
87
  end
88
88
 
89
- it 'skips --laddr parameter if host_ip is nil' do
89
+ it 'Uses 127.0.0.1 by default if host_ip is nil' do
90
90
  forward_conf.delete(:host_ip)
91
91
  subject.stub(system: true)
92
92
  subject.call(env)
93
93
  expect(subject).to have_received(:spawn).with(
94
- "sudo redir --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null"
94
+ "sudo redir --laddr=127.0.0.1 --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null"
95
95
  )
96
96
  end
97
97
 
98
- it 'skips --laddr parameter if host_ip is a blank string' do
98
+ it 'Uses 127.0.0.1 by default if host_ip is a blank string' do
99
99
  forward_conf[:host_ip] = ' '
100
100
  subject.stub(system: true)
101
101
  subject.call(env)
102
102
  expect(subject).to have_received(:spawn).with(
103
- "sudo redir --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null"
103
+ "sudo redir --laddr=127.0.0.1 --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null"
104
104
  )
105
105
  end
106
106
  end
@@ -54,7 +54,7 @@ describe Vagrant::LXC::Driver do
54
54
 
55
55
  it 'creates container with the right arguments' do
56
56
  expect(cli).to have_received(:create).with(
57
- template_name,
57
+ template_path,
58
58
  backingstore,
59
59
  backingstore_opts,
60
60
  config_file,
@@ -97,7 +97,7 @@ describe Vagrant::LXC::Driver do
97
97
  before do
98
98
  sudo.should_receive(:run).with('cat', '/var/lib/lxc/name/config').exactly(2).times.
99
99
  and_return('# CONFIGURATION')
100
- sudo.should_receive(:run).twice.with('cp', '-f', %r{/tmp/.*}, '/var/lib/lxc/name/config')
100
+ sudo.should_receive(:run).twice.with('cp', '-f', %r{/(run|tmp)/.*}, '/var/lib/lxc/name/config')
101
101
  sudo.should_receive(:run).twice.with('chown', 'root:root', '/var/lib/lxc/name/config')
102
102
 
103
103
  subject.customizations << internal_customization
@@ -192,14 +192,10 @@ describe Vagrant::LXC::Driver do
192
192
  subject.share_folders(folders)
193
193
  end
194
194
 
195
- it "creates guest folder under container's rootfs" do
196
- expect(sudo_wrapper).to have_received(:run).with("mkdir", "-p", "#{rootfs_path}/#{expected_guest_path}")
197
- end
198
-
199
195
  it 'adds a mount.entry to its local customizations' do
200
196
  expect(subject.customizations).to include [
201
197
  'mount.entry',
202
- "#{shared_folder[:hostpath]} #{expected_guest_path} none bind 0 0"
198
+ "#{shared_folder[:hostpath]} #{expected_guest_path} none bind,create=dir 0 0"
203
199
  ]
204
200
  end
205
201
 
@@ -213,7 +209,7 @@ describe Vagrant::LXC::Driver do
213
209
  it 'supports directories with spaces' do
214
210
  expect(subject.customizations).to include [
215
211
  'mount.entry',
216
- "/path/with\\040space tmp/with\\040space none bind 0 0"
212
+ "/path/with\\040space tmp/with\\040space none bind,create=dir 0 0"
217
213
  ]
218
214
  end
219
215
  end
@@ -243,7 +239,7 @@ describe Vagrant::LXC::Driver do
243
239
  it 'adds a mount.entry to its local customizations' do
244
240
  expect(subject.customizations).to include [
245
241
  'mount.entry',
246
- "#{shared_folder[:hostpath]} #{expected_guest_path} none bind 0 0"
242
+ "#{shared_folder[:hostpath]} #{expected_guest_path} none bind,create=dir 0 0"
247
243
  ]
248
244
  end
249
245
  end
@@ -273,7 +269,7 @@ describe Vagrant::LXC::Driver do
273
269
  it 'adds a mount.entry to its local customizations' do
274
270
  expect(subject.customizations).to include [
275
271
  'mount.entry',
276
- "#{shared_folder[:hostpath]} #{expected_guest_path} none bind 0 0"
272
+ "#{shared_folder[:hostpath]} #{expected_guest_path} none bind,create=dir 0 0"
277
273
  ]
278
274
  end
279
275
  end
@@ -1,4 +1,4 @@
1
- #!/opt/vagrant/embedded/bin/ruby
1
+ #!<%= cmd_paths['ruby'] %>
2
2
  # Automatically created by vagrant-lxc
3
3
 
4
4
  class Whitelist
@@ -80,7 +80,6 @@ end
80
80
 
81
81
  base = "/var/lib/lxc"
82
82
  base_path = %r{\A#{base}/.*\z}
83
- templates_path = %r{\A/usr/(share|lib|lib64|local/lib)/lxc/templates/.*\z}
84
83
 
85
84
  ##
86
85
  # Commands from provider.rb
@@ -96,18 +95,13 @@ Whitelist.add '<%= cmd_paths['mkdir'] %>', '-p', base_path
96
95
  # - Container config customizations and pruning
97
96
  Whitelist.add '<%= cmd_paths['cp'] %>', '-f', %r{/tmp/.*}, base_path
98
97
  Whitelist.add '<%= cmd_paths['chown'] %>', 'root:root', base_path
99
- # - Template import
100
- Whitelist.add '<%= cmd_paths['cp'] %>', %r{\A.*\z}, templates_path
101
- Whitelist.add '<%= cmd_paths['chmod'] %>', '+x', templates_path
102
- # - Template removal
103
- Whitelist.add '<%= cmd_paths['rm'] %>', templates_path
104
98
  # - Packaging
105
99
  Whitelist.add '<%= cmd_paths['tar'] %>', '--numeric-owner', '-cvzf', %r{/tmp/.*/rootfs.tar.gz}, '-C', base_path, './rootfs'
106
100
  Whitelist.add '<%= cmd_paths['chown'] %>', /\A\d+:\d+\z/, %r{\A/tmp/.*/rootfs\.tar\.gz\z}
107
101
  # - Private network script and commands
108
102
  Whitelist.add '<%= cmd_paths['ip'] %>', 'addr', 'add', /(\d+|\.)+\/24/, 'dev', /.+/
109
- Whitelist.add '<%= cmd_paths['ifconfig'] %>', /.+/, 'down'
110
- Whitelist.add '<%= cmd_paths['brctl'] %>', 'delbr', /.+/
103
+ Whitelist.add '<%= cmd_paths['ip'] %>', 'link', 'set', /.+/, /(up|down)/
104
+ Whitelist.add '<%= cmd_paths['brctl'] %>', /(addbr|delbr)/, /.+/
111
105
  Whitelist.add_regex %r{<%= pipework_regex %>}, '**'
112
106
 
113
107
  ##
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.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabio Rehm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-14 00:00:00.000000000 Z
11
+ date: 2015-09-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Linux Containers provider for Vagrant
14
14
  email:
@@ -47,7 +47,6 @@ files:
47
47
  - lib/vagrant-lxc/action/prepare_nfs_settings.rb
48
48
  - lib/vagrant-lxc/action/prepare_nfs_valid_ids.rb
49
49
  - lib/vagrant-lxc/action/private_networks.rb
50
- - lib/vagrant-lxc/action/remove_temporary_files.rb
51
50
  - lib/vagrant-lxc/action/setup_package_files.rb
52
51
  - lib/vagrant-lxc/action/warn_networks.rb
53
52
  - lib/vagrant-lxc/command/root.rb
@@ -102,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
101
  version: '0'
103
102
  requirements: []
104
103
  rubyforge_project:
105
- rubygems_version: 2.2.2
104
+ rubygems_version: 2.4.1
106
105
  signing_key:
107
106
  specification_version: 4
108
107
  summary: Linux Containers provider for Vagrant
@@ -1,23 +0,0 @@
1
- module Vagrant
2
- module LXC
3
- module Action
4
- class RemoveTemporaryFiles
5
- def initialize(app, env)
6
- @app = app
7
- @logger = Log4r::Logger.new("vagrant::lxc::action::remove_tmp_files")
8
- end
9
-
10
- def call(env)
11
- # Continue execution, we need the container to be stopped
12
- @app.call env
13
-
14
- if env[:machine].state.id == :stopped
15
- @logger.debug 'Removing temporary files'
16
- tmp_path = env[:machine].provider.driver.rootfs_path.join('tmp')
17
- env[:machine].provider.sudo_wrapper.run('rm', '-rf', "#{tmp_path}/*")
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end