cucumber-chef 2.0.7 → 2.1.0.rc.0
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/README.md +1 -1
- data/Rakefile +1 -1
- data/bin/cc-knife +2 -5
- data/bin/cc-push +50 -26
- data/bin/cc-server +9 -10
- data/bin/cucumber-chef +65 -71
- data/chef_repo/cookbooks/cucumber-chef/attributes/default.rb +1 -1
- data/chef_repo/cookbooks/cucumber-chef/recipes/default.rb +1 -1
- data/chef_repo/cookbooks/cucumber-chef/recipes/lxc.rb +34 -36
- data/chef_repo/cookbooks/cucumber-chef/recipes/test_lab.rb +64 -47
- data/chef_repo/cookbooks/cucumber-chef/templates/default/solrconfig.erb +650 -0
- data/cucumber-chef.gemspec +5 -5
- data/lib/cucumber/chef/bootstrap.rb +10 -10
- data/lib/cucumber/chef/config.rb +15 -15
- data/lib/cucumber/chef/helpers/chef_client.rb +88 -14
- data/lib/cucumber/chef/helpers/chef_server.rb +39 -16
- data/lib/cucumber/chef/helpers/command.rb +28 -12
- data/lib/cucumber/chef/helpers/container.rb +29 -26
- data/lib/cucumber/chef/helpers/minitest.rb +1 -1
- data/lib/cucumber/chef/helpers/server.rb +37 -18
- data/lib/cucumber/chef/helpers/test_lab.rb +1 -1
- data/lib/cucumber/chef/helpers/utility.rb +23 -3
- data/lib/cucumber/chef/helpers.rb +10 -8
- data/lib/cucumber/chef/provisioner.rb +22 -21
- data/lib/cucumber/chef/steps/chef_steps.rb +1 -1
- data/lib/cucumber/chef/steps/minitest_steps.rb +3 -3
- data/lib/cucumber/chef/steps/provision_steps.rb +7 -6
- data/lib/cucumber/chef/steps/ssh_steps.rb +31 -2
- data/lib/cucumber/chef/steps.rb +1 -1
- data/lib/cucumber/chef/templates/cucumber/cc-hooks.rb +111 -0
- data/lib/cucumber/chef/templates/cucumber/env.rb +0 -87
- data/lib/cucumber/chef/templates/cucumber/readme-environments.erb +1 -0
- data/lib/cucumber/chef/templates/cucumber/readme-roles.erb +1 -1
- data/lib/cucumber/chef/templates/cucumber-chef/config-rb.erb +5 -0
- data/lib/cucumber/chef/test_lab.rb +70 -23
- data/lib/cucumber/chef/utility.rb +121 -31
- data/lib/cucumber/chef/version.rb +2 -2
- data/lib/cucumber/chef.rb +1 -1
- data/lib/cucumber-chef.rb +1 -1
- data/spec/cucumber/chef/config_spec.rb +1 -1
- data/spec/cucumber/chef/provisioner_spec.rb +1 -1
- data/spec/cucumber/chef/test_lab_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +8 -5
data/README.md
CHANGED
@@ -26,7 +26,7 @@ Cucumber-Chef - A test driven infrastructure system
|
|
26
26
|
|
27
27
|
* Author: Stephen Nelson-Smith <stephen@atalanta-systems.com>
|
28
28
|
* Author: Zachary Patten <zachary@jovelabs.com>
|
29
|
-
* Copyright: Copyright (c) 2011-
|
29
|
+
* Copyright: Copyright (c) 2011-2013 Atalanta Systems Ltd
|
30
30
|
* License: Apache License, Version 2.0
|
31
31
|
|
32
32
|
Licensed under the Apache License, Version 2.0 (the "License");
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# Author: Stephen Nelson-Smith <stephen@atalanta-systems.com>
|
4
4
|
# Author: Zachary Patten <zachary@jovelabs.com>
|
5
|
-
# Copyright: Copyright (c) 2011-
|
5
|
+
# Copyright: Copyright (c) 2011-2013 Atalanta Systems Ltd
|
6
6
|
# License: Apache License, Version 2.0
|
7
7
|
#
|
8
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
data/bin/cc-knife
CHANGED
@@ -1,21 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'cucumber-chef'
|
3
3
|
|
4
|
-
$logger = ZTK::Logger.new(Cucumber::Chef.log_file)
|
5
|
-
Cucumber::Chef.is_rc? and ($logger.level = ZTK::Logger::DEBUG)
|
6
|
-
|
7
4
|
# if we have bundler binstubs use that; otherwise attempt to detect
|
8
5
|
knife = (Cucumber::Chef.locate(:file, "bin", "knife") rescue nil)
|
9
6
|
knife = "/usr/bin/env knife" unless knife
|
10
7
|
|
11
8
|
message = "cc-knife v#{Cucumber::Chef::VERSION}"
|
12
9
|
puts(message)
|
13
|
-
|
10
|
+
Cucumber::Chef.logger.info { message }
|
14
11
|
|
15
12
|
Cucumber::Chef::Config.load
|
16
13
|
if (test_lab = Cucumber::Chef::TestLab.new) && (test_lab.labs_running.count > 0)
|
17
14
|
|
18
|
-
knife_rb = Cucumber::Chef.
|
15
|
+
knife_rb = Cucumber::Chef.knife_rb
|
19
16
|
if File.exists?(knife_rb)
|
20
17
|
command = [knife, ARGV, "--server-url http://#{test_lab.labs_running.first.public_ip_address}:4000", "--config #{knife_rb}", "2>&1"].flatten.compact.join(" ")
|
21
18
|
puts(command)
|
data/bin/cc-push
CHANGED
@@ -1,38 +1,62 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'cucumber-chef'
|
3
3
|
|
4
|
-
def
|
5
|
-
|
6
|
-
|
4
|
+
def run_remote(command)
|
5
|
+
$logger.info { "cc-push(run_remote): '#{command}'" }
|
6
|
+
$test_lab.ssh.exec(command)
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
puts(message)
|
14
|
-
$logger.info { message }
|
9
|
+
def run_local(command)
|
10
|
+
$logger.info { "cc-push(run_local): '#{command}'" }
|
11
|
+
%x(#{command})
|
12
|
+
end
|
15
13
|
|
16
|
-
Cucumber::Chef
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
@ssh.config.user = "ubuntu"
|
21
|
-
@ssh.config.keys = Cucumber::Chef.locate(:file, ".cucumber-chef", "id_rsa-#{@ssh.config.user}")
|
14
|
+
tag = Cucumber::Chef.tag("cc-push")
|
15
|
+
puts(tag)
|
16
|
+
Cucumber::Chef.load_config(tag)
|
17
|
+
$logger = Cucumber::Chef.logger
|
22
18
|
|
19
|
+
if ($test_lab = Cucumber::Chef::TestLab.new) && ($test_lab.labs_running.count > 0)
|
23
20
|
gem_name = "cucumber-chef-#{Cucumber::Chef::VERSION}.gem"
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
21
|
+
gem_path = File.join(Cucumber::Chef.root, gem_name)
|
22
|
+
|
23
|
+
$logger.info { "gem_name == '#{gem_name}'" }
|
24
|
+
$logger.info { "gem_path == '#{gem_path}'" }
|
25
|
+
|
26
|
+
if !File.exists?(gem_path)
|
27
|
+
puts
|
28
|
+
puts("To build cucumber-chef and install the gem in to the test lab, execute:")
|
29
|
+
puts
|
30
|
+
puts [ "cd #{Cucumber::Chef.root}", "gem build cucumber-chef.gemspec", "cd #{Dir.pwd}", "bundle exec cc-push" ].join(" ; ")
|
31
|
+
puts
|
32
|
+
else
|
33
|
+
local_file = File.join(Cucumber::Chef.root, gem_name)
|
34
|
+
remote_file = File.join("/", "home", $test_lab.ssh.config.user, gem_name)
|
35
|
+
$logger.info { "#{local_file} -> #{$test_lab.ssh.config.user}@#{$test_lab.labs_running.first.public_ip_address}:#{remote_file}" }
|
36
|
+
|
37
|
+
$test_lab.ssh.upload(local_file, remote_file)
|
38
|
+
FileUtils.rm_f(File.join(Cucumber::Chef.root, "*.gem"))
|
39
|
+
|
40
|
+
run_remote(<<-EOH
|
41
|
+
sudo /bin/bash -c '
|
42
|
+
cd #{File.dirname(remote_file)}
|
43
|
+
|
44
|
+
gem uninstall ztk --all --ignore-dependencies --executables --verbose --backtrace
|
45
|
+
gem cleanup ztk --verbose --backtrace
|
46
|
+
gem install ztk --verbose --backtrace
|
47
|
+
|
48
|
+
ls -la | grep 'cucumber-chef-'
|
49
|
+
gem uninstall cucumber-chef --all --ignore-dependencies --executables --verbose --backtrace
|
50
|
+
rm -fv /usr/lib/ruby/gems/1.8/cache/#{gem_name}
|
51
|
+
gem cleanup cucumber-chef --verbose --backtrace
|
52
|
+
gem install #{gem_name} --local --verbose --backtrace
|
53
|
+
rm -fv /home/#{$test_lab.ssh.config.user}/*.gem'
|
54
|
+
EOH
|
55
|
+
)
|
56
|
+
File.exists?(gem_path) && File.delete(gem_path)
|
57
|
+
end
|
34
58
|
|
35
59
|
else
|
36
|
-
puts("No
|
60
|
+
puts("No run_remotening cucumber-chef test labs to connect to!")
|
37
61
|
exit(1)
|
38
62
|
end
|
data/bin/cc-server
CHANGED
@@ -27,24 +27,23 @@ class FrontObject
|
|
27
27
|
include Cucumber::Chef::Helpers
|
28
28
|
|
29
29
|
def initialize
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
$logger =
|
34
|
-
Cucumber::Chef.is_rc? and ($logger.level = ZTK::Logger::DEBUG)
|
35
|
-
|
36
|
-
puts("cc-server v#{Cucumber::Chef::VERSION}")
|
30
|
+
tag = Cucumber::Chef.tag("cc-server")
|
31
|
+
puts(" * #{tag}")
|
32
|
+
Cucumber::Chef.load_config(tag)
|
33
|
+
$logger = Cucumber::Chef.logger
|
37
34
|
end
|
38
35
|
|
39
36
|
def shutdown
|
40
37
|
DRb.stop_service
|
41
38
|
end
|
42
39
|
|
43
|
-
|
40
|
+
def logger
|
41
|
+
$logger
|
42
|
+
end
|
44
43
|
|
45
|
-
|
44
|
+
end
|
46
45
|
|
47
|
-
list = %w( deny all
|
46
|
+
list = %w( deny all )
|
48
47
|
ARGV[0] and (list += [ 'allow', ARGV[0] ])
|
49
48
|
acl = ACL.new(list)
|
50
49
|
|
data/bin/cucumber-chef
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
require 'thor'
|
4
4
|
require 'cucumber-chef'
|
5
5
|
|
6
|
+
# $logger = Cucumber::Chef.logger
|
7
|
+
|
6
8
|
class CucumberChef < Thor
|
7
9
|
include Thor::Actions
|
8
10
|
|
@@ -39,9 +41,11 @@ class CucumberChef < Thor
|
|
39
41
|
"example_feature.erb" => "features/#{project}/#{project}.feature",
|
40
42
|
"example_steps.erb" => "features/#{project}/step_definitions/#{project}_steps.rb",
|
41
43
|
"env.rb" => "features/support/env.rb",
|
44
|
+
"cc-hooks.rb" => "features/support/cc-hooks.rb",
|
42
45
|
"readme-data_bags.erb" => "features/support/data_bags/README",
|
43
46
|
"readme-roles.erb" => "features/support/roles/README",
|
44
|
-
"readme-keys.erb" => "features/support/keys/README"
|
47
|
+
"readme-keys.erb" => "features/support/keys/README",
|
48
|
+
"readme-environments.erb" => "features/support/environments/README"
|
45
49
|
}
|
46
50
|
|
47
51
|
templates.each do |source, destination|
|
@@ -50,29 +54,12 @@ class CucumberChef < Thor
|
|
50
54
|
end
|
51
55
|
|
52
56
|
def load_config
|
57
|
+
tag = Cucumber::Chef.tag("cucumber-chef")
|
58
|
+
puts(set_color(tag, :green, true))
|
59
|
+
Cucumber::Chef.load_config(tag)
|
60
|
+
$logger = Cucumber::Chef.logger
|
53
61
|
|
54
|
-
|
55
|
-
if ( !chef_repo || ( !File.exists?(chef_repo) || !File.directory?(chef_repo) ) )
|
56
|
-
fatal("It does not look like you are inside a chef-repo! Please relocate to one and execute your command again!")
|
57
|
-
exit(255)
|
58
|
-
end
|
59
|
-
|
60
|
-
$logger = ZTK::Logger.new(Cucumber::Chef.log_file)
|
61
|
-
Cucumber::Chef.is_rc? and ($logger.level = ZTK::Logger::DEBUG)
|
62
|
-
|
63
|
-
message = "cucumber-chef v#{Cucumber::Chef::VERSION}"
|
64
|
-
puts(set_color(message, :green, true))
|
65
|
-
|
66
|
-
$logger.info { "================================================================================" }
|
67
|
-
$logger.info { message }
|
68
|
-
$logger.info { "UNAME: %s" % %x( uname -a ).chomp.strip }
|
69
|
-
$logger.info { "Ruby Version: #{RUBY_VERSION}" }
|
70
|
-
$logger.info { "Ruby Patch Level: #{RUBY_PATCHLEVEL}" }
|
71
|
-
$logger.info { "Ruby Platform: #{RUBY_PLATFORM}" }
|
72
|
-
$logger.info { "Ruby Engine: #{RUBY_ENGINE}" }
|
73
|
-
$logger.info { "================================================================================" }
|
74
|
-
|
75
|
-
@options.test? ? Cucumber::Chef::Config.test : Cucumber::Chef::Config.load
|
62
|
+
@options.test? and Cucumber::Chef::Config.test
|
76
63
|
end
|
77
64
|
|
78
65
|
def fatal(message)
|
@@ -218,21 +205,13 @@ class CucumberChef < Thor
|
|
218
205
|
puts(set_color("...BOOM!", :red, true))
|
219
206
|
puts
|
220
207
|
|
221
|
-
ssh
|
222
|
-
ssh.
|
223
|
-
ssh.config.user = "ubuntu"
|
224
|
-
ssh.config.keys = Cucumber::Chef.locate(:file, ".cucumber-chef", "id_rsa-#{ssh.config.user}")
|
225
|
-
ssh.exec("nohup sudo pkill -9 -f cc-server")
|
226
|
-
ssh.exec("nohup sudo BACKGROUND=yes cc-server #{Cucumber::Chef.external_ip}")
|
208
|
+
test_lab.ssh.exec("nohup sudo pkill -9 -f cc-server")
|
209
|
+
test_lab.ssh.exec("nohup sudo BACKGROUND=yes cc-server #{Cucumber::Chef.external_ip}")
|
227
210
|
Cucumber::Chef.spinner do
|
228
211
|
ZTK::TCPSocketCheck.new(:host => test_lab.labs_running.first.public_ip_address, :port => 8787, :data => "\n\n").wait
|
229
212
|
end
|
230
|
-
|
231
|
-
|
232
|
-
test_lab_drb ||= DRbObject.new_with_uri("druby://#{test_lab.labs_running.first.public_ip_address}:8787")
|
233
|
-
test_lab_drb and DRb.start_service
|
234
|
-
test_lab_drb.servers = Hash.new(nil)
|
235
|
-
test_lab_drb.server_destroy(container)
|
213
|
+
test_lab.drb.servers = Hash.new(nil)
|
214
|
+
test_lab.drb.server_destroy(container)
|
236
215
|
else
|
237
216
|
puts
|
238
217
|
puts(set_color("Whew! That was close!", :green, true))
|
@@ -249,6 +228,19 @@ class CucumberChef < Thor
|
|
249
228
|
fatal(e)
|
250
229
|
end
|
251
230
|
|
231
|
+
################################################################################
|
232
|
+
|
233
|
+
desc "test", "depreciated"
|
234
|
+
def test
|
235
|
+
puts
|
236
|
+
puts(set_color("The test task is depreciated! You should execute cucumber directly.", :red, true))
|
237
|
+
puts
|
238
|
+
|
239
|
+
rescue Cucumber::Chef::Error => e
|
240
|
+
$logger.fatal { e.backtrace.join("\n") }
|
241
|
+
fatal(e)
|
242
|
+
end
|
243
|
+
|
252
244
|
################################################################################
|
253
245
|
|
254
246
|
desc "up", "Startup the cucumber-chef test lab"
|
@@ -296,28 +288,13 @@ class CucumberChef < Thor
|
|
296
288
|
|
297
289
|
puts
|
298
290
|
if (test_lab = Cucumber::Chef::TestLab.new) && (test_lab.labs_running.count > 0)
|
299
|
-
ssh = ZTK::SSH.new
|
300
|
-
|
301
291
|
if args.size == 0
|
302
|
-
ssh.config.host_name = test_lab.labs_running.first.public_ip_address
|
303
|
-
ssh.config.user = "ubuntu"
|
304
|
-
ssh.config.keys = Cucumber::Chef.locate(:file, ".cucumber-chef", "id_rsa-#{ssh.config.user}")
|
305
|
-
|
306
292
|
puts([set_color("Attempting SSH connection to cucumber-chef '", :blue, true), set_color("test lab", :cyan, true), set_color("'...", :blue, true)].join)
|
307
|
-
ssh.console
|
293
|
+
test_lab.ssh.console
|
308
294
|
else
|
309
295
|
container = args[0]
|
310
|
-
|
311
|
-
ssh.config.proxy_host_name = test_lab.labs_running.first.public_ip_address
|
312
|
-
ssh.config.proxy_user = "ubuntu"
|
313
|
-
ssh.config.proxy_keys = Cucumber::Chef.locate(:file, ".cucumber-chef", "id_rsa-#{ssh.config.proxy_user}")
|
314
|
-
|
315
|
-
ssh.config.host_name = container
|
316
|
-
ssh.config.user = "root"
|
317
|
-
ssh.config.keys = Cucumber::Chef.locate(:file, ".cucumber-chef", "id_rsa-#{ssh.config.proxy_user}")
|
318
|
-
|
319
296
|
puts([set_color("Attempting SSH connection to cucumber-chef container '", :blue, true), set_color(container, :cyan, true), set_color("'...", :blue, true)].join)
|
320
|
-
|
297
|
+
test_lab.proxy_ssh(container).console
|
321
298
|
end
|
322
299
|
|
323
300
|
else
|
@@ -330,6 +307,39 @@ class CucumberChef < Thor
|
|
330
307
|
fatal(e)
|
331
308
|
end
|
332
309
|
|
310
|
+
################################################################################
|
311
|
+
|
312
|
+
desc "log", "Streams the cucumber-chef local and test lab logs to the terminal."
|
313
|
+
def log
|
314
|
+
load_config
|
315
|
+
|
316
|
+
if ($test_lab = Cucumber::Chef::TestLab.new) && ($test_lab.labs_running.count > 0)
|
317
|
+
$tail_thread_remote = Thread.new do
|
318
|
+
$test_lab.ssh.exec("tail -n 0 -f /home/#{$test_lab.ssh.config.user}/.cucumber-chef/cucumber-chef.log")
|
319
|
+
|
320
|
+
Kernel.at_exit do
|
321
|
+
$test_lab.ssh.close
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
log_file = File.open(Cucumber::Chef.log_file, "r")
|
326
|
+
log_file.seek(0, ::IO::SEEK_END)
|
327
|
+
loop do
|
328
|
+
if !(data = (log_file.readline rescue nil)).nil?
|
329
|
+
print(data)
|
330
|
+
else
|
331
|
+
sleep(1)
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
$tail_thread_remote.join
|
336
|
+
end
|
337
|
+
|
338
|
+
Kernel.at_exit do
|
339
|
+
$tail_thread_remote.kill
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
333
343
|
################################################################################
|
334
344
|
|
335
345
|
desc "diagnose <container>", "Provide diagnostics from the chef-client on the specified container."
|
@@ -341,29 +351,19 @@ class CucumberChef < Thor
|
|
341
351
|
|
342
352
|
puts
|
343
353
|
if (test_lab = Cucumber::Chef::TestLab.new) && (test_lab.labs_running.count > 0)
|
344
|
-
ssh = ZTK::SSH.new
|
345
|
-
|
346
|
-
ssh.config.proxy_host_name = test_lab.labs_running.first.public_ip_address
|
347
|
-
ssh.config.proxy_user = "ubuntu"
|
348
|
-
ssh.config.proxy_keys = Cucumber::Chef.locate(:file, ".cucumber-chef", "id_rsa-#{ssh.config.proxy_user}")
|
349
|
-
|
350
|
-
ssh.config.host_name = container
|
351
|
-
ssh.config.user = "root"
|
352
|
-
ssh.config.keys = Cucumber::Chef.locate(:file, ".cucumber-chef", "id_rsa-#{ssh.config.proxy_user}")
|
353
|
-
|
354
354
|
puts([set_color("Attempting to collect diagnostic information on cucumber-chef container '", :blue, true), set_color(container, :cyan, true), set_color("'...", :blue, true)].join)
|
355
355
|
if @options.strace?
|
356
356
|
puts
|
357
357
|
puts("chef-stacktrace.out:")
|
358
358
|
puts(set_color("============================================================================", :bold))
|
359
|
-
|
359
|
+
test_lab.proxy_ssh(container).exec("[[ -e /var/chef/cache/chef-stacktrace.out ]] && cat /var/chef/cache/chef-stacktrace.out")
|
360
360
|
print("\n")
|
361
361
|
end
|
362
362
|
if @options.log?
|
363
363
|
puts
|
364
364
|
puts("chef.log:")
|
365
365
|
puts(set_color("============================================================================", :bold))
|
366
|
-
|
366
|
+
test_lab.proxy_ssh(container).exec("[[ -e /var/log/chef/client.log ]] && tail -n #{@options.lines} /var/log/chef/client.log")
|
367
367
|
end
|
368
368
|
end
|
369
369
|
puts
|
@@ -397,16 +397,10 @@ class CucumberChef < Thor
|
|
397
397
|
|
398
398
|
puts
|
399
399
|
if (test_lab = Cucumber::Chef::TestLab.new) && (test_lab.labs_running.count > 0)
|
400
|
-
ssh = ZTK::SSH.new
|
401
|
-
|
402
|
-
ssh.config.host_name = test_lab.labs_running.first.public_ip_address
|
403
|
-
ssh.config.user = "ubuntu"
|
404
|
-
ssh.config.keys = Cucumber::Chef.locate(:file, ".cucumber-chef", "id_rsa-#{ssh.config.user}")
|
405
|
-
|
406
400
|
puts(set_color("Getting container processes from cucumber-chef test lab...", :blue, true))
|
407
401
|
puts
|
408
402
|
puts(set_color("============================================================================", :bold))
|
409
|
-
ssh.exec("lxc-ps --lxc -- #{args.join(" ")}")
|
403
|
+
test_lab.ssh.exec("lxc-ps --lxc -- #{args.join(" ")}")
|
410
404
|
print("\n")
|
411
405
|
end
|
412
406
|
puts
|
@@ -1,7 +1,7 @@
|
|
1
1
|
################################################################################
|
2
2
|
#
|
3
3
|
# Author: Zachary Patten <zachary@jovelabs.com>
|
4
|
-
# Copyright: Copyright (c) 2011-
|
4
|
+
# Copyright: Copyright (c) 2011-2013 Atalanta Systems Ltd
|
5
5
|
# License: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -1,7 +1,7 @@
|
|
1
1
|
################################################################################
|
2
2
|
#
|
3
3
|
# Author: Zachary Patten <zachary@jovelabs.com>
|
4
|
-
# Copyright: Copyright (c) 2011-
|
4
|
+
# Copyright: Copyright (c) 2011-2013 Atalanta Systems Ltd
|
5
5
|
# License: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -1,7 +1,7 @@
|
|
1
1
|
################################################################################
|
2
2
|
#
|
3
3
|
# Author: Zachary Patten <zachary@jovelabs.com>
|
4
|
-
# Copyright: Copyright (c) 2011-
|
4
|
+
# Copyright: Copyright (c) 2011-2013 Atalanta Systems Ltd
|
5
5
|
# License: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -267,49 +267,47 @@ directory "create lxc configuration directory" do
|
|
267
267
|
not_if { File.exists?("/etc/lxc") && File.directory?("/etc/lxc") }
|
268
268
|
end
|
269
269
|
|
270
|
-
|
271
|
-
#
|
272
|
-
|
273
|
-
|
274
|
-
arch = (%x( arch ).include?("i686") ? "i386" : "amd64")
|
270
|
+
# # load the chef client into our distro lxc cache
|
271
|
+
# install_chef_sh = "/tmp/install-chef.sh"
|
272
|
+
# distros = { "ubuntu" => [ "lucid", "maverick", "natty", "oneiric", "precise" ] }
|
273
|
+
# arch = (%x( arch ).include?("i686") ? "i386" : "amd64")
|
275
274
|
|
276
|
-
template "create lxc initializer container configuration" do
|
277
|
-
|
278
|
-
|
275
|
+
# template "create lxc initializer container configuration" do
|
276
|
+
# path "/etc/lxc/initializer"
|
277
|
+
# source "lxc-initializer-config.erb"
|
279
278
|
|
280
|
-
|
281
|
-
end
|
279
|
+
# not_if { File.exists?("/etc/lxc/initializer") }
|
280
|
+
# end
|
282
281
|
|
283
|
-
distros.each do |distro, releases|
|
284
|
-
|
285
|
-
|
286
|
-
|
282
|
+
# distros.each do |distro, releases|
|
283
|
+
# releases.each do |release|
|
284
|
+
# cache_rootfs = File.join("/", "var", "cache", "lxc", release, "rootfs-#{arch}")
|
285
|
+
# initializer_rootfs = File.join("/", "var", "lib", "lxc", "initializer", "rootfs")
|
287
286
|
|
288
|
-
|
289
|
-
|
287
|
+
# execute "create the lxc initializer container for #{distro}/#{release}" do
|
288
|
+
# command "lxc-create -n initializer -f /etc/lxc/initializer -t #{distro} -- -r #{release}"
|
290
289
|
|
291
|
-
|
292
|
-
|
290
|
+
# not_if { File.exists?(cache_rootfs) && File.directory?(cache_rootfs) }
|
291
|
+
# end
|
293
292
|
|
294
|
-
|
295
|
-
|
293
|
+
# execute "destroy the lxc initializer container for #{distro}/#{release}" do
|
294
|
+
# command "lxc-destroy -n initializer"
|
296
295
|
|
297
|
-
|
298
|
-
|
296
|
+
# only_if { File.exists?(initializer_rootfs) && File.directory?(initializer_rootfs) }
|
297
|
+
# end
|
299
298
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
299
|
+
# template "create opscode omnibus installer in lxc container cache for #{distro}/#{release}" do
|
300
|
+
# path "#{cache_rootfs}#{install_chef_sh}"
|
301
|
+
# source "lxc-install-chef.erb"
|
302
|
+
# mode "0755"
|
304
303
|
|
305
|
-
|
306
|
-
|
304
|
+
# not_if { File.exists?(File.join(cache_rootfs, install_chef_sh)) }
|
305
|
+
# end
|
307
306
|
|
308
|
-
|
309
|
-
|
307
|
+
# execute "install chef-client using omnibus in lxc container cache for #{distro}/#{release}" do
|
308
|
+
# command "chroot #{cache_rootfs} /bin/bash -c '#{install_chef_sh}'"
|
310
309
|
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
end
|
315
|
-
=end
|
310
|
+
# not_if { File.exists?(File.join(cache_rootfs, "opt", "opscode", "bin", "chef-client")) }
|
311
|
+
# end
|
312
|
+
# end
|
313
|
+
# end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
################################################################################
|
2
2
|
#
|
3
3
|
# Author: Zachary Patten <zachary@jovelabs.com>
|
4
|
-
# Copyright: Copyright (c) 2011-
|
4
|
+
# Copyright: Copyright (c) 2011-2013 Atalanta Systems Ltd
|
5
5
|
# License: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -19,57 +19,14 @@
|
|
19
19
|
################################################################################
|
20
20
|
|
21
21
|
|
22
|
-
%w( build-essential wget chkconfig ruby-full ruby-dev libxml2-dev libxslt1-dev ).each do |p|
|
23
|
-
package p
|
24
|
-
end
|
25
|
-
|
26
|
-
bash "install rubygems" do
|
27
|
-
code <<-EOH
|
28
|
-
cd /tmp
|
29
|
-
wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.19.tgz
|
30
|
-
tar zxf rubygems-1.8.19.tgz
|
31
|
-
cd rubygems-1.8.19
|
32
|
-
ruby setup.rb --no-format-executable
|
33
|
-
EOH
|
34
|
-
end
|
35
|
-
|
36
|
-
gem_package "cucumber-chef" do
|
37
|
-
gem_binary("/usr/bin/gem")
|
38
|
-
|
39
|
-
version(node['cucumber_chef']['version'])
|
40
|
-
|
41
|
-
if node['cucumber_chef']['prerelease']
|
42
|
-
options("--prerelease")
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
%w( rspec ).each do |g|
|
47
|
-
gem_package g do
|
48
|
-
gem_binary("/usr/bin/gem")
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
22
|
################################################################################
|
53
|
-
#
|
23
|
+
# SYSTEM TWEAKS
|
54
24
|
################################################################################
|
55
|
-
service "chef-client"
|
56
25
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
notifies :restart, "service[chef-client]"
|
61
|
-
|
62
|
-
only_if do
|
63
|
-
%x( cat /etc/chef/client.rb | grep "log_level :info" )
|
64
|
-
($? == 0)
|
65
|
-
end
|
26
|
+
%w( build-essential wget chkconfig ruby-full ruby-dev libxml2-dev libxslt1-dev ).each do |p|
|
27
|
+
package p
|
66
28
|
end
|
67
29
|
|
68
|
-
|
69
|
-
################################################################################
|
70
|
-
# SYSTEM TWEAKS
|
71
|
-
################################################################################
|
72
|
-
|
73
30
|
%w( root ubuntu ).each do |user|
|
74
31
|
home_dir = (user == "root" ? "/#{user}" : "/home/#{user}")
|
75
32
|
|
@@ -146,3 +103,63 @@ template "install cucumber-chef motd" do
|
|
146
103
|
|
147
104
|
not_if { File.exists?("/etc/motd") && !File.symlink?("/etc/motd") }
|
148
105
|
end
|
106
|
+
|
107
|
+
|
108
|
+
################################################################################
|
109
|
+
# RUBY
|
110
|
+
################################################################################
|
111
|
+
bash "install rubygems" do
|
112
|
+
code <<-EOH
|
113
|
+
cd /tmp
|
114
|
+
wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.19.tgz
|
115
|
+
tar zxf rubygems-1.8.19.tgz
|
116
|
+
cd rubygems-1.8.19
|
117
|
+
ruby setup.rb --no-format-executable
|
118
|
+
EOH
|
119
|
+
end
|
120
|
+
|
121
|
+
gem_package "cucumber-chef" do
|
122
|
+
gem_binary("/usr/bin/gem")
|
123
|
+
|
124
|
+
version(node['cucumber_chef']['version'])
|
125
|
+
|
126
|
+
if node['cucumber_chef']['prerelease']
|
127
|
+
options("--prerelease")
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
%w( rspec ).each do |g|
|
132
|
+
gem_package g do
|
133
|
+
gem_binary("/usr/bin/gem")
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
################################################################################
|
139
|
+
# CHEF-CLIENT
|
140
|
+
################################################################################
|
141
|
+
service "chef-client"
|
142
|
+
|
143
|
+
execute "set chef-client logging to debug" do
|
144
|
+
command "sed -i \"s/log_level :info/log_level :debug/\" /etc/chef/client.rb"
|
145
|
+
|
146
|
+
notifies :restart, "service[chef-client]"
|
147
|
+
|
148
|
+
only_if do
|
149
|
+
%x( cat /etc/chef/client.rb | grep "log_level :info" )
|
150
|
+
($? == 0)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
################################################################################
|
156
|
+
# CHEF-SOLR / APACHE SOLR
|
157
|
+
################################################################################
|
158
|
+
|
159
|
+
template "install custom solr config" do
|
160
|
+
path "/var/lib/chef/solr/conf/solrconfig.xml"
|
161
|
+
source "solrconfig.erb"
|
162
|
+
owner "chef"
|
163
|
+
group "chef"
|
164
|
+
mode "0644"
|
165
|
+
end
|