vagrant-lxc 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/BOXES.md +55 -0
  3. data/CHANGELOG.md +14 -0
  4. data/CONTRIBUTING.md +20 -0
  5. data/Gemfile +1 -1
  6. data/Gemfile.lock +4 -3
  7. data/README.md +16 -19
  8. data/boxes/build-debian-box.sh +167 -0
  9. data/boxes/build-ubuntu-box.sh +151 -0
  10. data/boxes/common/install-babushka +4 -3
  11. data/boxes/common/install-chef +3 -2
  12. data/boxes/common/install-puppet +3 -2
  13. data/boxes/common/install-salt +3 -2
  14. data/boxes/common/lxc-template +10 -13
  15. data/boxes/common/metadata.json +2 -1
  16. data/development/Vagrantfile +4 -4
  17. data/development/site.pp +31 -6
  18. data/lib/vagrant-lxc/action.rb +44 -40
  19. data/lib/vagrant-lxc/action/clear_forwarded_ports.rb +4 -0
  20. data/lib/vagrant-lxc/action/fetch_ip_from_dnsmasq_leases.rb +1 -1
  21. data/lib/vagrant-lxc/action/fetch_ip_with_lxc_attach.rb +4 -7
  22. data/lib/vagrant-lxc/action/message.rb +1 -0
  23. data/lib/vagrant-lxc/action/setup_package_files.rb +1 -0
  24. data/lib/vagrant-lxc/action/wait_for_communicator.rb +9 -14
  25. data/lib/vagrant-lxc/driver.rb +10 -7
  26. data/lib/vagrant-lxc/driver/cli.rb +7 -1
  27. data/lib/vagrant-lxc/errors.rb +5 -0
  28. data/lib/vagrant-lxc/version.rb +1 -1
  29. data/locales/en.yml +8 -2
  30. data/spec/Vagrantfile +7 -2
  31. data/spec/unit/driver/cli_spec.rb +8 -0
  32. metadata +8 -18
  33. data/boxes/debian/download +0 -156
  34. data/boxes/debian/finalize +0 -195
  35. data/boxes/debian/lxc-template +0 -367
  36. data/boxes/debian/metadata.json.template +0 -9
  37. data/boxes/ubuntu/download +0 -113
  38. data/boxes/ubuntu/finalize +0 -374
  39. data/boxes/ubuntu/lxc-template +0 -559
  40. data/boxes/ubuntu/metadata.json.template +0 -9
  41. data/development/shell-provisioning/upgrade-kernel +0 -14
  42. data/example/Vagrantfile +0 -46
  43. data/example/cookbooks/hello-world/recipes/default.rb +0 -4
  44. data/example/puppet/manifests/site.pp +0 -5
  45. data/example/puppet/modules/hello_world/manifests/init.pp +0 -3
  46. data/tasks/boxes.rake +0 -115
  47. data/tasks/boxes.v2.rake +0 -188
@@ -1,9 +0,0 @@
1
- {
2
- "provider": "lxc",
3
- "version": "2",
4
-
5
- "template-opts": {
6
- "--arch": "ARCH",
7
- "--release": "RELEASE"
8
- }
9
- }
@@ -1,14 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -e
4
-
5
-
6
- if [[ `uname -r` != "3.5.0-17-generic" ]]; then
7
- exit 0
8
- fi
9
- echo 'An old kernel was found on the guest machine and it will be upgraded' 1>&2
10
- echo 'Please reload the box after provisioning when finished' 1>&2
11
- sudo apt-get update
12
- sudo apt-get install linux-image-3.5.0-28-generic linux-headers-3.5.0-28-generic -y
13
- sudo apt-get upgrade -y
14
- sudo apt-get autoremove -y
@@ -1,46 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- # Not really needed, but useful while developing so that vagrant picks it up
5
- Vagrant.require_plugin 'vagrant-lxc'
6
- Vagrant.require_plugin 'vagrant-omnibus'
7
-
8
- Vagrant.configure("2") do |config|
9
- config.vm.synced_folder "/tmp", "/vagrant_data"
10
-
11
- config.vm.provider :lxc do |lxc|
12
- lxc.customize 'cgroup.memory.limit_in_bytes', '400M'
13
- end
14
-
15
- config.vm.provision :shell, :inline => <<-SCRIPT
16
- echo "Hi there I'm a shell script used for provisioning"
17
- SCRIPT
18
-
19
- config.vm.provision :puppet do |puppet|
20
- puppet.module_path = "puppet/modules"
21
- puppet.manifests_path = "puppet/manifests"
22
- puppet.manifest_file = "site.pp"
23
- end
24
-
25
- port = 8080
26
- releases = %w(precise quantal raring wheezy squeeze sid)
27
- releases.each do |release|
28
- config.vm.define(release) do |lxc_config|
29
- lxc_config.vm.box = "#{release}64"
30
- lxc_config.vm.box_url = "http://dl.dropbox.com/u/13510779/lxc-#{release}-amd64-2013-07-12.box"
31
- # Uncomment if you want to try out a box built locally
32
- # lxc_config.vm.box_url = "../boxes/output/lxc-#{release}-amd64-2013-07-12.box"
33
- lxc_config.vm.network :forwarded_port, guest: 80, host: (port += 1)
34
- lxc_config.vm.hostname = "lxc-#{release}64-example"
35
-
36
- if %w(precise quantal raring squeeze).include? release
37
- lxc_config.omnibus.chef_version = :latest
38
-
39
- lxc_config.vm.provision :chef_solo do |chef|
40
- chef.add_recipe "hello-world"
41
- chef.log_level = :debug
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,4 +0,0 @@
1
- execute "hello world" do
2
- command "echo 'Hello from Chef!'"
3
- action :run
4
- end
@@ -1,5 +0,0 @@
1
- Exec { path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/'] }
2
-
3
- notice "Hi there! puppet here"
4
-
5
- require hello_world
@@ -1,3 +0,0 @@
1
- class hello_world {
2
- notice "Puppet module here. Things seem to be working just fine ;-)"
3
- }
@@ -1,115 +0,0 @@
1
- require 'pathname'
2
- require 'rake/tasklib'
3
- load 'tasks/boxes.v2.rake'
4
-
5
- class BuildGenericBoxTaskV3 < BuildGenericBoxTaskV2
6
- def build
7
- require 'vagrant'
8
-
9
- check_if_box_has_been_built!
10
-
11
- FileUtils.mkdir_p 'boxes/temp' unless File.exist? 'base/temp'
12
- check_for_partially_built_box!
13
-
14
- pwd = Dir.pwd
15
- sh 'mkdir -p boxes/temp/'
16
- Dir.chdir 'boxes/temp' do
17
- download
18
- install_cfg_engines
19
- finalize
20
- prepare_package_contents pwd
21
- sh 'sudo rm -rf rootfs'
22
- sh "tar -czf tmp-package.box ./*"
23
- end
24
-
25
- sh 'mkdir -p boxes/output'
26
- sh "cp boxes/temp/tmp-package.box boxes/output/#{@file}"
27
- sh "rm -rf boxes/temp"
28
- end
29
-
30
- def finalize
31
- auth_key = Vagrant.source_root.join('keys', 'vagrant.pub').expand_path.to_s
32
- run 'finalize', @arch, @release, auth_key
33
- end
34
-
35
- def prepare_package_contents(pwd)
36
- run 'cleanup'
37
- sh 'sudo rm -f rootfs.tar.gz'
38
- sh 'sudo tar --numeric-owner -czf rootfs.tar.gz ./rootfs/*'
39
- sh "sudo chown #{ENV['USER']}:#{`id -gn`.strip} rootfs.tar.gz"
40
- sh "cp #{pwd}/boxes/common/lxc-template ."
41
- sh "cp #{pwd}/boxes/common/lxc.conf ."
42
- sh "cp #{pwd}/boxes/common/metadata.json ."
43
- end
44
- end
45
-
46
- class BuildDebianBoxTaskV3 < BuildGenericBoxTaskV3
47
- def initialize(name, release, arch, opts = {})
48
- super(name, 'debian', release, arch, opts)
49
- end
50
- end
51
-
52
- class BuildUbuntuBoxTaskV3 < BuildGenericBoxTaskV3
53
- def initialize(name, release, arch, opts = {})
54
- super(name, 'ubuntu', release, arch, opts)
55
- end
56
- end
57
-
58
- puppet = ENV['PUPPET'] == '1'
59
- babushka = ENV['BABUSHKA'] == '1'
60
- salt = ENV['SALT'] == '1'
61
-
62
- namespace :boxes do
63
- namespace :ubuntu do
64
- namespace :build do
65
-
66
- desc 'Build an Ubuntu Precise 64 bits box'
67
- BuildUbuntuBoxTaskV3.
68
- new(:precise64,
69
- :precise, 'amd64', puppet: puppet, babushka: babushka, salt: salt)
70
-
71
- desc 'Build an Ubuntu Quantal 64 bits box'
72
- BuildUbuntuBoxTaskV3.
73
- new(:quantal64,
74
- :quantal, 'amd64', puppet: puppet, babushka: babushka, salt: salt)
75
-
76
- desc 'Build an Ubuntu Raring 64 bits box'
77
- BuildUbuntuBoxTaskV3.
78
- new(:raring64,
79
- :raring, 'amd64', puppet: puppet, babushka: babushka, salt: salt)
80
-
81
- desc 'Build an Ubuntu Saucy 64 bits box'
82
- BuildUbuntuBoxTaskV3.
83
- new(:saucy64,
84
- :saucy, 'amd64', puppet: puppet, babushka: babushka, salt: salt)
85
-
86
- desc 'Build all Ubuntu boxes'
87
- task :all => %w( precise64 quantal64 raring64 saucy64 )
88
- end
89
- end
90
-
91
- namespace :debian do
92
- namespace :build do
93
- desc 'Build an Debian Squeeze 64 bits box'
94
- BuildDebianBoxTaskV3.
95
- new(:squeeze64,
96
- :squeeze, 'amd64', puppet: puppet, babushka: babushka, salt: false)
97
-
98
- desc 'Build an Debian Wheezy 64 bits box'
99
- BuildDebianBoxTaskV3.
100
- new(:wheezy64,
101
- :wheezy, 'amd64', puppet: puppet, babushka: babushka, salt: false)
102
-
103
- desc 'Build an Debian Sid/unstable 64 bits box'
104
- BuildDebianBoxTaskV3.
105
- new(:sid64,
106
- :sid, 'amd64', puppet: puppet, babushka: babushka, salt: false)
107
-
108
- desc 'Build all Debian boxes'
109
- task :all => %w( squeeze64 wheezy64 sid64 )
110
- end
111
- end
112
-
113
- desc 'Build all base boxes for release'
114
- task :build_all => %w( ubuntu:build:all debian:build:all )
115
- end
@@ -1,188 +0,0 @@
1
- require 'pathname'
2
- require 'rake/tasklib'
3
-
4
- class BuildGenericBoxTaskV2 < ::Rake::TaskLib
5
- include ::Rake::DSL
6
-
7
- attr_reader :name
8
-
9
- def initialize(name, distrib, release, arch, opts = {})
10
- @name = name
11
- @distrib = distrib
12
- @release = release.to_s
13
- @arch = arch.to_s
14
- @install_chef = opts.fetch(:chef, false)
15
- @install_puppet = opts.fetch(:puppet, true)
16
- @install_babushka = opts.fetch(:babushka, true)
17
- @install_salt = opts.fetch(:salt, true)
18
- @file = opts[:file] || default_box_file
19
- @scripts_path = Pathname(Dir.pwd).join('boxes')
20
-
21
- desc "Build an #{distrib.upcase} #{release} #{arch} box" unless
22
- ::Rake.application.last_comment
23
- task name do
24
- RakeFileUtils.send(:verbose, true) do
25
- build
26
- end
27
- end
28
- end
29
-
30
- def default_box_file
31
- require 'time'
32
- "lxc-#{@release}-#{@arch}-#{Date.today}.box"
33
- end
34
-
35
- def run(script_name, *args)
36
- unless (script = @scripts_path.join(@distrib, script_name)).readable?
37
- script = @scripts_path.join('common', script_name)
38
- end
39
-
40
- if script.readable?
41
- sh "sudo #{script} #{args.join(' ')}"
42
- else
43
- STDERR.puts "cannot execute #{script_name} (not found?)"
44
- exit 1
45
- end
46
- end
47
-
48
- def build
49
- check_if_box_has_been_built!
50
-
51
- FileUtils.mkdir_p 'boxes/temp' unless File.exist? 'base/temp'
52
- check_for_partially_built_box!
53
-
54
- pwd = Dir.pwd
55
- sh 'mkdir -p boxes/temp/'
56
- Dir.chdir 'boxes/temp' do
57
- download
58
- install_cfg_engines
59
- prepare_package_contents pwd
60
- sh 'sudo rm -rf rootfs'
61
- sh "tar -czf tmp-package.box ./*"
62
- end
63
-
64
- sh 'mkdir -p boxes/output'
65
- sh "cp boxes/temp/tmp-package.box boxes/output/#{@file}"
66
- sh "rm -rf boxes/temp"
67
- end
68
-
69
- def check_if_box_has_been_built!
70
- return unless File.exists?("./boxes/output/#{@file}")
71
-
72
- puts 'Box has been built already!'
73
- exit 1
74
- end
75
-
76
- def check_for_partially_built_box!
77
- return unless Dir.entries('boxes/temp').size > 2
78
-
79
- puts 'There is a partially built box under ' +
80
- File.expand_path('./boxes/temp') +
81
- ', please remove it before building a new box'
82
- exit 1
83
- end
84
-
85
- def download
86
- run 'download', @arch, @release
87
- end
88
-
89
- def install_cfg_engines
90
- [ :puppet, :chef, :babushka, :salt ].each do |cfg_engine|
91
- next unless instance_variable_get :"@install_#{cfg_engine}"
92
- script_name = "install-#{cfg_engine}"
93
- run script_name
94
- end
95
- end
96
-
97
- def prepare_package_contents(pwd)
98
- run 'cleanup'
99
- sh 'sudo rm -f rootfs.tar.gz'
100
- sh 'sudo tar --numeric-owner -czf rootfs.tar.gz ./rootfs/*'
101
- sh "sudo chown #{ENV['USER']}:#{`id -gn`.strip} rootfs.tar.gz"
102
- sh "cp #{pwd}/boxes/#{@distrib}/lxc-template ."
103
- compile_metadata(pwd)
104
- end
105
-
106
- def compile_metadata(pwd)
107
- metadata = File.read("#{pwd}/boxes/#{@distrib}/metadata.json.template")
108
- metadata.gsub!('ARCH', @arch)
109
- metadata.gsub!('RELEASE', @release)
110
- File.open('metadata.json', 'w') { |f| f.print metadata }
111
- end
112
- end
113
-
114
- class BuildDebianBoxTaskV2 < BuildGenericBoxTaskV2
115
- def initialize(name, release, arch, opts = {})
116
- super(name, 'debian', release, arch, opts)
117
- end
118
- end
119
-
120
- class BuildUbuntuBoxTaskV2 < BuildGenericBoxTaskV2
121
- def initialize(name, release, arch, opts = {})
122
- super(name, 'ubuntu', release, arch, opts)
123
- end
124
- end
125
-
126
- chef = ENV['CHEF'] == '1'
127
- puppet = ENV['PUPPET'] == '1'
128
- babushka = ENV['BABUSHKA'] == '1'
129
- salt = ENV['SALT'] == '1'
130
-
131
- namespace :boxes do
132
- namespace :v2 do
133
- namespace :ubuntu do
134
- namespace :build do
135
-
136
- desc 'Build an Ubuntu Precise 64 bits box'
137
- BuildUbuntuBoxTaskV2.
138
- new(:precise64,
139
- :precise, 'amd64', chef: chef, puppet: puppet, babushka: babushka, salt: salt)
140
-
141
- desc 'Build an Ubuntu Quantal 64 bits box'
142
- BuildUbuntuBoxTaskV2.
143
- new(:quantal64,
144
- :quantal, 'amd64', chef: chef, puppet: puppet, babushka: babushka, salt: salt)
145
-
146
- # FIXME: Find out how to install chef on raring
147
- desc 'Build an Ubuntu Raring 64 bits box'
148
- BuildUbuntuBoxTaskV2.
149
- new(:raring64,
150
- :raring, 'amd64', chef: chef, puppet: puppet, babushka: babushka, salt: salt)
151
-
152
- desc 'Build an Ubuntu Saucy 64 bits box'
153
- BuildUbuntuBoxTaskV2.
154
- new(:saucy64,
155
- :saucy, 'amd64', chef: chef, puppet: puppet, babushka: babushka, salt: salt)
156
-
157
- desc 'Build all Ubuntu boxes'
158
- task :all => %w( precise64 quantal64 raring64 saucy64 )
159
- end
160
- end
161
-
162
- # FIXME: Find out how to install chef on debian boxes
163
- namespace :debian do
164
- namespace :build do
165
- desc 'Build an Debian Squeeze 64 bits box'
166
- BuildDebianBoxTaskV2.
167
- new(:squeeze64,
168
- :squeeze, 'amd64', chef: false, puppet: puppet, babushka: babushka, salt: false)
169
-
170
- desc 'Build an Debian Wheezy 64 bits box'
171
- BuildDebianBoxTaskV2.
172
- new(:wheezy64,
173
- :wheezy, 'amd64', chef: false, puppet: puppet, babushka: babushka, salt: false)
174
-
175
- desc 'Build an Debian Sid/unstable 64 bits box'
176
- BuildDebianBoxTaskV2.
177
- new(:sid64,
178
- :sid, 'amd64', chef: false, puppet: puppet, babushka: babushka, salt: false)
179
-
180
- desc 'Build all Debian boxes'
181
- task :all => %w( squeeze64 wheezy64 sid64 )
182
- end
183
- end
184
-
185
- desc 'Build all base boxes for release'
186
- task :build_all => %w( ubuntu:build:all debian:build:all )
187
- end
188
- end