Merge pull request #376 from globin/nixos-current

NixOS compatibility
This commit is contained in:
Franz Pletz 2015-08-25 14:53:03 +02:00
commit bbff802b5d
8 changed files with 67 additions and 123 deletions

View file

@ -1,7 +1,7 @@
source 'https://rubygems.org' source 'https://rubygems.org'
group :development do 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'
gem 'guard-rspec' gem 'guard-rspec'
gem 'rb-inotify' gem 'rb-inotify'

View file

@ -1,12 +1,12 @@
GIT GIT
remote: https://github.com/fgrehm/vagrant-cachier.git remote: https://github.com/fgrehm/vagrant-cachier.git
revision: 9f6b615e84364b851939a8e7ee8229fc0d276c73 revision: 40dddfb368526948e769492a00a7937c5a044a4d
specs: specs:
vagrant-cachier (1.1.0) vagrant-cachier (1.2.1)
GIT GIT
remote: https://github.com/fgrehm/vagrant-pristine.git remote: https://github.com/fgrehm/vagrant-pristine.git
revision: 503dbc47848c81d0fbfa6840491856f518d244a1 revision: 6d044265db17451c606f000bf43437e95a742bb4
specs: specs:
vagrant-pristine (0.3.0) vagrant-pristine (0.3.0)
@ -22,16 +22,16 @@ GIT
GIT GIT
remote: https://github.com/mitchellh/vagrant.git remote: https://github.com/mitchellh/vagrant.git
revision: 1cd667b243f4a263cd5322b6455165cc676b6f7f revision: 78ea5e4a78ce644717ab16d8001ab77430168f0f
tag: v1.7.2 tag: v1.7.4
specs: specs:
vagrant (1.7.2) vagrant (1.7.4)
bundler (>= 1.5.2, < 1.8.0) bundler (>= 1.5.2, <= 1.10.5)
childprocess (~> 0.5.0) childprocess (~> 0.5.0)
erubis (~> 2.7.0) erubis (~> 2.7.0)
hashicorp-checkpoint (~> 0.1.1) hashicorp-checkpoint (~> 0.1.1)
i18n (~> 0.6.0) i18n (>= 0.6.0, <= 0.8.0)
listen (~> 2.8.0) listen (~> 3.0.2)
log4r (~> 1.1.9, < 1.1.11) log4r (~> 1.1.9, < 1.1.11)
net-scp (~> 1.1.0) net-scp (~> 1.1.0)
net-sftp (~> 2.1) net-sftp (~> 2.1)
@ -40,7 +40,8 @@ GIT
rb-kqueue (~> 0.2.0) rb-kqueue (~> 0.2.0)
rest-client (>= 1.6.0, < 2.0) rest-client (>= 1.6.0, < 2.0)
wdm (~> 0.1.0) wdm (~> 0.1.0)
winrm (~> 1.1.3) winrm (~> 1.3)
winrm-fs (~> 0.2.0)
PATH PATH
remote: . remote: .
@ -50,52 +51,44 @@ PATH
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
akami (1.2.2)
gyoku (>= 0.4.0)
nokogiri
builder (3.2.2) builder (3.2.2)
celluloid (0.16.0) childprocess (0.5.6)
timers (~> 4.0.0)
childprocess (0.5.5)
ffi (~> 1.0, >= 1.0.11) ffi (~> 1.0, >= 1.0.11)
coderay (1.1.0) coderay (1.1.0)
coveralls (0.7.1) coveralls (0.7.2)
multi_json (~> 1.3) multi_json (~> 1.3)
rest-client rest-client (= 1.6.7)
simplecov (>= 0.7) simplecov (>= 0.7)
term-ansicolor term-ansicolor (= 1.2.2)
thor thor (= 0.18.1)
diff-lcs (1.2.5) diff-lcs (1.2.5)
docile (1.1.5) docile (1.1.5)
erubis (2.7.0) erubis (2.7.0)
ffi (1.9.6) ffi (1.9.10)
formatador (0.2.5) formatador (0.2.5)
gssapi (1.0.3) gssapi (1.2.0)
ffi (>= 1.0.1) ffi (>= 1.0.1)
guard (2.11.1) guard (2.12.8)
formatador (>= 0.2.4) formatador (>= 0.2.4)
listen (~> 2.7) listen (>= 2.7, <= 4.0)
lumberjack (~> 1.0) lumberjack (~> 1.0)
nenv (~> 0.1) nenv (~> 0.1)
notiffany (~> 0.0) notiffany (~> 0.0)
pry (>= 0.9.12) pry (>= 0.9.12)
shellany (~> 0.0) shellany (~> 0.0)
thor (>= 0.18.1) thor (>= 0.18.1)
guard-compat (1.2.0) guard-compat (1.2.1)
guard-rspec (4.5.0) guard-rspec (4.6.2)
guard (~> 2.1) guard (~> 2.1)
guard-compat (~> 1.1) guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0) rspec (>= 2.99.0, < 4.0)
gyoku (1.2.2) gyoku (1.3.1)
builder (>= 2.1.2) builder (>= 2.1.2)
hashicorp-checkpoint (0.1.4) hashicorp-checkpoint (0.1.4)
hitimes (1.2.2)
httpclient (2.6.0.1) httpclient (2.6.0.1)
httpi (0.9.7) i18n (0.7.0)
rack json (1.8.3)
i18n (0.6.11) listen (3.0.2)
listen (2.8.5)
celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3) rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9) rb-inotify (>= 0.9)
little-plugger (1.1.3) little-plugger (1.1.3)
@ -105,36 +98,33 @@ GEM
multi_json (>= 1.8.4) multi_json (>= 1.8.4)
lumberjack (1.0.9) lumberjack (1.0.9)
method_source (0.8.2) method_source (0.8.2)
mime-types (2.4.3) mime-types (2.6.1)
mini_portile (0.6.0) mini_portile (0.6.0)
multi_json (1.10.1) multi_json (1.11.2)
nenv (0.1.1) nenv (0.2.0)
net-scp (1.1.2) net-scp (1.1.2)
net-ssh (>= 2.6.5) net-ssh (>= 2.6.5)
net-sftp (2.1.2) net-sftp (2.1.2)
net-ssh (>= 2.6.5) net-ssh (>= 2.6.5)
net-ssh (2.9.1) net-ssh (2.9.2)
netrc (0.10.2)
nokogiri (1.6.3.1) nokogiri (1.6.3.1)
mini_portile (= 0.6.0) mini_portile (= 0.6.0)
nori (1.1.5) nori (2.6.0)
notiffany (0.0.2) notiffany (0.0.6)
nenv (~> 0.1) nenv (~> 0.1)
shellany (~> 0.0) shellany (~> 0.0)
pry (0.10.1) pry (0.10.1)
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.8.1) method_source (~> 0.8.1)
slop (~> 3.4) slop (~> 3.4)
rack (1.6.0)
rake (10.4.2) rake (10.4.2)
rb-fsevent (0.9.4) rb-fsevent (0.9.5)
rb-inotify (0.9.5) rb-inotify (0.9.5)
ffi (>= 0.5.0) ffi (>= 0.5.0)
rb-kqueue (0.2.3) rb-kqueue (0.2.4)
ffi (>= 0.5.0) ffi (>= 0.5.0)
rest-client (1.7.2) rest-client (1.6.7)
mime-types (>= 1.16, < 3.0) mime-types (>= 1.16)
netrc (~> 0.7)
rspec (2.99.0) rspec (2.99.0)
rspec-core (~> 2.99.0) rspec-core (~> 2.99.0)
rspec-expectations (~> 2.99.0) rspec-expectations (~> 2.99.0)
@ -142,42 +132,37 @@ GEM
rspec-core (2.99.2) rspec-core (2.99.2)
rspec-expectations (2.99.2) rspec-expectations (2.99.2)
diff-lcs (>= 1.1.3, < 2.0) diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.99.2) rspec-mocks (2.99.4)
rubyntlm (0.1.1) rubyntlm (0.4.0)
savon (0.9.5) rubyzip (1.1.7)
akami (~> 1.0)
builder (>= 2.1.2)
gyoku (>= 0.4.0)
httpi (~> 0.9)
nokogiri (>= 1.4.0)
nori (~> 1.0)
wasabi (~> 1.0)
shellany (0.0.1) shellany (0.0.1)
simplecov (0.9.1) simplecov (0.10.0)
docile (~> 1.1.0) docile (~> 1.1.0)
multi_json (~> 1.0) json (~> 1.8)
simplecov-html (~> 0.8.0) simplecov-html (~> 0.10.0)
simplecov-html (0.8.0) simplecov-html (0.10.0)
slop (3.6.0) slop (3.6.0)
term-ansicolor (1.3.0) term-ansicolor (1.2.2)
tins (~> 1.0) tins (~> 0.8)
thor (0.18.1) thor (0.18.1)
timers (4.0.1) tins (0.13.2)
hitimes
tins (1.3.3)
uuidtools (2.1.5) uuidtools (2.1.5)
vagrant-omnibus (1.4.1) vagrant-omnibus (1.4.1)
wasabi (1.0.0) wdm (0.1.1)
nokogiri (>= 1.4.0) winrm (1.3.3)
wdm (0.1.0) builder (>= 2.1.2)
winrm (1.1.3) gssapi (~> 1.2)
gssapi (~> 1.0.0) gyoku (~> 1.0)
httpclient (~> 2.2, >= 2.2.0.2) httpclient (~> 2.2, >= 2.2.0.2)
logging (~> 1.6, >= 1.6.1) logging (~> 1.6, >= 1.6.1)
nokogiri (~> 1.5) nori (~> 2.0)
rubyntlm (~> 0.1.1) rubyntlm (~> 0.4.0)
savon (= 0.9.5)
uuidtools (~> 2.1.2) 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 PLATFORMS
ruby ruby

View file

@ -79,10 +79,8 @@ module Vagrant
def create(name, backingstore, backingstore_options, template_path, config_file, template_options = {}) def create(name, backingstore, backingstore_options, template_path, config_file, template_options = {})
@cli.name = @container_name = name @cli.name = @container_name = name
import_template(template_path) do |template_name|
@logger.debug "Creating container..." @logger.debug "Creating container..."
@cli.create template_name, backingstore, backingstore_options, config_file, template_options @cli.create template_path, backingstore, backingstore_options, config_file, template_options
end
end end
def share_folders(folders) def share_folders(folders)
@ -239,39 +237,6 @@ module Vagrant
@sudo_wrapper.run 'chown', 'root:root', base_path.join('config').to_s @sudo_wrapper.run 'chown', 'root:root', base_path.join('config').to_s
end end
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 end
end end

View file

@ -36,7 +36,7 @@ module Vagrant
def ensure_lxc_installed! def ensure_lxc_installed!
begin begin
sudo_wrapper.run("/usr/bin/which", "lxc-create") sudo_wrapper.run("which", "lxc-create")
rescue Vagrant::LXC::Errors::ExecuteError rescue Vagrant::LXC::Errors::ExecuteError
raise Errors::LxcNotInstalled raise Errors::LxcNotInstalled
end end

View file

@ -14,7 +14,7 @@ module Vagrant
def run(*command) def run(*command)
options = command.last.is_a?(Hash) ? command.last : {} options = command.last.is_a?(Hash) ? command.last : {}
command.unshift @wrapper_path if @wrapper_path && !options[:no_wrapper] command.unshift @wrapper_path if @wrapper_path && !options[:no_wrapper]
execute *(['sudo'] + command) execute *(['sudo', '/usr/bin/env'] + command)
end end
private private

View file

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
# This is a modified version of /usr/share/lxc/templates/lxc-download # 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 # that comes with ubuntu-lxc 1.0.0 stable from ppa changed to suit vagrant-lxc needs

View file

@ -54,7 +54,7 @@ describe Vagrant::LXC::Driver do
it 'creates container with the right arguments' do it 'creates container with the right arguments' do
expect(cli).to have_received(:create).with( expect(cli).to have_received(:create).with(
template_name, template_path,
backingstore, backingstore,
backingstore_opts, backingstore_opts,
config_file, config_file,
@ -97,7 +97,7 @@ describe Vagrant::LXC::Driver do
before do before do
sudo.should_receive(:run).with('cat', '/var/lib/lxc/name/config').exactly(2).times. sudo.should_receive(:run).with('cat', '/var/lib/lxc/name/config').exactly(2).times.
and_return('# CONFIGURATION') 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') sudo.should_receive(:run).twice.with('chown', 'root:root', '/var/lib/lxc/name/config')
subject.customizations << internal_customization subject.customizations << internal_customization

View file

@ -80,7 +80,6 @@ end
base = "/var/lib/lxc" base = "/var/lib/lxc"
base_path = %r{\A#{base}/.*\z} base_path = %r{\A#{base}/.*\z}
templates_path = %r{\A/usr/(share|lib|lib64|local/lib)/lxc/templates/.*\z}
## ##
# Commands from provider.rb # Commands from provider.rb
@ -96,11 +95,6 @@ Whitelist.add '<%= cmd_paths['mkdir'] %>', '-p', base_path
# - Container config customizations and pruning # - Container config customizations and pruning
Whitelist.add '<%= cmd_paths['cp'] %>', '-f', %r{/tmp/.*}, base_path Whitelist.add '<%= cmd_paths['cp'] %>', '-f', %r{/tmp/.*}, base_path
Whitelist.add '<%= cmd_paths['chown'] %>', 'root:root', 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 # - Packaging
Whitelist.add '<%= cmd_paths['tar'] %>', '--numeric-owner', '-cvzf', %r{/tmp/.*/rootfs.tar.gz}, '-C', base_path, './rootfs' 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} Whitelist.add '<%= cmd_paths['chown'] %>', /\A\d+:\d+\z/, %r{\A/tmp/.*/rootfs\.tar\.gz\z}