dev-lxc 0.2.2 → 0.2.3
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.
- data/lib/dev-lxc/chef-server.rb +12 -6
- data/lib/dev-lxc/container.rb +6 -3
- data/lib/dev-lxc/version.rb +1 -1
- data/lib/dev-lxc.rb +13 -1
- metadata +2 -2
data/lib/dev-lxc/chef-server.rb
CHANGED
|
@@ -155,12 +155,18 @@ module DevLXC
|
|
|
155
155
|
base_platform.clone(base_server.name, {:flags => LXC::LXC_CLONE_SNAPSHOT})
|
|
156
156
|
base_server = DevLXC::Container.new(base_server.name)
|
|
157
157
|
|
|
158
|
-
#
|
|
159
|
-
#
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
158
|
+
# Disable certain sysctl.d files in Ubuntu 10.04, they cause `start procps` to fail
|
|
159
|
+
# Enterprise Chef server's postgresql recipe expects to be able to `start procps`
|
|
160
|
+
if base_platform.name == "b-ubuntu-1004"
|
|
161
|
+
if File.exist?("#{base_server.config_item('lxc.rootfs')}/etc/sysctl.d/10-console-messages.conf")
|
|
162
|
+
FileUtils.mv("#{base_server.config_item('lxc.rootfs')}/etc/sysctl.d/10-console-messages.conf",
|
|
163
|
+
"#{base_server.config_item('lxc.rootfs')}/etc/sysctl.d/10-console-messages.conf.orig")
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
# TODO when LXC 1.0.2 is released the following test can be done using #config_item("lxc.mount.auto")
|
|
167
|
+
unless IO.readlines(base_server.config_file_name).select { |line| line.start_with?("lxc.mount.auto") }.empty?
|
|
168
|
+
base_server.set_config_item("lxc.mount.auto", "proc:rw sys:rw")
|
|
169
|
+
base_server.save_config
|
|
164
170
|
end
|
|
165
171
|
base_server.sync_mounts(@mounts)
|
|
166
172
|
base_server.start
|
data/lib/dev-lxc/container.rb
CHANGED
|
@@ -29,9 +29,12 @@ module DevLXC
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def sync_mounts(mounts)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
existing_mounts = self.config_item("lxc.mount.entry")
|
|
33
|
+
if existing_mounts.is_a?(Array)
|
|
34
|
+
preserved_mounts = existing_mounts.delete_if { |m| m.end_with?("## dev-lxc ##") }
|
|
35
|
+
self.clear_config_item('lxc.mount.entries')
|
|
36
|
+
self.set_config_item("lxc.mount.entry", preserved_mounts)
|
|
37
|
+
end
|
|
35
38
|
mounts.each do |mount|
|
|
36
39
|
raise "Mount source #{mount.split.first} does not exist." unless File.exists?(mount.split.first)
|
|
37
40
|
puts "Adding mount entry #{mount}"
|
data/lib/dev-lxc/version.rb
CHANGED
data/lib/dev-lxc.rb
CHANGED
|
@@ -23,6 +23,13 @@ module DevLXC
|
|
|
23
23
|
when "b-centos-6"
|
|
24
24
|
base_platform.create("download", "btrfs", 0, ["-d", "centos", "-r", "6", "-a", "amd64"])
|
|
25
25
|
end
|
|
26
|
+
# TODO when LXC 1.0.2 is released and the following test is replaced with #config_item("lxc.mount.auto")
|
|
27
|
+
# then this #save_config can be removed
|
|
28
|
+
base_platform.save_config
|
|
29
|
+
# TODO when LXC 1.0.2 is released the following test can be done using #config_item("lxc.mount.auto")
|
|
30
|
+
unless IO.readlines(base_platform.config_file_name).select { |line| line.start_with?("lxc.mount.auto") }.empty?
|
|
31
|
+
base_platform.set_config_item("lxc.mount.auto", "proc:rw sys:rw")
|
|
32
|
+
end
|
|
26
33
|
hwaddr = '00:16:3e:' + Digest::SHA1.hexdigest(Time.now.to_s).slice(0..5).unpack('a2a2a2').join(':')
|
|
27
34
|
puts "Setting #{base_platform.name} container's lxc.network.0.hwaddr to #{hwaddr}"
|
|
28
35
|
base_platform.set_config_item("lxc.network.0.hwaddr", hwaddr)
|
|
@@ -31,6 +38,11 @@ module DevLXC
|
|
|
31
38
|
puts "Installing packages in container #{base_platform.name}"
|
|
32
39
|
case base_platform.name
|
|
33
40
|
when "b-ubuntu-1004"
|
|
41
|
+
# Disable certain sysctl.d files in Ubuntu 10.04, they cause `start procps` to fail
|
|
42
|
+
if File.exist?("#{base_platform.config_item('lxc.rootfs')}/etc/sysctl.d/10-console-messages.conf")
|
|
43
|
+
FileUtils.mv("#{base_platform.config_item('lxc.rootfs')}/etc/sysctl.d/10-console-messages.conf",
|
|
44
|
+
"#{base_platform.config_item('lxc.rootfs')}/etc/sysctl.d/10-console-messages.conf.orig")
|
|
45
|
+
end
|
|
34
46
|
base_platform.run_command("apt-get update")
|
|
35
47
|
base_platform.run_command("apt-get install -y standard^ server^ vim-nox emacs23-nox curl tree")
|
|
36
48
|
when "b-ubuntu-1204"
|
|
@@ -73,7 +85,7 @@ module DevLXC
|
|
|
73
85
|
|
|
74
86
|
def self.append_line_to_file(file_name, line)
|
|
75
87
|
content = IO.readlines(file_name)
|
|
76
|
-
content[-1] = content[-1].chomp + "\n"
|
|
88
|
+
content[-1] = content[-1].chomp + "\n" unless content.empty?
|
|
77
89
|
content << line
|
|
78
90
|
IO.write(file_name, content.join)
|
|
79
91
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dev-lxc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2014-03-
|
|
12
|
+
date: 2014-03-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|