testlab 1.2.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -4
- data/features/support/Labfile.vagrant +7 -0
- data/lib/testlab/container/configuration.rb +1 -1
- data/lib/testlab/provisioners/apt_cacher_ng.rb +3 -16
- data/lib/testlab/provisioners/bind.rb +0 -13
- data/lib/testlab/provisioners/resolv.rb +14 -14
- data/lib/testlab/provisioners/templates/apt/provision.erb +12 -7
- data/lib/testlab/provisioners/templates/apt_cacher_ng/provision.erb +5 -7
- data/lib/testlab/provisioners/templates/raring/provision.erb +7 -6
- data/lib/testlab/provisioners/templates/resolv/{resolv.conf.erb → provision.erb} +9 -0
- data/lib/testlab/version.rb +1 -1
- metadata +5 -6
- data/lib/testlab/provisioners/templates/apt_cacher_ng/deprovision.erb +0 -6
data/README.md
CHANGED
@@ -280,7 +280,7 @@ For more information see the TestLab Documentation, `testlab-repo`, command-line
|
|
280
280
|
|
281
281
|
# EXAMPLE USE
|
282
282
|
|
283
|
-
* See the `testlab-repo` - https://github.com/
|
283
|
+
* See the `testlab-repo` - https://github.com/lookout/testlab-repo
|
284
284
|
|
285
285
|
# RUBIES TESTED AGAINST
|
286
286
|
|
@@ -298,15 +298,15 @@ IRC:
|
|
298
298
|
|
299
299
|
Documentation:
|
300
300
|
|
301
|
-
* http://
|
301
|
+
* http://lookout.github.io/testlab/
|
302
302
|
|
303
303
|
Source:
|
304
304
|
|
305
|
-
* https://github.com/
|
305
|
+
* https://github.com/lookout/testlab
|
306
306
|
|
307
307
|
Issues:
|
308
308
|
|
309
|
-
* https://github.com/
|
309
|
+
* https://github.com/lookout/testlab/issues
|
310
310
|
|
311
311
|
# LICENSE
|
312
312
|
|
@@ -53,7 +53,7 @@ class TestLab
|
|
53
53
|
'lxc.network.hwaddr' => interface.mac,
|
54
54
|
'lxc.network.ipv4' => "#{interface.ip}/#{interface.cidr} #{interface.netmask}"
|
55
55
|
]
|
56
|
-
if (
|
56
|
+
if (self.primary_interface == interface)
|
57
57
|
networks.last.merge!('lxc.network.ipv4.gateway' => :auto)
|
58
58
|
end
|
59
59
|
end
|
@@ -43,6 +43,7 @@ class TestLab
|
|
43
43
|
file.puts(ZTK::Template.render(apt_conf_d_proxy_file_template, context))
|
44
44
|
end
|
45
45
|
|
46
|
+
node.exec(%(sudo mkdir -pv #{File.dirname(apt_cacher_ng_security_conf_file)}))
|
46
47
|
node.file(:target => apt_cacher_ng_security_conf_file, :chown => "root:root", :chmod => "0644") do |file|
|
47
48
|
file.puts(ZTK::Template.render(apt_cacher_ng_security_conf_template, context))
|
48
49
|
end
|
@@ -52,16 +53,6 @@ class TestLab
|
|
52
53
|
true
|
53
54
|
end
|
54
55
|
|
55
|
-
# APT-CacherNG: Node Deprovision
|
56
|
-
#
|
57
|
-
# @param [TestLab::Node] node The node which we want to deprovision.
|
58
|
-
# @return [Boolean] True if successful.
|
59
|
-
def on_node_deprovision(node)
|
60
|
-
node.bootstrap(ZTK::Template.render(deprovision_template, @config))
|
61
|
-
|
62
|
-
true
|
63
|
-
end
|
64
|
-
|
65
56
|
# APT-CacherNG: Container Provision
|
66
57
|
#
|
67
58
|
# @param [TestLab::Container] container The container which we want to
|
@@ -94,21 +85,17 @@ class TestLab
|
|
94
85
|
end
|
95
86
|
|
96
87
|
def apt_conf_d_proxy_file_template
|
97
|
-
File.join(TestLab::Provisioner.template_dir,
|
88
|
+
File.join(TestLab::Provisioner.template_dir, 'apt_cacher_ng', '00proxy.erb')
|
98
89
|
end
|
99
90
|
|
100
91
|
def apt_cacher_ng_security_conf_template
|
101
|
-
File.join(TestLab::Provisioner.template_dir,
|
92
|
+
File.join(TestLab::Provisioner.template_dir, 'apt_cacher_ng', 'security.conf.erb')
|
102
93
|
end
|
103
94
|
|
104
95
|
def provision_template
|
105
96
|
File.join(TestLab::Provisioner.template_dir, 'apt_cacher_ng', 'provision.erb')
|
106
97
|
end
|
107
98
|
|
108
|
-
def deprovision_template
|
109
|
-
File.join(TestLab::Provisioner.template_dir, 'apt_cacher_ng', 'deprovision.erb')
|
110
|
-
end
|
111
|
-
|
112
99
|
end
|
113
100
|
|
114
101
|
end
|
@@ -18,7 +18,6 @@ class TestLab
|
|
18
18
|
@config[:bind][:domain] ||= "tld.invalid"
|
19
19
|
@config[:bind][:forwarders] ||= %w(8.8.8.8 8.8.4.4)
|
20
20
|
|
21
|
-
|
22
21
|
@ui.logger.debug { "config(#{@config.inspect})" }
|
23
22
|
end
|
24
23
|
|
@@ -34,18 +33,6 @@ class TestLab
|
|
34
33
|
true
|
35
34
|
end
|
36
35
|
|
37
|
-
# Bind: Node Deprovision
|
38
|
-
#
|
39
|
-
# @param [TestLab::Node] node The node which we want to deprovision.
|
40
|
-
# @return [Boolean] True if successful.
|
41
|
-
def on_node_deprovision(node)
|
42
|
-
@ui.logger.debug { "BIND Deprovisioner: Node #{node.id}" }
|
43
|
-
|
44
|
-
node.exec(%(sudo DEBIAN_FRONTEND="noninteractive" apt-get -y purge bind9))
|
45
|
-
|
46
|
-
true
|
47
|
-
end
|
48
|
-
|
49
36
|
# Bind: Container Up
|
50
37
|
#
|
51
38
|
# @param [TestLab::Container] container The container which just came online.
|
@@ -17,10 +17,10 @@ class TestLab
|
|
17
17
|
@config[:resolv] ||= Hash.new
|
18
18
|
|
19
19
|
@config[:resolv][:servers] ||= Array.new
|
20
|
-
@config[:resolv][:servers].
|
20
|
+
@config[:resolv][:servers].unshift([TestLab::Network.ips]).flatten!
|
21
21
|
|
22
22
|
@config[:resolv][:search] ||= Array.new
|
23
|
-
@config[:resolv][:search].
|
23
|
+
@config[:resolv][:search].unshift([TestLab::Container.domains]).flatten!
|
24
24
|
|
25
25
|
@ui.logger.debug { "config(#{@config.inspect})" }
|
26
26
|
end
|
@@ -32,9 +32,12 @@ class TestLab
|
|
32
32
|
def on_node_provision(node)
|
33
33
|
@ui.logger.debug { "RESOLV Provisioner: Node #{node.id}" }
|
34
34
|
|
35
|
-
@config[:resolv]
|
35
|
+
@config[:resolv].merge!(
|
36
|
+
:servers => %w(127.0.0.1),
|
37
|
+
:object => :node
|
38
|
+
)
|
36
39
|
|
37
|
-
|
40
|
+
node.bootstrap(ZTK::Template.render(provision_template, @config))
|
38
41
|
|
39
42
|
true
|
40
43
|
end
|
@@ -48,22 +51,19 @@ class TestLab
|
|
48
51
|
def on_container_provision(container)
|
49
52
|
@ui.logger.debug { "RESOLV Provisioner: Container #{container.id}" }
|
50
53
|
|
51
|
-
|
54
|
+
@config[:resolv].merge!(
|
55
|
+
:object => :container
|
56
|
+
)
|
52
57
|
|
53
|
-
|
54
|
-
end
|
58
|
+
container.bootstrap(ZTK::Template.render(provision_template, @config))
|
55
59
|
|
56
|
-
|
57
|
-
object.file(:target => %(/etc/resolv.conf), :chown => "root:root") do |file|
|
58
|
-
file.puts(ZTK::Template.do_not_edit_notice(:message => "TestLab v#{TestLab::VERSION} RESOLVER Configuration"))
|
59
|
-
file.puts(ZTK::Template.render(resolv_conf_template, @config))
|
60
|
-
end
|
60
|
+
true
|
61
61
|
end
|
62
62
|
|
63
63
|
private
|
64
64
|
|
65
|
-
def
|
66
|
-
File.join(TestLab::Provisioner.template_dir, 'resolv', '
|
65
|
+
def provision_template
|
66
|
+
File.join(TestLab::Provisioner.template_dir, 'resolv', 'provision.erb')
|
67
67
|
end
|
68
68
|
|
69
69
|
end
|
@@ -1,19 +1,24 @@
|
|
1
1
|
set -x
|
2
2
|
set -e
|
3
3
|
|
4
|
-
[[ -f /.testlab-apt-provision ]] && exit 0
|
5
|
-
|
6
4
|
export DEBIAN_FRONTEND="noninteractive"
|
7
5
|
|
8
6
|
apt-get -y update
|
7
|
+
|
9
8
|
<% if !@apt[:install].nil? -%>
|
10
|
-
|
9
|
+
<% @apt[:install].flatten.compact.each do |package| -%>
|
10
|
+
dpkg --status <%= package %> &> /dev/null || apt-get -y install <%= package %>
|
11
11
|
<% end -%>
|
12
|
+
<% end -%>
|
13
|
+
|
12
14
|
<% if !@apt[:remove].nil? -%>
|
13
|
-
|
15
|
+
<% @apt[:remove].flatten.compact.each do |package| -%>
|
16
|
+
dpkg --status <%= package %> &> /dev/null && apt-get -y remove <%= package %>
|
14
17
|
<% end -%>
|
15
|
-
<% if !@apt[:purge].nil? -%>
|
16
|
-
apt-get -y purge <%= @apt[:purge].flatten.compact.join(' ') %>
|
17
18
|
<% end -%>
|
18
19
|
|
19
|
-
|
20
|
+
<% if !@apt[:purge].nil? -%>
|
21
|
+
<% @apt[:purge].flatten.compact.each do |package| -%>
|
22
|
+
dpkg --status <%= package %> &> /dev/null && apt-get -y purge <%= package %>
|
23
|
+
<% end -%>
|
24
|
+
<% end -%>
|
@@ -1,12 +1,10 @@
|
|
1
1
|
set -x
|
2
2
|
set -e
|
3
3
|
|
4
|
-
[[ -f /.testlab-apt-cacher-ng-provision ]] && exit 0
|
5
|
-
|
6
4
|
export DEBIAN_FRONTEND="noninteractive"
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
if ! dpkg --status apt-cacher-ng &> /dev/null; then
|
7
|
+
apt-get -y install apt-cacher-ng
|
8
|
+
service apt-cacher-ng restart || service apt-cacher-ng start
|
9
|
+
grep "^MIRROR" /etc/default/lxc || (echo 'MIRROR="http://127.0.0.1:3142/archive.ubuntu.com/ubuntu"' | tee -a /etc/default/lxc)
|
10
|
+
fi
|
@@ -1,13 +1,13 @@
|
|
1
1
|
set -x
|
2
2
|
set -e
|
3
3
|
|
4
|
-
[[ -f /.testlab-raring-provision ]] && exit 0
|
5
|
-
|
6
4
|
export DEBIAN_FRONTEND="noninteractive"
|
7
5
|
|
8
6
|
# Update APT and ensure our required packages are installed
|
9
7
|
apt-get -y update
|
10
|
-
|
8
|
+
<% %w(lxc bridge-utils debootstrap yum iptables iptables-persistent ntpdate ntp pbzip2).each do |package| -%>
|
9
|
+
dpkg --status <%= package %> &> /dev/null || apt-get -y install <%= package %>
|
10
|
+
<% end -%>
|
11
11
|
|
12
12
|
# Ensure the default lxc networking services are off
|
13
13
|
service lxc-net stop || (service lxc-net start ; service lxc-net stop)
|
@@ -21,7 +21,8 @@ sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/' /etc/sysctl.conf
|
|
21
21
|
sysctl -w net.ipv4.ip_forward=1
|
22
22
|
|
23
23
|
# Install an iptable NAT rule
|
24
|
-
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
25
|
-
iptables-save | tee /etc/iptables/rules.v4
|
26
24
|
|
27
|
-
|
25
|
+
if ! iptables -t nat -v --list | grep "MASQUERADE"; then
|
26
|
+
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
27
|
+
iptables-save | tee /etc/iptables/rules.v4
|
28
|
+
fi
|
@@ -1,3 +1,10 @@
|
|
1
|
+
set -x
|
2
|
+
|
3
|
+
dpkg --status bind9 &> /dev/null || <%= (@resolv[:object] == :container).inspect %>
|
4
|
+
|
5
|
+
if [ $? -eq 0 ]; then
|
6
|
+
cat << EOF | tee /etc/resolv.conf
|
7
|
+
<%= ZTK::Template.do_not_edit_notice(:message => "TestLab Resolv Provisioner") %>
|
1
8
|
<% if !@resolv[:domain].nil? -%>
|
2
9
|
domain <%= @resolv[:domain] %>
|
3
10
|
<% end -%>
|
@@ -9,3 +16,5 @@ search <%= @resolv[:search].flatten.compact.uniq.join(' ') %>
|
|
9
16
|
nameserver <%= server %>
|
10
17
|
<% end -%>
|
11
18
|
<% end -%>
|
19
|
+
EOF
|
20
|
+
fi
|
data/lib/testlab/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testlab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
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: 2013-07-
|
12
|
+
date: 2013-07-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gli
|
@@ -289,7 +289,6 @@ files:
|
|
289
289
|
- lib/testlab/provisioners/shell.rb
|
290
290
|
- lib/testlab/provisioners/templates/apt/provision.erb
|
291
291
|
- lib/testlab/provisioners/templates/apt_cacher_ng/00proxy.erb
|
292
|
-
- lib/testlab/provisioners/templates/apt_cacher_ng/deprovision.erb
|
293
292
|
- lib/testlab/provisioners/templates/apt_cacher_ng/provision.erb
|
294
293
|
- lib/testlab/provisioners/templates/apt_cacher_ng/security.conf.erb
|
295
294
|
- lib/testlab/provisioners/templates/bind/bind-db.erb
|
@@ -300,7 +299,7 @@ files:
|
|
300
299
|
- lib/testlab/provisioners/templates/chef/ruby_gem_client.erb
|
301
300
|
- lib/testlab/provisioners/templates/chef/ruby_gem_server.erb
|
302
301
|
- lib/testlab/provisioners/templates/raring/provision.erb
|
303
|
-
- lib/testlab/provisioners/templates/resolv/
|
302
|
+
- lib/testlab/provisioners/templates/resolv/provision.erb
|
304
303
|
- lib/testlab/support.rb
|
305
304
|
- lib/testlab/support/execution.rb
|
306
305
|
- lib/testlab/support/lifecycle.rb
|
@@ -339,7 +338,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
339
338
|
version: '0'
|
340
339
|
segments:
|
341
340
|
- 0
|
342
|
-
hash: -
|
341
|
+
hash: -2931685983354543503
|
343
342
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
344
343
|
none: false
|
345
344
|
requirements:
|
@@ -348,7 +347,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
348
347
|
version: '0'
|
349
348
|
segments:
|
350
349
|
- 0
|
351
|
-
hash: -
|
350
|
+
hash: -2931685983354543503
|
352
351
|
requirements: []
|
353
352
|
rubyforge_project:
|
354
353
|
rubygems_version: 1.8.25
|