cucumber-chef 3.0.0.rc.5 → 3.0.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/WIKI.md +77 -0
- data/bin/cucumber-chef +3 -48
- data/chef_repo/cookbooks/cucumber-chef/recipes/test_lab.rb +39 -29
- data/cucumber-chef.gemspec +1 -1
- data/lib/cucumber/chef/client.rb +21 -23
- data/lib/cucumber/chef/config.rb +12 -10
- data/lib/cucumber/chef/containers.rb +9 -6
- data/lib/cucumber/chef/provider.rb +4 -0
- data/lib/cucumber/chef/providers/vagrant.rb +19 -6
- data/lib/cucumber/chef/provisioner.rb +60 -62
- data/lib/cucumber/chef/templates/bootstrap/ubuntu-precise-omnibus.erb +64 -48
- data/lib/cucumber/chef/templates/cucumber-chef/Vagrantfile.erb +32 -0
- data/lib/cucumber/chef/templates/cucumber-chef/config-rb.erb +28 -38
- data/lib/cucumber/chef/utility.rb +13 -3
- data/lib/cucumber/chef/version.rb +1 -1
- metadata +7 -8
- data/chef_repo/cookbooks/cucumber-chef/templates/default/solrconfig.erb +0 -650
- data/lib/cucumber/chef/templates/bootstrap/ubuntu-precise-apt.erb +0 -213
data/WIKI.md
CHANGED
@@ -314,6 +314,83 @@ Displays information on the status of the current test lab containers:
|
|
314
314
|
| mysql-test-1 | true | ubuntu | 192.168.0.220 | 00:00:5e:ea:fe:28 | Chef: 10.18.2 | true |
|
315
315
|
+----------------------+-------+--------+---------------+-------------------+---------------+---------+
|
316
316
|
|
317
|
+
## `cucumber-chef displayconfig`
|
318
|
+
|
319
|
+
Display various configuration information:
|
320
|
+
|
321
|
+
$ cucumber-chef displayconfig
|
322
|
+
cucumber-chef v3.0.0.rc.5
|
323
|
+
--------------------------------------------------------------------------------
|
324
|
+
---
|
325
|
+
:mode: :user
|
326
|
+
:prerelease: true
|
327
|
+
:user: zpatten
|
328
|
+
:artifacts:
|
329
|
+
chef-client-log: /var/log/chef/client.log
|
330
|
+
chef-client-stacktrace: /var/chef/cache/chef-stacktrace.out
|
331
|
+
:chef:
|
332
|
+
:version: 10.24.0
|
333
|
+
:default_password: p@ssw0rd1
|
334
|
+
:render_client_rb: true
|
335
|
+
:cookbook_paths:
|
336
|
+
- cookbooks
|
337
|
+
- site-cookbooks
|
338
|
+
:test_lab:
|
339
|
+
:hostname: cucumber-chef
|
340
|
+
:tld: test-lab
|
341
|
+
:command_timeout: 1800
|
342
|
+
:provider: :vagrant
|
343
|
+
:aws:
|
344
|
+
:bootstrap_user: ubuntu
|
345
|
+
:lab_user: cucumber-chef
|
346
|
+
:lxc_user: root
|
347
|
+
:ssh:
|
348
|
+
:lab_port: 22
|
349
|
+
:lxc_port: 22
|
350
|
+
:ubuntu_release: precise
|
351
|
+
:aws_instance_arch: i386
|
352
|
+
:aws_instance_disk_store: ebs
|
353
|
+
:aws_instance_type: c1.medium
|
354
|
+
:aws_security_group: cucumber-chef
|
355
|
+
:identity_file:
|
356
|
+
:aws_access_key_id:
|
357
|
+
:aws_secret_access_key:
|
358
|
+
:aws_ssh_key_id:
|
359
|
+
:region: us-west-2
|
360
|
+
:availability_zone: us-west-2a
|
361
|
+
:vagrant:
|
362
|
+
:bootstrap_user: vagrant
|
363
|
+
:lab_user: cucumber-chef
|
364
|
+
:lxc_user: root
|
365
|
+
:ssh:
|
366
|
+
:lab_ip: 192.168.33.10
|
367
|
+
:lab_port: 22
|
368
|
+
:lxc_port: 22
|
369
|
+
:cpus: 4
|
370
|
+
:memory: 4096
|
371
|
+
:identity_file: /home/zpatten/.vagrant.d/insecure_private_key
|
372
|
+
|
373
|
+
--------------------------------------------------------------------------------
|
374
|
+
root_dir = "/home/zpatten/code/cc-chef-repo/vendor/checkouts/cucumber-chef"
|
375
|
+
home_dir = "/home/zpatten/code/cc-chef-repo/.cucumber-chef"
|
376
|
+
log_file = "/home/zpatten/code/cc-chef-repo/.cucumber-chef/cucumber-chef.log"
|
377
|
+
artifacts_dir = "/home/zpatten/code/cc-chef-repo/.cucumber-chef/vagrant/artifacts"
|
378
|
+
config_rb = "/home/zpatten/code/cc-chef-repo/.cucumber-chef/config.rb"
|
379
|
+
labfile = "/home/zpatten/code/cc-chef-repo/Labfile"
|
380
|
+
chef_repo = "/home/zpatten/code/cc-chef-repo"
|
381
|
+
chef_user = "zpatten"
|
382
|
+
chef_identity = "/home/zpatten/code/cc-chef-repo/.cucumber-chef/vagrant/zpatten.pem"
|
383
|
+
bootstrap_user = "vagrant"
|
384
|
+
bootstrap_user_home_dir = "/home/vagrant"
|
385
|
+
bootstrap_identity = "/home/zpatten/.vagrant.d/insecure_private_key"
|
386
|
+
lab_user = "cucumber-chef"
|
387
|
+
lab_user_home_dir = "/home/cucumber-chef"
|
388
|
+
lab_identity = "/home/zpatten/code/cc-chef-repo/.cucumber-chef/vagrant/id_rsa-cucumber-chef"
|
389
|
+
lxc_user = "root"
|
390
|
+
lxc_user_home_dir = "/root"
|
391
|
+
lxc_identity = "/home/zpatten/code/cc-chef-repo/.cucumber-chef/vagrant/id_rsa-root"
|
392
|
+
chef_pre_11 = true
|
393
|
+
--------------------------------------------------------------------------------
|
317
394
|
|
318
395
|
# RESOURCES
|
319
396
|
|
data/bin/cucumber-chef
CHANGED
@@ -18,8 +18,6 @@ class CucumberChef < Thor
|
|
18
18
|
|
19
19
|
CucumberChef.source_root(source_dir)
|
20
20
|
|
21
|
-
get_aws_credentials
|
22
|
-
|
23
21
|
templates = {
|
24
22
|
"config-rb.erb" => "config.rb"
|
25
23
|
}
|
@@ -70,51 +68,6 @@ class CucumberChef < Thor
|
|
70
68
|
exit(255)
|
71
69
|
end
|
72
70
|
|
73
|
-
def get_aws_credentials
|
74
|
-
say "OHAI!", :magenta
|
75
|
-
puts
|
76
|
-
say "Cucumber-Chef uses Amazon Web Services to build a test lab for automated infrastructure testing."
|
77
|
-
say "I need a few details before I can set up your test lab for you."
|
78
|
-
puts
|
79
|
-
say "We're going to use symmetric keys to authenticate with the AWS API."
|
80
|
-
say "First, I need your access key."
|
81
|
-
say "Your access key identifies you as you make API calls. It's not a secret."
|
82
|
-
say "You can find it under 'Access Credentials', on https://aws-portal.amazon.com/gp/aws/securityCredentials"
|
83
|
-
puts
|
84
|
-
@aws_access_key = ask "What is your AWS Access Key?", :bold
|
85
|
-
puts
|
86
|
-
say "Now I need your secret access key. This *is* a secret. The clue's in the name."
|
87
|
-
say "This is just a string of characters used to create the digital signature included in your API requests."
|
88
|
-
say "You can also find this under 'Access Credentials', on https://aws-portal.amazon.com/gp/aws/securityCredentials"
|
89
|
-
puts
|
90
|
-
@aws_secret_access_key = ask "What is your AWS Secret Access Key?", :bold
|
91
|
-
puts
|
92
|
-
say "Right. Now I need to know about the ssh key pair you want to use to connect to EC2 machines."
|
93
|
-
say "I need the name of the key pair. You can see this on the AWS management console, under Network & Security > Key Pairs"
|
94
|
-
puts
|
95
|
-
@aws_ssh_id = ask "What is your AWS Key Pair called?", :bold
|
96
|
-
puts
|
97
|
-
say "I also need to know what the ssh key is called - the actual name of the file on your local machine, eg #{@aws_ssh_id}.pem"
|
98
|
-
puts
|
99
|
-
@aws_ssh_key = ask "What's the filename of your ssh key?", :bold
|
100
|
-
puts
|
101
|
-
say "And, finally, I need to know where you keep it, on the file system. Often this is ~/.ssh"
|
102
|
-
puts
|
103
|
-
@aws_ssh_key_dir = ask "What directory contains your ssh key?", :bold
|
104
|
-
puts
|
105
|
-
say "OK, nearly there. AWS uses different keys depending on which region you use."
|
106
|
-
say "For example, 'us-east', 'us-west', or 'eu-west'"
|
107
|
-
puts
|
108
|
-
@region = ask "Which region are you using?", :bold
|
109
|
-
puts
|
110
|
-
say("One last thing. If you're using librarian-chef, we want to be sure all the hooks are in place.")
|
111
|
-
puts
|
112
|
-
@librarian_chef = yes?("Does this chef-repo use librarian-chef?", :bold)
|
113
|
-
puts
|
114
|
-
say "Awesome. Thank you!"
|
115
|
-
puts
|
116
|
-
end
|
117
|
-
|
118
71
|
end
|
119
72
|
|
120
73
|
################################################################################
|
@@ -513,9 +466,11 @@ class CucumberChef < Thor
|
|
513
466
|
"config_rb" => Cucumber::Chef.config_rb,
|
514
467
|
"labfile" => Cucumber::Chef.labfile,
|
515
468
|
"chef_repo" => Cucumber::Chef.chef_repo,
|
516
|
-
"bootstrap_identity" => Cucumber::Chef.bootstrap_identity,
|
517
469
|
"chef_user" => Cucumber::Chef.chef_user,
|
518
470
|
"chef_identity" => Cucumber::Chef.chef_identity,
|
471
|
+
"bootstrap_user" => Cucumber::Chef.bootstrap_user,
|
472
|
+
"bootstrap_user_home_dir" => Cucumber::Chef.bootstrap_user_home_dir,
|
473
|
+
"bootstrap_identity" => Cucumber::Chef.bootstrap_identity,
|
519
474
|
"lab_user" => Cucumber::Chef.lab_user,
|
520
475
|
"lab_user_home_dir" => Cucumber::Chef.lab_user_home_dir,
|
521
476
|
"lab_identity" => Cucumber::Chef.lab_identity,
|
@@ -27,48 +27,64 @@
|
|
27
27
|
package p
|
28
28
|
end
|
29
29
|
|
30
|
-
[ node.cucumber_chef.lab_user, node.cucumber_chef.lxc_user ].
|
31
|
-
home_dir = (
|
30
|
+
[ node.cucumber_chef.lab_user, node.cucumber_chef.lxc_user ].each do |username|
|
31
|
+
home_dir = ((username.downcase == "root") ? "/#{username}" : "/home/#{username}")
|
32
|
+
|
33
|
+
user username do
|
34
|
+
comment username
|
35
|
+
home home_dir
|
36
|
+
shell "/bin/bash"
|
37
|
+
supports :manage_home => true
|
38
|
+
end
|
39
|
+
|
40
|
+
directory "create home directory for #{username}" do
|
41
|
+
path home_dir
|
42
|
+
owner username
|
43
|
+
group username
|
44
|
+
mode "0700"
|
32
45
|
|
33
|
-
|
46
|
+
not_if { File.directory?(File.join(home_dir)) }
|
47
|
+
end
|
48
|
+
|
49
|
+
directory "create .ssh directory for #{username}" do
|
34
50
|
path "#{home_dir}/.ssh"
|
35
|
-
owner
|
36
|
-
group
|
51
|
+
owner username
|
52
|
+
group username
|
37
53
|
mode "0700"
|
38
54
|
|
39
55
|
not_if { File.directory?(File.join(home_dir, ".ssh")) }
|
40
56
|
end
|
41
57
|
|
42
|
-
template "create ssh config for #{
|
58
|
+
template "create ssh config for #{username}" do
|
43
59
|
path "#{home_dir}/.ssh/config"
|
44
60
|
source "ssh-config.erb"
|
45
|
-
owner
|
46
|
-
group
|
61
|
+
owner username
|
62
|
+
group username
|
47
63
|
mode "0600"
|
48
64
|
|
49
65
|
not_if { File.exists?(File.join(home_dir, ".ssh", "config")) }
|
50
66
|
end
|
51
67
|
|
52
|
-
execute "generate ssh keypair for #{
|
68
|
+
execute "generate ssh keypair for #{username}" do
|
53
69
|
command "ssh-keygen -q -N '' -f #{home_dir}/.ssh/id_rsa"
|
54
70
|
|
55
71
|
not_if { File.exists?(File.join(home_dir, ".ssh", "id_rsa")) }
|
56
72
|
end
|
57
73
|
|
58
|
-
file "ensure ssh private key ownership for #{
|
74
|
+
file "ensure ssh private key ownership for #{username}" do
|
59
75
|
path "#{home_dir}/.ssh/id_rsa"
|
60
|
-
owner
|
61
|
-
group
|
76
|
+
owner username
|
77
|
+
group username
|
62
78
|
mode "0400"
|
63
79
|
end
|
64
80
|
|
65
|
-
file "ensure ssh public key ownership for #{
|
81
|
+
file "ensure ssh public key ownership for #{username}" do
|
66
82
|
path "#{home_dir}/.ssh/id_rsa.pub"
|
67
|
-
owner
|
68
|
-
group
|
83
|
+
owner username
|
84
|
+
group username
|
69
85
|
end
|
70
86
|
|
71
|
-
execute "copy public key into authorized_keys for #{
|
87
|
+
execute "copy public key into authorized_keys for #{username}" do
|
72
88
|
command "cat #{home_dir}/.ssh/id_rsa.pub | tee -a #{home_dir}/.ssh/authorized_keys"
|
73
89
|
|
74
90
|
not_if do
|
@@ -76,6 +92,13 @@ end
|
|
76
92
|
($? == 0)
|
77
93
|
end
|
78
94
|
end
|
95
|
+
|
96
|
+
file "ensure ssh authorized_keys ownership for #{username}" do
|
97
|
+
path "#{home_dir}/.ssh/authorized_keys"
|
98
|
+
owner username
|
99
|
+
group username
|
100
|
+
end
|
101
|
+
|
79
102
|
end
|
80
103
|
|
81
104
|
file "remove update-motd" do
|
@@ -111,16 +134,3 @@ execute "set chef-client logging to debug" do
|
|
111
134
|
($? == 0)
|
112
135
|
end
|
113
136
|
end
|
114
|
-
|
115
|
-
|
116
|
-
################################################################################
|
117
|
-
# CHEF-SOLR / APACHE SOLR
|
118
|
-
################################################################################
|
119
|
-
|
120
|
-
# template "install custom solr config" do
|
121
|
-
# path "/var/lib/chef/solr/conf/solrconfig.xml"
|
122
|
-
# source "solrconfig.erb"
|
123
|
-
# owner "chef"
|
124
|
-
# group "chef"
|
125
|
-
# mode "0644"
|
126
|
-
# end
|
data/cucumber-chef.gemspec
CHANGED
@@ -46,7 +46,7 @@ Gem::Specification.new do |s|
|
|
46
46
|
s.add_dependency("rake", ">= 0.9.2")
|
47
47
|
s.add_dependency("thor", ">= 0.15.2")
|
48
48
|
s.add_dependency("ubuntu_ami", ">= 0.4.0")
|
49
|
-
s.add_dependency("ztk", ">= 1.0.
|
49
|
+
s.add_dependency("ztk", ">= 1.0.9")
|
50
50
|
|
51
51
|
s.add_development_dependency("simplecov", ">= 0.6.4")
|
52
52
|
s.add_development_dependency("pry", ">= 0")
|
data/lib/cucumber/chef/client.rb
CHANGED
@@ -49,32 +49,30 @@ module Cucumber
|
|
49
49
|
|
50
50
|
# PUSH CHEF-REPO
|
51
51
|
#################
|
52
|
-
if environment_variable_set?("PUSH")
|
53
|
-
# Upload all of the chef-repo environments
|
54
|
-
ZTK::Benchmark.bench(:message => ">>> Pushing chef-repo environments to the test lab", :mark => "completed in %0.4f seconds.") do
|
55
|
-
@test_lab.knife_cli(%(environment from file ./environments/*.rb), :silence => true)
|
56
|
-
end
|
57
52
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
@test_lab.knife_cli(%(cookbook upload --all --cookbook-path #{cookbook_paths.join(':')} --force), :silence => true)
|
63
|
-
end
|
53
|
+
# Upload all of the chef-repo environments
|
54
|
+
ZTK::Benchmark.bench(:message => ">>> Pushing chef-repo environments to the test lab", :mark => "completed in %0.4f seconds.") do
|
55
|
+
@test_lab.knife_cli(%(environment from file ./environments/*.rb), :silence => true)
|
56
|
+
end
|
64
57
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
58
|
+
# Upload all of the chef-repo cookbooks
|
59
|
+
ZTK::Benchmark.bench(:message => ">>> Pushing chef-repo cookbooks to the test lab", :mark => "completed in %0.4f seconds.") do
|
60
|
+
cookbook_paths = Cucumber::Chef::Config.chef[:cookbook_paths]
|
61
|
+
@test_lab.knife_cli(%(cookbook upload --all --cookbook-path #{cookbook_paths.join(':')} --force), :silence => true)
|
62
|
+
end
|
69
63
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
64
|
+
# Upload all of the chef-repo roles
|
65
|
+
ZTK::Benchmark.bench(:message => ">>> Pushing chef-repo roles to the test lab", :mark => "completed in %0.4f seconds.") do
|
66
|
+
@test_lab.knife_cli(%(role from file ./roles/*.rb), :silence => true)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Upload all of our chef-repo data bags
|
70
|
+
Dir.glob("./data_bags/*").each do |data_bag_path|
|
71
|
+
next if !File.directory?(data_bag_path)
|
72
|
+
ZTK::Benchmark.bench(:message => ">>> Pushing chef-repo data bag '#{File.basename(data_bag_path)}' to the test lab", :mark => "completed in %0.4f seconds.") do
|
73
|
+
data_bag = File.basename(data_bag_path)
|
74
|
+
@test_lab.knife_cli(%(data bag create "#{data_bag}"), :silence => true)
|
75
|
+
@test_lab.knife_cli(%(data bag from file "#{data_bag}" "#{data_bag_path}"), :silence => true)
|
78
76
|
end
|
79
77
|
end
|
80
78
|
|
data/lib/cucumber/chef/config.rb
CHANGED
@@ -170,18 +170,15 @@ module Cucumber
|
|
170
170
|
mode :user
|
171
171
|
prerelease (Cucumber::Chef.is_rc? ? true : false)
|
172
172
|
|
173
|
-
librarian_chef false
|
174
|
-
|
175
173
|
user (ENV['OPSCODE_USER'] || ENV['USER'])
|
176
174
|
|
177
175
|
artifacts ({"chef-client-log" => "/var/log/chef/client.log",
|
178
176
|
"chef-client-stacktrace" => "/var/chef/cache/chef-stacktrace.out"})
|
179
177
|
|
180
|
-
chef ({:
|
181
|
-
:
|
182
|
-
:
|
183
|
-
:
|
184
|
-
:render_client_rb => true})
|
178
|
+
chef ({:version => "latest",
|
179
|
+
:default_password => "p@ssw0rd1",
|
180
|
+
:render_client_rb => true,
|
181
|
+
:cookbook_paths => %w(cookbooks)})
|
185
182
|
|
186
183
|
test_lab ({:hostname => "cucumber-chef",
|
187
184
|
:tld => "test-lab"})
|
@@ -190,7 +187,8 @@ module Cucumber
|
|
190
187
|
|
191
188
|
provider :vagrant
|
192
189
|
|
193
|
-
aws ({:
|
190
|
+
aws ({:bootstrap_user => "ubuntu",
|
191
|
+
:lab_user => "cucumber-chef",
|
194
192
|
:lxc_user => "root",
|
195
193
|
:ssh => {
|
196
194
|
:lab_port => 22,
|
@@ -202,12 +200,16 @@ module Cucumber
|
|
202
200
|
:aws_instance_type => "m1.small",
|
203
201
|
:aws_security_group => "cucumber-chef"})
|
204
202
|
|
205
|
-
vagrant ({:
|
203
|
+
vagrant ({:bootstrap_user => "vagrant",
|
204
|
+
:lab_user => "cucumber-chef",
|
206
205
|
:lxc_user => "root",
|
207
206
|
:ssh => {
|
207
|
+
:lab_ip => "127.0.0.1",
|
208
208
|
:lab_port => 2222,
|
209
209
|
:lxc_port => 22
|
210
|
-
}
|
210
|
+
},
|
211
|
+
:cpus => 1,
|
212
|
+
:memory => 1024 })
|
211
213
|
|
212
214
|
################################################################################
|
213
215
|
|
@@ -229,7 +229,7 @@ module Cucumber
|
|
229
229
|
@test_lab.bootstrap_ssh.exec(%(sudo chroot #{cache_rootfs} /bin/bash -c 'locale-gen'), :silence => true)
|
230
230
|
@test_lab.bootstrap_ssh.exec(%(sudo chroot #{cache_rootfs} /bin/bash -c 'locale-gen en_US'), :silence => true)
|
231
231
|
@test_lab.bootstrap_ssh.exec(%(sudo chroot #{cache_rootfs} /bin/bash -c 'wget http://www.opscode.com/chef/install.sh'), :silence => true)
|
232
|
-
@test_lab.bootstrap_ssh.exec(%(sudo chroot #{cache_rootfs} /bin/bash -c 'bash install.sh -v #{Cucumber::Chef::Config.chef[:
|
232
|
+
@test_lab.bootstrap_ssh.exec(%(sudo chroot #{cache_rootfs} /bin/bash -c 'bash install.sh -v #{Cucumber::Chef::Config.chef[:version]}'), :silence => true)
|
233
233
|
if distro.downcase == "fedora"
|
234
234
|
@test_lab.bootstrap_ssh.exec(%(sudo chroot #{cache_rootfs} /bin/bash -c 'rpm -Uvh --nodeps /tmp/*rpm'), :silence => true)
|
235
235
|
end
|
@@ -237,13 +237,16 @@ module Cucumber
|
|
237
237
|
@test_lab.bootstrap_ssh.exec(%(sudo #{create_command(name, distro, release, arch)}), :silence => true)
|
238
238
|
end
|
239
239
|
|
240
|
-
|
241
|
-
|
240
|
+
lab_user_ssh_path = File.join(Cucumber::Chef.lab_user_home_dir, ".ssh")
|
241
|
+
lxc_user_ssh_path = File.join(Cucumber::Chef.lxc_user_home_dir, ".ssh")
|
242
|
+
|
243
|
+
lxc_ssh_path = File.join(root(name), Cucumber::Chef.lxc_user_home_dir, ".ssh")
|
242
244
|
motd_path = File.join(root(name), "etc", "motd")
|
243
245
|
|
244
|
-
@test_lab.bootstrap_ssh.exec(%(sudo mkdir -vp #{
|
245
|
-
@test_lab.bootstrap_ssh.exec(%(sudo chmod 0700 #{
|
246
|
-
@test_lab.bootstrap_ssh.exec(%(sudo cat #{File.join(
|
246
|
+
@test_lab.bootstrap_ssh.exec(%(sudo mkdir -vp #{lxc_ssh_path}), :silence => true)
|
247
|
+
@test_lab.bootstrap_ssh.exec(%(sudo chmod 0700 #{lxc_ssh_path}), :silence => true)
|
248
|
+
@test_lab.bootstrap_ssh.exec(%(sudo cat #{File.join(lab_user_ssh_path, "id_rsa.pub")} | sudo tee -a #{File.join(lxc_ssh_path, "authorized_keys")}), :silence => true)
|
249
|
+
@test_lab.bootstrap_ssh.exec(%(sudo cat #{File.join(lxc_user_ssh_path, "id_rsa.pub")} | sudo tee -a #{File.join(lxc_ssh_path, "authorized_keys")}), :silence => true)
|
247
250
|
|
248
251
|
@test_lab.bootstrap_ssh.exec(%(sudo rm -vf #{motd_path}), :silence => true)
|
249
252
|
@test_lab.bootstrap_ssh.exec(%(sudo cp -v /etc/motd #{motd_path}), :silence => true)
|
@@ -44,7 +44,20 @@ module Cucumber
|
|
44
44
|
|
45
45
|
def create
|
46
46
|
ZTK::Benchmark.bench(:message => "Creating #{Cucumber::Chef::Config.provider.upcase} instance", :mark => "completed in %0.4f seconds.", :stdout => @stdout) do
|
47
|
-
|
47
|
+
|
48
|
+
context = {
|
49
|
+
:ip => Cucumber::Chef.lab_ip,
|
50
|
+
:cpus => Cucumber::Chef::Config.vagrant[:cpus],
|
51
|
+
:memory => Cucumber::Chef::Config.vagrant[:memory]
|
52
|
+
}
|
53
|
+
|
54
|
+
vagrantfile_template = File.join(Cucumber::Chef.root_dir, "lib", "cucumber", "chef", "templates", "cucumber-chef", "Vagrantfile.erb")
|
55
|
+
|
56
|
+
vagrantfile = File.join(Cucumber::Chef.chef_repo, "Vagrantfile")
|
57
|
+
|
58
|
+
!File.exists?(vagrantfile) and IO.write(vagrantfile, ::ZTK::Template.render(vagrantfile_template, context))
|
59
|
+
|
60
|
+
self.vagrant_cli("up", id)
|
48
61
|
ZTK::TCPSocketCheck.new(:host => self.ip, :port => self.port, :wait => 120).wait
|
49
62
|
end
|
50
63
|
|
@@ -62,7 +75,7 @@ module Cucumber
|
|
62
75
|
|
63
76
|
def destroy
|
64
77
|
if exists?
|
65
|
-
self.vagrant_cli("destroy", "--force")
|
78
|
+
self.vagrant_cli("destroy", "--force", id)
|
66
79
|
else
|
67
80
|
raise VagrantError, "We could not find a test lab!"
|
68
81
|
end
|
@@ -79,7 +92,7 @@ module Cucumber
|
|
79
92
|
|
80
93
|
def up
|
81
94
|
if (exists? && dead?)
|
82
|
-
self.vagrant_cli("up")
|
95
|
+
self.vagrant_cli("up", id)
|
83
96
|
ZTK::TCPSocketCheck.new(:host => self.ip, :port => self.port, :wait => 120).wait
|
84
97
|
else
|
85
98
|
raise VagrantError, "We could not find a powered off test lab."
|
@@ -97,7 +110,7 @@ module Cucumber
|
|
97
110
|
|
98
111
|
def down
|
99
112
|
if (exists? && alive?)
|
100
|
-
self.vagrant_cli("halt")
|
113
|
+
self.vagrant_cli("halt", id)
|
101
114
|
else
|
102
115
|
raise AWSError, "We could not find a running test lab."
|
103
116
|
end
|
@@ -114,7 +127,7 @@ module Cucumber
|
|
114
127
|
|
115
128
|
def reload
|
116
129
|
if (exists? && alive?)
|
117
|
-
self.vagrant_cli("reload")
|
130
|
+
self.vagrant_cli("reload", id)
|
118
131
|
else
|
119
132
|
raise AWSError, "We could not find a running test lab."
|
120
133
|
end
|
@@ -142,7 +155,7 @@ module Cucumber
|
|
142
155
|
################################################################################
|
143
156
|
|
144
157
|
def id
|
145
|
-
"
|
158
|
+
"test-lab-#{ENV['USER']}".downcase
|
146
159
|
end
|
147
160
|
|
148
161
|
def state
|