diff --git a/Gemfile b/Gemfile index b0d8fc3..92fea22 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' group :development do - gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git', tag: 'v1.7.2' + gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git', tag: 'v1.7.4' gem 'guard' gem 'guard-rspec' gem 'rb-inotify' diff --git a/Gemfile.lock b/Gemfile.lock index 9b8e147..68d2007 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,12 @@ GIT remote: https://github.com/fgrehm/vagrant-cachier.git - revision: 9f6b615e84364b851939a8e7ee8229fc0d276c73 + revision: 40dddfb368526948e769492a00a7937c5a044a4d specs: - vagrant-cachier (1.1.0) + vagrant-cachier (1.2.1) GIT remote: https://github.com/fgrehm/vagrant-pristine.git - revision: 503dbc47848c81d0fbfa6840491856f518d244a1 + revision: 6d044265db17451c606f000bf43437e95a742bb4 specs: vagrant-pristine (0.3.0) @@ -22,16 +22,16 @@ GIT GIT remote: https://github.com/mitchellh/vagrant.git - revision: 1cd667b243f4a263cd5322b6455165cc676b6f7f - tag: v1.7.2 + revision: 78ea5e4a78ce644717ab16d8001ab77430168f0f + tag: v1.7.4 specs: - vagrant (1.7.2) - bundler (>= 1.5.2, < 1.8.0) + vagrant (1.7.4) + bundler (>= 1.5.2, <= 1.10.5) childprocess (~> 0.5.0) erubis (~> 2.7.0) hashicorp-checkpoint (~> 0.1.1) - i18n (~> 0.6.0) - listen (~> 2.8.0) + i18n (>= 0.6.0, <= 0.8.0) + listen (~> 3.0.2) log4r (~> 1.1.9, < 1.1.11) net-scp (~> 1.1.0) net-sftp (~> 2.1) @@ -40,7 +40,8 @@ GIT rb-kqueue (~> 0.2.0) rest-client (>= 1.6.0, < 2.0) wdm (~> 0.1.0) - winrm (~> 1.1.3) + winrm (~> 1.3) + winrm-fs (~> 0.2.0) PATH remote: . @@ -50,52 +51,44 @@ PATH GEM remote: https://rubygems.org/ specs: - akami (1.2.2) - gyoku (>= 0.4.0) - nokogiri builder (3.2.2) - celluloid (0.16.0) - timers (~> 4.0.0) - childprocess (0.5.5) + childprocess (0.5.6) ffi (~> 1.0, >= 1.0.11) coderay (1.1.0) - coveralls (0.7.1) + coveralls (0.7.2) multi_json (~> 1.3) - rest-client + rest-client (= 1.6.7) simplecov (>= 0.7) - term-ansicolor - thor + term-ansicolor (= 1.2.2) + thor (= 0.18.1) diff-lcs (1.2.5) docile (1.1.5) erubis (2.7.0) - ffi (1.9.6) + ffi (1.9.10) formatador (0.2.5) - gssapi (1.0.3) + gssapi (1.2.0) ffi (>= 1.0.1) - guard (2.11.1) + guard (2.12.8) formatador (>= 0.2.4) - listen (~> 2.7) + listen (>= 2.7, <= 4.0) lumberjack (~> 1.0) nenv (~> 0.1) notiffany (~> 0.0) pry (>= 0.9.12) shellany (~> 0.0) thor (>= 0.18.1) - guard-compat (1.2.0) - guard-rspec (4.5.0) + guard-compat (1.2.1) + guard-rspec (4.6.2) guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) - gyoku (1.2.2) + gyoku (1.3.1) builder (>= 2.1.2) hashicorp-checkpoint (0.1.4) - hitimes (1.2.2) httpclient (2.6.0.1) - httpi (0.9.7) - rack - i18n (0.6.11) - listen (2.8.5) - celluloid (>= 0.15.2) + i18n (0.7.0) + json (1.8.3) + listen (3.0.2) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) little-plugger (1.1.3) @@ -105,36 +98,33 @@ GEM multi_json (>= 1.8.4) lumberjack (1.0.9) method_source (0.8.2) - mime-types (2.4.3) + mime-types (2.6.1) mini_portile (0.6.0) - multi_json (1.10.1) - nenv (0.1.1) + multi_json (1.11.2) + nenv (0.2.0) net-scp (1.1.2) net-ssh (>= 2.6.5) net-sftp (2.1.2) net-ssh (>= 2.6.5) - net-ssh (2.9.1) - netrc (0.10.2) + net-ssh (2.9.2) nokogiri (1.6.3.1) mini_portile (= 0.6.0) - nori (1.1.5) - notiffany (0.0.2) + nori (2.6.0) + notiffany (0.0.6) nenv (~> 0.1) shellany (~> 0.0) pry (0.10.1) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - rack (1.6.0) rake (10.4.2) - rb-fsevent (0.9.4) + rb-fsevent (0.9.5) rb-inotify (0.9.5) ffi (>= 0.5.0) - rb-kqueue (0.2.3) + rb-kqueue (0.2.4) ffi (>= 0.5.0) - rest-client (1.7.2) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) + rest-client (1.6.7) + mime-types (>= 1.16) rspec (2.99.0) rspec-core (~> 2.99.0) rspec-expectations (~> 2.99.0) @@ -142,42 +132,37 @@ GEM rspec-core (2.99.2) rspec-expectations (2.99.2) diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.99.2) - rubyntlm (0.1.1) - savon (0.9.5) - akami (~> 1.0) - builder (>= 2.1.2) - gyoku (>= 0.4.0) - httpi (~> 0.9) - nokogiri (>= 1.4.0) - nori (~> 1.0) - wasabi (~> 1.0) + rspec-mocks (2.99.4) + rubyntlm (0.4.0) + rubyzip (1.1.7) shellany (0.0.1) - simplecov (0.9.1) + simplecov (0.10.0) docile (~> 1.1.0) - multi_json (~> 1.0) - simplecov-html (~> 0.8.0) - simplecov-html (0.8.0) + json (~> 1.8) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.0) slop (3.6.0) - term-ansicolor (1.3.0) - tins (~> 1.0) + term-ansicolor (1.2.2) + tins (~> 0.8) thor (0.18.1) - timers (4.0.1) - hitimes - tins (1.3.3) + tins (0.13.2) uuidtools (2.1.5) vagrant-omnibus (1.4.1) - wasabi (1.0.0) - nokogiri (>= 1.4.0) - wdm (0.1.0) - winrm (1.1.3) - gssapi (~> 1.0.0) + wdm (0.1.1) + winrm (1.3.3) + builder (>= 2.1.2) + gssapi (~> 1.2) + gyoku (~> 1.0) httpclient (~> 2.2, >= 2.2.0.2) logging (~> 1.6, >= 1.6.1) - nokogiri (~> 1.5) - rubyntlm (~> 0.1.1) - savon (= 0.9.5) + nori (~> 2.0) + rubyntlm (~> 0.4.0) uuidtools (~> 2.1.2) + winrm-fs (0.2.0) + erubis (~> 2.7) + logging (~> 1.6, >= 1.6.1) + rubyzip (~> 1.1) + winrm (~> 1.3.0) PLATFORMS ruby diff --git a/lib/vagrant-lxc/driver.rb b/lib/vagrant-lxc/driver.rb index 9fe0993..a7d960f 100644 --- a/lib/vagrant-lxc/driver.rb +++ b/lib/vagrant-lxc/driver.rb @@ -79,10 +79,8 @@ module Vagrant def create(name, backingstore, backingstore_options, template_path, config_file, template_options = {}) @cli.name = @container_name = name - import_template(template_path) do |template_name| - @logger.debug "Creating container..." - @cli.create template_name, backingstore, backingstore_options, config_file, template_options - end + @logger.debug "Creating container..." + @cli.create template_path, backingstore, backingstore_options, config_file, template_options end def share_folders(folders) @@ -92,7 +90,7 @@ module Vagrant end def share_folder(host_path, guest_path, mount_options = nil) - guest_path = guest_path.gsub(/^\//, '').gsub(' ', '\\\040') + guest_path = guest_path.gsub(/^\//, '').gsub(' ', '\\\040') mount_options = Array(mount_options || ['bind', 'create=dir']) host_path = host_path.to_s.gsub(' ', '\\\040') @customizations << ['mount.entry', "#{host_path} #{guest_path} none #{mount_options.join(',')} 0 0"] @@ -239,39 +237,6 @@ module Vagrant @sudo_wrapper.run 'chown', 'root:root', base_path.join('config').to_s end end - - def import_template(path) - template_name = "vagrant-tmp-#{@container_name}" - tmp_template_path = templates_path.join("lxc-#{template_name}").to_s - - @logger.info 'Copying LXC template into place' - @sudo_wrapper.run('cp', path, tmp_template_path) - @sudo_wrapper.run('chmod', '+x', tmp_template_path) - - yield template_name - ensure - @logger.info 'Removing LXC template' - if tmp_template_path - @sudo_wrapper.run('rm', tmp_template_path) - end - end - - TEMPLATES_PATH_LOOKUP = %w( - /usr/share/lxc/templates - /usr/lib/lxc/templates - /usr/lib64/lxc/templates - /usr/local/lib/lxc/templates - ) - def templates_path - return @templates_path if @templates_path - - path = TEMPLATES_PATH_LOOKUP.find { |candidate| File.directory?(candidate) } - if !path - raise Errors::TemplatesDirMissing.new paths: TEMPLATES_PATH_LOOKUP.inspect - end - - @templates_path = Pathname(path) - end end end end diff --git a/lib/vagrant-lxc/provider.rb b/lib/vagrant-lxc/provider.rb index ab56279..dead6ab 100644 --- a/lib/vagrant-lxc/provider.rb +++ b/lib/vagrant-lxc/provider.rb @@ -36,7 +36,7 @@ module Vagrant def ensure_lxc_installed! begin - sudo_wrapper.run("/usr/bin/which", "lxc-create") + sudo_wrapper.run("which", "lxc-create") rescue Vagrant::LXC::Errors::ExecuteError raise Errors::LxcNotInstalled end diff --git a/lib/vagrant-lxc/sudo_wrapper.rb b/lib/vagrant-lxc/sudo_wrapper.rb index 406c0f0..f344d9f 100644 --- a/lib/vagrant-lxc/sudo_wrapper.rb +++ b/lib/vagrant-lxc/sudo_wrapper.rb @@ -14,7 +14,7 @@ module Vagrant def run(*command) options = command.last.is_a?(Hash) ? command.last : {} command.unshift @wrapper_path if @wrapper_path && !options[:no_wrapper] - execute *(['sudo'] + command) + execute *(['sudo', '/usr/bin/env'] + command) end private diff --git a/scripts/lxc-template b/scripts/lxc-template index 8036bba..50baf96 100755 --- a/scripts/lxc-template +++ b/scripts/lxc-template @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # This is a modified version of /usr/share/lxc/templates/lxc-download # that comes with ubuntu-lxc 1.0.0 stable from ppa changed to suit vagrant-lxc needs diff --git a/spec/unit/driver_spec.rb b/spec/unit/driver_spec.rb index 0aed4b5..9851acd 100644 --- a/spec/unit/driver_spec.rb +++ b/spec/unit/driver_spec.rb @@ -54,7 +54,7 @@ describe Vagrant::LXC::Driver do it 'creates container with the right arguments' do expect(cli).to have_received(:create).with( - template_name, + template_path, backingstore, backingstore_opts, config_file, @@ -97,7 +97,7 @@ describe Vagrant::LXC::Driver do before do sudo.should_receive(:run).with('cat', '/var/lib/lxc/name/config').exactly(2).times. and_return('# CONFIGURATION') - sudo.should_receive(:run).twice.with('cp', '-f', %r{/tmp/.*}, '/var/lib/lxc/name/config') + sudo.should_receive(:run).twice.with('cp', '-f', %r{/(run|tmp)/.*}, '/var/lib/lxc/name/config') sudo.should_receive(:run).twice.with('chown', 'root:root', '/var/lib/lxc/name/config') subject.customizations << internal_customization diff --git a/templates/sudoers.rb.erb b/templates/sudoers.rb.erb index e9e6fd5..fd4d40c 100644 --- a/templates/sudoers.rb.erb +++ b/templates/sudoers.rb.erb @@ -80,7 +80,6 @@ end base = "/var/lib/lxc" base_path = %r{\A#{base}/.*\z} -templates_path = %r{\A/usr/(share|lib|lib64|local/lib)/lxc/templates/.*\z} ## # Commands from provider.rb @@ -96,11 +95,6 @@ Whitelist.add '<%= cmd_paths['mkdir'] %>', '-p', base_path # - Container config customizations and pruning Whitelist.add '<%= cmd_paths['cp'] %>', '-f', %r{/tmp/.*}, base_path Whitelist.add '<%= cmd_paths['chown'] %>', 'root:root', base_path -# - Template import -Whitelist.add '<%= cmd_paths['cp'] %>', %r{\A.*\z}, templates_path -Whitelist.add '<%= cmd_paths['chmod'] %>', '+x', templates_path -# - Template removal -Whitelist.add '<%= cmd_paths['rm'] %>', templates_path # - Packaging Whitelist.add '<%= cmd_paths['tar'] %>', '--numeric-owner', '-cvzf', %r{/tmp/.*/rootfs.tar.gz}, '-C', base_path, './rootfs' Whitelist.add '<%= cmd_paths['chown'] %>', /\A\d+:\d+\z/, %r{\A/tmp/.*/rootfs\.tar\.gz\z}