vagrant-lxc 0.5.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53e892dfb1ea3897de7672db8cee129a7f5b65c8
4
- data.tar.gz: 9a2767f8b694f2c3a9bbb94674c9cef9c5eec8bc
3
+ metadata.gz: 0fd5ca05e6456d793879dd160fe0746fba08541a
4
+ data.tar.gz: 25437c338c3a8a41122e8ff35bdba2bdf9ca5dac
5
5
  SHA512:
6
- metadata.gz: ca4237b0ce604a2e66e0c53252d5d5b6491e764dee60ff76e224eb0669a6171b3321422ebcf84ad6ef4c99f756d807d9987a52e28f3050c5f5f9bbc85aa5dcc0
7
- data.tar.gz: 1db202a14678a2a86cab86d4c0cc607d676b30d29b0a125193dc610f7452f19cd0dc0b43c0b0b5111d3cc43c5d6bf1a031e14b8b6d34d4c75be251b138ea5677
6
+ metadata.gz: 16ea43d6b1f598fc62ae3930a2f81ca2f917689144cc313973ae171c695e65daa6aba15e15980fae891c1c7b0867ce8878a84bda4b3c0503a498bbbcd4060980
7
+ data.tar.gz: 5ab9575aefa1ddefdcb988232d988c095238a613799c5f3353d2721c5bf53fac0219f413cd96804166f34d9462a6931889e7dfcb060d74e8f2f763e99357d7b2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [0.6.0](https://github.com/fgrehm/vagrant-lxc/compare/v0.5.0...v0.6.0) (Sep 12, 2013)
2
+
3
+ IMPROVEMENTS:
4
+
5
+ - Compatibility with Vagrant 1.3+ [#136](https://github.com/fgrehm/vagrant-lxc/pull/136)
6
+ - Set plugin name to `vagrant-lxc` so that it is easier to check if the plugin is
7
+ installed with the newly added `Vagrant.has_plugin?`
8
+
9
+ BUG FIXES:
10
+
11
+ - Fix box package ownership on `vagrant package` [#140](https://github.com/fgrehm/vagrant-lxc/pull/140)
12
+ - Fix error while compressing container's rootfs under Debian hosts [#131](https://github.com/fgrehm/vagrant-lxc/issues/131) /
13
+ [#133](https://github.com/fgrehm/vagrant-lxc/issues/133)
14
+
1
15
  ## [0.5.0](https://github.com/fgrehm/vagrant-lxc/compare/v0.4.0...v0.5.0) (Aug 1, 2013)
2
16
 
3
17
  BACKWARDS INCOMPATIBILITIES:
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  GIT
2
2
  remote: git://github.com/fgrehm/vagrant-cachier.git
3
- revision: f5d9ce507239535326a0a0395c890cc7a27d73f1
3
+ revision: 11defb0b290a34d069f3ec014fb30d4461aab04b
4
4
  specs:
5
- vagrant-cachier (0.3.0.dev)
5
+ vagrant-cachier (0.3.3)
6
6
 
7
7
  GIT
8
8
  remote: git://github.com/fgrehm/vagrant-pristine.git
@@ -12,9 +12,9 @@ GIT
12
12
 
13
13
  GIT
14
14
  remote: git://github.com/mitchellh/vagrant.git
15
- revision: 2282a88f3dfde65b881758b4643480cba4468c4a
15
+ revision: 7b440339f3d801e60e2451823dec04aae772d86a
16
16
  specs:
17
- vagrant (1.2.7.dev)
17
+ vagrant (1.3.2.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.5.0)
28
+ vagrant-lxc (0.6.0)
29
29
 
30
30
  GEM
31
31
  remote: https://rubygems.org/
@@ -44,25 +44,25 @@ GEM
44
44
  erubis (2.7.0)
45
45
  ffi (1.9.0)
46
46
  formatador (0.2.4)
47
- guard (1.8.1)
47
+ guard (1.8.2)
48
48
  formatador (>= 0.2.4)
49
49
  listen (>= 1.0.0)
50
50
  lumberjack (>= 1.0.2)
51
51
  pry (>= 0.9.10)
52
52
  thor (>= 0.14.6)
53
- guard-rspec (3.0.2)
53
+ guard-rspec (3.0.3)
54
54
  guard (>= 1.8)
55
55
  rspec (~> 2.13)
56
- i18n (0.6.4)
57
- listen (1.2.2)
56
+ i18n (0.6.5)
57
+ listen (1.3.1)
58
58
  rb-fsevent (>= 0.9.3)
59
59
  rb-inotify (>= 0.9)
60
60
  rb-kqueue (>= 0.2)
61
61
  log4r (1.1.10)
62
62
  lumberjack (1.0.4)
63
63
  method_source (0.8.2)
64
- mime-types (1.23)
65
- multi_json (1.7.7)
64
+ mime-types (1.25)
65
+ multi_json (1.8.0)
66
66
  net-scp (1.1.2)
67
67
  net-ssh (>= 2.6.5)
68
68
  net-ssh (2.6.8)
@@ -72,7 +72,7 @@ GEM
72
72
  slop (~> 3.4)
73
73
  rake (10.1.0)
74
74
  rb-fsevent (0.9.3)
75
- rb-inotify (0.9.0)
75
+ rb-inotify (0.9.1)
76
76
  ffi (>= 0.5.0)
77
77
  rb-kqueue (0.2.0)
78
78
  ffi (>= 0.5.0)
@@ -96,7 +96,7 @@ GEM
96
96
  simplecov-html (0.7.1)
97
97
  slop (3.4.6)
98
98
  thor (0.18.1)
99
- vagrant-omnibus (1.1.0)
99
+ vagrant-omnibus (1.1.1)
100
100
 
101
101
  PLATFORMS
102
102
  ruby
data/README.md CHANGED
@@ -28,8 +28,9 @@ and the [changelog](CHANGELOG.md) for most up to date information.*
28
28
  * A [bug-free](https://github.com/fgrehm/vagrant-lxc/wiki/Troubleshooting#im-unable-to-restart-containers) kernel
29
29
 
30
30
  The plugin is known to work better and pretty much out of the box on Ubuntu 12.04+
31
- hosts and installing the dependencies on it basically means a `apt-get install lxc redir`
32
- and a `apt-get update && apt-get dist-upgrade` to upgrade the kernel.
31
+ hosts and installing the dependencies on it basically means a `apt-get install lxc lxc-templates cgroup-lite redir`
32
+ and a `apt-get update && apt-get dist-upgrade` to upgrade the kernel. For Debian
33
+ hosts you'll need to follow the instructions described on the [Wiki](https://github.com/fgrehm/vagrant-lxc/wiki/Usage-on-debian-hosts).
33
34
 
34
35
  Some manual steps are required to set up a Linode machine prior to using this
35
36
  plugin, please check https://github.com/fgrehm/vagrant-lxc/wiki/Usage-on-Linode
@@ -53,7 +54,7 @@ vagrant plugin install vagrant-lxc
53
54
  After installing, add a [base box](#base-boxes) using any name you want, for example:
54
55
 
55
56
  ```
56
- vagrant box add quantal64 http://dl.dropbox.com/u/13510779/lxc-quantal-amd64-2013-07-12.box
57
+ vagrant box add quantal64 http://bit.ly/vagrant-lxc-quantal64-2013-07-12
57
58
  ```
58
59
 
59
60
  Then create a Vagrantfile that looks like the following, changing the box name
@@ -97,41 +98,9 @@ For other configuration options, please check the [lxc.conf manpages](http://man
97
98
  ### Avoiding `sudo` passwords
98
99
 
99
100
  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`.
134
-
101
+ are not supported on mainstream kernels. Have a look at the [Wiki](https://github.com/fgrehm/vagrant-lxc/wiki/Avoiding-'sudo'-passwords)
102
+ to find out how to work around that specially if you are running an OS with sudo
103
+ < 1.8.4 (like Ubuntu 12.04) as you might be affected by a bug.
135
104
 
136
105
  ### Base boxes
137
106
 
@@ -19,6 +19,11 @@ require 'vagrant-lxc/action/remove_temporary_files'
19
19
  require 'vagrant-lxc/action/setup_package_files'
20
20
  require 'vagrant-lxc/action/share_folders'
21
21
 
22
+ unless Vagrant::LXC.vagrant_1_3_or_later
23
+ require 'vagrant-lxc/action/wait_for_communicator'
24
+ Vagrant::Action::Builtin.const_set :WaitForCommunicator, Vagrant::LXC::Action::WaitForCommunicator
25
+ end
26
+
22
27
  module Vagrant
23
28
  module LXC
24
29
  module Action
@@ -40,7 +45,6 @@ module Vagrant
40
45
  end
41
46
  end
42
47
 
43
-
44
48
  # This action boots the VM, assuming the VM is in a state that requires
45
49
  # a bootup (i.e. not saved).
46
50
  def self.action_boot
@@ -52,6 +56,7 @@ module Vagrant
52
56
  b.use Vagrant::Action::Builtin::SetHostname
53
57
  b.use ForwardPorts
54
58
  b.use Boot
59
+ b.use Vagrant::Action::Builtin::WaitForCommunicator, [:starting, :running]
55
60
  end
56
61
  end
57
62
 
@@ -146,6 +151,9 @@ module Vagrant
146
151
  b3.use Vagrant::Action::Builtin::EnvSet, :force_halt => true
147
152
  b3.use action_halt
148
153
  b3.use Destroy
154
+ if Vagrant::LXC.vagrant_1_3_or_later
155
+ b3.use Vagrant::Action::Builtin::ProvisionerCleanup
156
+ end
149
157
  else
150
158
  b3.use Message, :will_not_destroy
151
159
  end
@@ -15,41 +15,9 @@ module Vagrant
15
15
 
16
16
  env[:ui].info I18n.t("vagrant_lxc.messages.starting")
17
17
  env[:machine].provider.driver.start(config.customizations)
18
- raise Vagrant::Errors::VMFailedToBoot if !wait_for_boot
19
18
 
20
19
  @app.call env
21
20
  end
22
-
23
- # Stolen from on VagrantPlugins::ProviderVirtualBox::Action::Boot
24
- def wait_for_boot
25
- @env[:ui].info I18n.t("vagrant_lxc.messages.waiting_for_start")
26
-
27
- @env[:machine].config.ssh.max_tries.to_i.times do |i|
28
- if @env[:machine].communicate.ready?
29
- @env[:ui].info I18n.t("vagrant_lxc.messages.container_ready")
30
- return true
31
- end
32
-
33
- # Return true so that the vm_failed_to_boot error doesn't
34
- # get shown
35
- return true if @env[:interrupted]
36
-
37
- # TODO: Find out if there is a command to check if the machine is
38
- # starting, `lxc-monitor` shows this information, but I've
39
- # never seen it on `lxc-info` which is what it is being used
40
- # to determine container status
41
-
42
- # If the VM is not starting or running, something went wrong
43
- # and we need to show a useful error.
44
- state = @env[:machine].provider.state.id
45
- raise Vagrant::Errors::VMFailedToRun if state != :starting && state != :running
46
-
47
- sleep 2 if !@env["vagrant.test"]
48
- end
49
-
50
- @env[:ui].error I18n.t("vagrant.actions.vm.boot.failed")
51
- false
52
- end
53
21
  end
54
22
  end
55
23
  end
@@ -0,0 +1,46 @@
1
+ # This acts like a backport of Vagrant's built in action from 1.3+ for older versions
2
+ # https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/action/builtin/wait_for_communicator.rb
3
+ module Vagrant
4
+ module LXC
5
+ module Action
6
+ class WaitForCommunicator
7
+ def initialize(app, env, states = [])
8
+ @app = app
9
+ @states = states
10
+ end
11
+
12
+ def call(env)
13
+ @env = env
14
+ raise Vagrant::Errors::VMFailedToBoot if !wait_for_boot
15
+ @app.call env
16
+ end
17
+
18
+ # Stolen from the an old version of VagrantPlugins::ProviderVirtualBox::Action::Boot
19
+ def wait_for_boot
20
+ @env[:ui].info I18n.t("vagrant_lxc.messages.waiting_for_start")
21
+
22
+ @env[:machine].config.ssh.max_tries.to_i.times do |i|
23
+ if @env[:machine].communicate.ready?
24
+ @env[:ui].info I18n.t("vagrant_lxc.messages.container_ready")
25
+ return true
26
+ end
27
+
28
+ # Return true so that the vm_failed_to_boot error doesn't
29
+ # get shown
30
+ return true if @env[:interrupted]
31
+
32
+ # If the VM is not starting or running, something went wrong
33
+ # and we need to show a useful error.
34
+ state = @env[:machine].provider.state.id
35
+ raise Vagrant::Errors::VMFailedToRun unless @states.include?(state)
36
+
37
+ sleep 2 if !@env["vagrant.test"]
38
+ end
39
+
40
+ @env[:ui].error I18n.t("vagrant.actions.vm.boot.failed")
41
+ false
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -4,6 +4,8 @@ require "vagrant/util/subprocess"
4
4
  require "vagrant-lxc/errors"
5
5
  require "vagrant-lxc/driver/cli"
6
6
 
7
+ require "etc"
8
+
7
9
  module Vagrant
8
10
  module LXC
9
11
  class Driver
@@ -76,7 +78,7 @@ module Vagrant
76
78
  prune_customizations
77
79
  write_customizations(customizations + @customizations)
78
80
 
79
- @cli.transition_to(:running) { |c| c.start(extra) }
81
+ @cli.start(extra)
80
82
  end
81
83
 
82
84
  def forced_halt
@@ -100,18 +102,19 @@ module Vagrant
100
102
 
101
103
  # TODO: This needs to be reviewed and specs needs to be written
102
104
  def compress_rootfs
103
- rootfs_dirname = File.dirname rootfs_path
104
- basename = rootfs_path.to_s.gsub(/^#{Regexp.escape rootfs_dirname}\//, '')
105
105
  # TODO: Pass in tmpdir so we can clean up from outside
106
106
  target_path = "#{Dir.mktmpdir}/rootfs.tar.gz"
107
107
 
108
108
  Dir.chdir base_path do
109
109
  @logger.info "Compressing '#{rootfs_path}' rootfs to #{target_path}"
110
110
  @sudo_wrapper.run('rm', '-f', 'rootfs.tar.gz')
111
- @sudo_wrapper.run('tar', '--numeric-owner', '-czf', target_path, "#{basename}/*")
111
+ @sudo_wrapper.run('tar', '--numeric-owner', '-czf', target_path, 'rootfs')
112
+
113
+ @logger.info "Changing rootfs tarball owner"
114
+
115
+ user_details=Etc.getpwnam(Etc.getlogin)
112
116
 
113
- @logger.info "Changing rootfs tarbal owner"
114
- @sudo_wrapper.run('chown', "#{ENV['USER']}:#{ENV['USER']}", target_path)
117
+ @sudo_wrapper.run('chown', "#{user_details.uid}:#{user_details.gid}", target_path)
115
118
  end
116
119
 
117
120
  target_path
@@ -3,7 +3,7 @@ require "vagrant"
3
3
  module Vagrant
4
4
  module LXC
5
5
  class Plugin < Vagrant.plugin("2")
6
- name "Linux Containers (LXC) provider"
6
+ name "vagrant-lxc"
7
7
  description <<-EOF
8
8
  The LXC provider allows Vagrant to manage and control
9
9
  LXC-based virtual machines.
@@ -23,5 +23,9 @@ module Vagrant
23
23
  Config
24
24
  end
25
25
  end
26
+
27
+ def self.vagrant_1_3_or_later
28
+ Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new('1.3.0')
29
+ end
26
30
  end
27
31
  end
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module LXC
3
- VERSION = "0.5.0"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
@@ -80,7 +80,6 @@ describe Vagrant::LXC::Driver do
80
80
  subject { described_class.new('name', sudo, cli) }
81
81
 
82
82
  before do
83
- cli.stub(:transition_to).and_yield(cli)
84
83
  subject.customizations << internal_customization
85
84
  subject.start(customizations)
86
85
  end
@@ -92,10 +91,6 @@ describe Vagrant::LXC::Driver do
92
91
  it 'starts container with configured customizations' do
93
92
  cli.should have_received(:start)
94
93
  end
95
-
96
- it 'expects a transition to running state to take place' do
97
- cli.should have_received(:transition_to).with(:running)
98
- end
99
94
  end
100
95
 
101
96
  describe 'halt' do
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: 0.5.0
4
+ version: 0.6.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: 2013-08-01 00:00:00.000000000 Z
11
+ date: 2013-09-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Linux Containers provider for Vagrant
14
14
  email:
@@ -78,6 +78,7 @@ files:
78
78
  - lib/vagrant-lxc/action/remove_temporary_files.rb
79
79
  - lib/vagrant-lxc/action/setup_package_files.rb
80
80
  - lib/vagrant-lxc/action/share_folders.rb
81
+ - lib/vagrant-lxc/action/wait_for_communicator.rb
81
82
  - lib/vagrant-lxc/config.rb
82
83
  - lib/vagrant-lxc/driver.rb
83
84
  - lib/vagrant-lxc/driver/cli.rb
@@ -129,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
130
  version: '0'
130
131
  requirements: []
131
132
  rubyforge_project:
132
- rubygems_version: 2.0.0
133
+ rubygems_version: 2.0.7
133
134
  signing_key:
134
135
  specification_version: 4
135
136
  summary: Linux Containers provider for Vagrant