dev-lxc 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- # Rename procps in Ubuntu platforms because Enterprise Chef server < 11.0.0
159
- # postgres recipe will use it even though it does not work in an LXC container
160
- @packages["server"].to_s.match(/private-chef[_-](\d+)\.(\d+\.?){2,}-/)
161
- if base_platform.name.include?("ubuntu") && Regexp.last_match[1].to_i < 11
162
- FileUtils.mv("#{base_server.config_item('lxc.rootfs')}/etc/init.d/procps",
163
- "#{base_server.config_item('lxc.rootfs')}/etc/init.d/procps.orig")
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
@@ -29,9 +29,12 @@ module DevLXC
29
29
  end
30
30
 
31
31
  def sync_mounts(mounts)
32
- preserved_mounts = self.config_item("lxc.mount.entry").delete_if { |m| m.end_with?("## dev-lxc ##") }
33
- self.clear_config_item('lxc.mount.entries')
34
- self.set_config_item("lxc.mount.entry", preserved_mounts)
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}"
@@ -1,3 +1,3 @@
1
1
  module DevLXC
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
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.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-10 00:00:00.000000000 Z
12
+ date: 2014-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler