cuken 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +8 -8
- data/VERSION +1 -1
- data/cuken.gemspec +19 -5
- data/features/about.md +110 -27
- data/features/chef_examples/cookbooks_cookbook.feature +2 -2
- data/features/chef_examples/zenoss/01_chef_server_setup.feature +205 -0
- data/features/chef_examples/zenoss/02_monitor_vm_setup.feature +139 -0
- data/features/chef_examples/zenoss/03_monitor_chef_setup.feature +109 -0
- data/features/step_definitions/cuken_steps.rb +16 -0
- data/features/support/env.rb +1 -0
- data/lib/cuken/api/chef/common.rb +20 -0
- data/lib/cuken/api/chef/cookbook.rb +62 -1
- data/lib/cuken/api/chef/data_bag.rb +89 -0
- data/lib/cuken/api/chef/knife.rb +16 -0
- data/lib/cuken/api/chef/role.rb +71 -0
- data/lib/cuken/api/chef.rb +51 -9
- data/lib/cuken/api/file.rb +68 -0
- data/lib/cuken/api/vagrant/common.rb +85 -0
- data/lib/cuken/api/vagrant/v_m.rb +125 -0
- data/lib/cuken/api/vagrant.rb +83 -0
- data/lib/cuken/chef.rb +16 -0
- data/lib/cuken/cucumber/chef/common.rb +4 -0
- data/lib/cuken/cucumber/chef/cookbook.rb +16 -2
- data/lib/cuken/cucumber/chef/data_bag.rb +48 -16
- data/lib/cuken/cucumber/chef/role.rb +30 -0
- data/lib/cuken/cucumber/chef.rb +16 -5
- data/lib/cuken/cucumber/cmd.rb +16 -0
- data/lib/cuken/cucumber/common.rb +16 -0
- data/lib/cuken/cucumber/file.rb +52 -0
- data/lib/cuken/cucumber/git/hooks.rb +28 -0
- data/lib/cuken/cucumber/rvm.rb +16 -0
- data/lib/cuken/cucumber/ssh/hooks.rb +31 -0
- data/lib/cuken/cucumber/ssh.rb +16 -0
- data/lib/cuken/cucumber/vagrant/common.rb +93 -0
- data/lib/cuken/cucumber/vagrant/hooks.rb +35 -0
- data/lib/cuken/cucumber/vagrant.rb +26 -0
- data/lib/cuken/vagrant.rb +19 -0
- metadata +18 -4
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -9,11 +9,11 @@ GEM
|
|
9
9
|
rspec (>= 2.5.0)
|
10
10
|
builder (3.0.0)
|
11
11
|
bunny (0.6.0)
|
12
|
-
chef (0.10.0
|
12
|
+
chef (0.10.0)
|
13
13
|
bunny (>= 0.6.0)
|
14
14
|
erubis
|
15
15
|
highline
|
16
|
-
json (
|
16
|
+
json (<= 1.5.2, >= 1.4.4)
|
17
17
|
mixlib-authentication (>= 1.1.0)
|
18
18
|
mixlib-cli (>= 1.1.0)
|
19
19
|
mixlib-config (>= 1.1.2)
|
@@ -22,7 +22,7 @@ GEM
|
|
22
22
|
net-ssh (~> 2.1.3)
|
23
23
|
net-ssh-multi (~> 1.0.1)
|
24
24
|
ohai (>= 0.6.0)
|
25
|
-
rest-client (
|
25
|
+
rest-client (< 1.7.0, >= 1.0.4)
|
26
26
|
treetop (~> 1.4.9)
|
27
27
|
uuidtools
|
28
28
|
childprocess (0.1.7)
|
@@ -36,10 +36,10 @@ GEM
|
|
36
36
|
diff-lcs (1.1.2)
|
37
37
|
erubis (2.6.6)
|
38
38
|
abstract (>= 1.0.0)
|
39
|
-
fakefs (0.3.
|
39
|
+
fakefs (0.3.2)
|
40
40
|
ffi (0.6.3)
|
41
41
|
rake (>= 0.8.7)
|
42
|
-
gherkin (2.3.
|
42
|
+
gherkin (2.3.7)
|
43
43
|
json (>= 1.4.6)
|
44
44
|
git (1.2.5)
|
45
45
|
grit (2.4.1)
|
@@ -63,12 +63,12 @@ GEM
|
|
63
63
|
net-scp (1.0.4)
|
64
64
|
net-ssh (>= 1.99.1)
|
65
65
|
net-ssh (2.1.4)
|
66
|
-
net-ssh-gateway (1.0
|
66
|
+
net-ssh-gateway (1.1.0)
|
67
67
|
net-ssh (>= 1.99.1)
|
68
68
|
net-ssh-multi (1.0.1)
|
69
69
|
net-ssh (>= 1.99.2)
|
70
70
|
net-ssh-gateway (>= 0.99.0)
|
71
|
-
ohai (0.6.
|
71
|
+
ohai (0.6.4)
|
72
72
|
mixlib-cli
|
73
73
|
mixlib-config
|
74
74
|
mixlib-log
|
@@ -129,7 +129,7 @@ PLATFORMS
|
|
129
129
|
DEPENDENCIES
|
130
130
|
aruba (~> 0.3.6)
|
131
131
|
bundler (~> 1.0.11)
|
132
|
-
chef (~> 0.10.0
|
132
|
+
chef (~> 0.10.0)
|
133
133
|
cucumber
|
134
134
|
fakefs (~> 0.3.1)
|
135
135
|
grit (~> 2.4.1)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.12
|
data/cuken.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{cuken}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.12"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Hedgehog"]
|
12
|
-
s.date = %q{2011-05-
|
12
|
+
s.date = %q{2011-05-03}
|
13
13
|
s.description = %q{Reusable Cucumber steps and API for post-convergence system integration descriptions}
|
14
14
|
s.email = %q{hedgehogshiatus@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -39,6 +39,9 @@ Gem::Specification.new do |s|
|
|
39
39
|
"features/chef_examples/cookbooks_repo.feature",
|
40
40
|
"features/chef_examples/knife_admin_client.feature",
|
41
41
|
"features/chef_examples/knife_client_create.feature",
|
42
|
+
"features/chef_examples/zenoss/01_chef_server_setup.feature",
|
43
|
+
"features/chef_examples/zenoss/02_monitor_vm_setup.feature",
|
44
|
+
"features/chef_examples/zenoss/03_monitor_chef_setup.feature",
|
42
45
|
"features/chef_steps/common_steps.feature",
|
43
46
|
"features/chef_steps/cookbook_steps.feature",
|
44
47
|
"features/chef_steps/knife_steps.feature",
|
@@ -402,7 +405,9 @@ Gem::Specification.new do |s|
|
|
402
405
|
"lib/cuken/api/chef.rb",
|
403
406
|
"lib/cuken/api/chef/common.rb",
|
404
407
|
"lib/cuken/api/chef/cookbook.rb",
|
408
|
+
"lib/cuken/api/chef/data_bag.rb",
|
405
409
|
"lib/cuken/api/chef/knife.rb",
|
410
|
+
"lib/cuken/api/chef/role.rb",
|
406
411
|
"lib/cuken/api/cmd.rb",
|
407
412
|
"lib/cuken/api/common.rb",
|
408
413
|
"lib/cuken/api/file.rb",
|
@@ -410,6 +415,9 @@ Gem::Specification.new do |s|
|
|
410
415
|
"lib/cuken/api/ssh-forever.rb",
|
411
416
|
"lib/cuken/api/ssh.rb",
|
412
417
|
"lib/cuken/api/ssh/password.rb",
|
418
|
+
"lib/cuken/api/vagrant.rb",
|
419
|
+
"lib/cuken/api/vagrant/common.rb",
|
420
|
+
"lib/cuken/api/vagrant/v_m.rb",
|
413
421
|
"lib/cuken/chef.rb",
|
414
422
|
"lib/cuken/cmd.rb",
|
415
423
|
"lib/cuken/common.rb",
|
@@ -441,11 +449,17 @@ Gem::Specification.new do |s|
|
|
441
449
|
"lib/cuken/cucumber/cmd.rb",
|
442
450
|
"lib/cuken/cucumber/common.rb",
|
443
451
|
"lib/cuken/cucumber/file.rb",
|
452
|
+
"lib/cuken/cucumber/git/hooks.rb",
|
444
453
|
"lib/cuken/cucumber/rvm.rb",
|
445
454
|
"lib/cuken/cucumber/ssh.rb",
|
455
|
+
"lib/cuken/cucumber/ssh/hooks.rb",
|
456
|
+
"lib/cuken/cucumber/vagrant.rb",
|
457
|
+
"lib/cuken/cucumber/vagrant/common.rb",
|
458
|
+
"lib/cuken/cucumber/vagrant/hooks.rb",
|
446
459
|
"lib/cuken/file.rb",
|
447
460
|
"lib/cuken/rvm.rb",
|
448
461
|
"lib/cuken/ssh.rb",
|
462
|
+
"lib/cuken/vagrant.rb",
|
449
463
|
"spec/api/knife_spec.rb",
|
450
464
|
"spec/api/rvm_spec.rb",
|
451
465
|
"spec/api/rvmrc_processor_spec.rb",
|
@@ -472,7 +486,7 @@ Gem::Specification.new do |s|
|
|
472
486
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
473
487
|
s.add_runtime_dependency(%q<aruba>, ["~> 0.3.6"])
|
474
488
|
s.add_runtime_dependency(%q<cucumber>, [">= 0"])
|
475
|
-
s.add_runtime_dependency(%q<chef>, ["~> 0.10.0
|
489
|
+
s.add_runtime_dependency(%q<chef>, ["~> 0.10.0"])
|
476
490
|
s.add_runtime_dependency(%q<grit>, ["~> 2.4.1"])
|
477
491
|
s.add_runtime_dependency(%q<rvm>, ["~> 1.5.2"])
|
478
492
|
s.add_runtime_dependency(%q<open4>, [">= 0"])
|
@@ -490,7 +504,7 @@ Gem::Specification.new do |s|
|
|
490
504
|
else
|
491
505
|
s.add_dependency(%q<aruba>, ["~> 0.3.6"])
|
492
506
|
s.add_dependency(%q<cucumber>, [">= 0"])
|
493
|
-
s.add_dependency(%q<chef>, ["~> 0.10.0
|
507
|
+
s.add_dependency(%q<chef>, ["~> 0.10.0"])
|
494
508
|
s.add_dependency(%q<grit>, ["~> 2.4.1"])
|
495
509
|
s.add_dependency(%q<rvm>, ["~> 1.5.2"])
|
496
510
|
s.add_dependency(%q<open4>, [">= 0"])
|
@@ -509,7 +523,7 @@ Gem::Specification.new do |s|
|
|
509
523
|
else
|
510
524
|
s.add_dependency(%q<aruba>, ["~> 0.3.6"])
|
511
525
|
s.add_dependency(%q<cucumber>, [">= 0"])
|
512
|
-
s.add_dependency(%q<chef>, ["~> 0.10.0
|
526
|
+
s.add_dependency(%q<chef>, ["~> 0.10.0"])
|
513
527
|
s.add_dependency(%q<grit>, ["~> 2.4.1"])
|
514
528
|
s.add_dependency(%q<rvm>, ["~> 1.5.2"])
|
515
529
|
s.add_dependency(%q<open4>, [">= 0"])
|
data/features/about.md
CHANGED
@@ -17,45 +17,82 @@ The Chef steps assume you have Chef server accessible on `localhost:4040`.
|
|
17
17
|
If you have ideas to clarify or improve any of these cucumber features,
|
18
18
|
please submit an [issue][9] or [pull request][8].
|
19
19
|
|
20
|
-
## The Chef JSON Issue
|
21
|
-
Due to several JSON gem conflicts between
|
20
|
+
## The Chef vs Vagrant/Aruba JSON Issue
|
21
|
+
Due to several JSON gem conflicts between Chef and the Vagrant/Aruba gems, Cuken is only intended
|
22
22
|
to work with the 0.10 series of Chef. Of course you are free to work whatever
|
23
|
-
magic you wish.
|
23
|
+
magic you wish for the 0.9.x releases.
|
24
24
|
|
25
25
|
## Opinons
|
26
26
|
Virtual machines are [Vagrant][11] VM's.
|
27
27
|
Vagrant VM's are all named.
|
28
28
|
Configuration management and system integration is done with [Opscode's Chef][12].
|
29
|
-
Chef Cookbooks are sourced from the
|
29
|
+
Chef Cookbooks are sourced from the [Cookbooks account][13] on Github.
|
30
|
+
|
31
|
+
## Multiple Vagrant Multi-VM Environemts in one Scenario
|
32
|
+
Vagrant allows you to have Multi-VM environemnts in one Vagrantfile.
|
33
|
+
Cuken allows you to have multiple Vangrant Multi-VM environments in one scenario.
|
34
|
+
However there can be a performance penalty, so use this judiciously. To illustrate the performance hit
|
35
|
+
the Zenoss example (02_monitor_vm_setup.rb) has a multiple Vagrant environment as a Background - this gets run before
|
36
|
+
each scenario. This example also serves to demonstrate the steps neccessary to switch between Vagrant environments
|
37
|
+
(Vagrantfiles). Note the convention is that the Vagrant file resides in the Chef-project root directory.
|
38
|
+
|
39
|
+
Background:
|
40
|
+
Given the Chef root directory "/tmp/chef" exists
|
41
|
+
And the state of VM "chef" is "running"
|
42
|
+
And I switch Vagrant environment
|
43
|
+
And the Chef root directory "/tmp/monitor" exists
|
44
|
+
And the state of VM "monitor" is not "running"
|
45
|
+
|
46
|
+
NOTE:
|
47
|
+
The Zenoss example is intended to exercise steps and illustrate some useage.
|
48
|
+
It is certainly not an illustrattion of best practice.
|
30
49
|
|
31
50
|
## Conventions
|
32
|
-
|
33
|
-
|
51
|
+
|
52
|
+
### Generic
|
53
|
+
Rather than repeatedly refer to Chef, Vagrant, etc. in each step, where it is unambiguous,
|
54
|
+
we treat the item or attribute as a pronoun, but capitalize to indicate the specialized substitution.
|
55
|
+
So, while there are many virtual machines and data bags in the world, here they refer to
|
56
|
+
Vagrant (VirtualBox) and Chef.
|
57
|
+
|
34
58
|
Examples:
|
35
59
|
|
36
|
-
Given the VM "chef" is not running
|
60
|
+
Given the state of VM "chef" is not "running"
|
37
61
|
Given I create the Data Bag "user"
|
38
62
|
|
39
|
-
|
40
|
-
|
63
|
+
### Place and Placed Files and Folders
|
64
|
+
The convention is to carry out all file and folder CRUD inside Aruba's scratch directory.
|
65
|
+
Given that Aruba deletes its tmporary working folder at the start of each scenario, it is neccessary to transfer any
|
66
|
+
files and folders you wish to keep.
|
67
|
+
We refer to this transfer of files and folders as 'placing'. Since a copy does not exists beyond the Scenario's life,
|
68
|
+
and since we verify the contents of placed files, it is not a file or folder copy nor move.
|
69
|
+
Placing and placed files and folders refer to taking a file from Aruba's scratch folder, moving it
|
70
|
+
outside of that ephemeral area and verifying the contents.
|
41
71
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
72
|
+
### Chef
|
73
|
+
In most cases Chef operations refer to the remote server, e.g. 'I create the Data Bag "...". The reason we leave remote
|
74
|
+
implicit in these steps, are:
|
75
|
+
a) to keep steps descriptions succint yet informative/accurate.
|
76
|
+
b) a 'local' version of this step is not accurate because local, filesystem, operations are properly done with the file
|
77
|
+
and directory steps and API, and are not done through Chef/Knife.
|
46
78
|
|
47
|
-
|
79
|
+
Cookbooks are are checked out into the branch 'cuken'.
|
80
|
+
Once you are happy with your changes, you can [rebase][14] ([interactively][15]) then push your changes to your fork
|
81
|
+
There are other ways, here is one [Git ver. 1.7.5]):
|
48
82
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
@ssh_pigeon
|
83
|
+
git checkout cuken # Just in case. Cuken leaves this branch checked-out
|
84
|
+
git rebase qa
|
85
|
+
git push origin qa
|
53
86
|
|
54
|
-
|
87
|
+
Then, on Github, issue a pull request from the qa branch of your fork.
|
88
|
+
To see a listing of the changes (before you rebase): `git diff qa..cuken`
|
55
89
|
|
56
|
-
|
90
|
+
### Vagrant
|
91
|
+
The Vagrantfile is required to be in the Chef-project root directory. Consequently the step
|
92
|
+
'the Chef root directory "/tmp/chef" exists' is required before any Vagrant steps.
|
57
93
|
|
58
|
-
|
94
|
+
## Hooks
|
95
|
+
If you need to change a default hook, add your variation of the following to your project's features/support/env.rb:
|
59
96
|
|
60
97
|
Before do
|
61
98
|
@aruba_timeout_seconds.nil? || @aruba_timeout_seconds < 3 ? @aruba_timeout_seconds = 3 : @aruba_timeout_seconds
|
@@ -65,19 +102,61 @@ If you need to change a default, add to your features/support/env.rb:
|
|
65
102
|
@aruba_timeout_seconds.nil? || @aruba_timeout_seconds < 3600 ? @aruba_timeout_seconds = 3600 : @aruba_timeout_seconds
|
66
103
|
end
|
67
104
|
|
105
|
+
### Aruba
|
106
|
+
Aruba will timeout if a command takes too long. A convention is to tag Features/Scenarios
|
107
|
+
according to the size of the timeout threshold:
|
108
|
+
See lib/cuken/vagrant/hooks.rb:
|
109
|
+
|
110
|
+
no tag: 3 seconds (Aruba default)
|
111
|
+
@fast 6 seconds
|
112
|
+
@quick 20 seconds
|
113
|
+
@slow 60 seconds
|
114
|
+
@glacial 600 seconds
|
115
|
+
@cosmic 3600 seconds
|
68
116
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
117
|
+
Aruba will timeout if IO takes too long. This affects interactive SSH connections.
|
118
|
+
See lib/cuken/ssh/hooks.rb:
|
119
|
+
|
120
|
+
no tag: 0.1 second (Aruba default)
|
121
|
+
@ssh_local 0.3 second
|
122
|
+
@ssh_remote 1 second
|
123
|
+
@ssh_pigeon 3 seconds
|
124
|
+
@ssh_dodo 10 seconds
|
125
|
+
|
126
|
+
### Git/Grit
|
127
|
+
See lib/cuken/git/hooks.rb:
|
128
|
+
|
129
|
+
no tag: 10 seconds (Grit default)
|
130
|
+
@git_quick 20 seconds
|
131
|
+
@git_slow 60 seconds
|
132
|
+
@git_glacial 600 seconds
|
133
|
+
@git_cosmic 3600 seconds
|
134
|
+
|
135
|
+
## Gotcha's
|
136
|
+
Unicorns are a dream, but Dragons are real...
|
137
|
+
### Aruba
|
138
|
+
Aruba doesn't yet handle generic script execution, and that includes Bash and friends. There is some support for Ruby.
|
139
|
+
No trouble, you just need to use this syntax, if you want to fix it, see [here][16]:
|
140
|
+
|
141
|
+
And I run `bash -c 'cp ~/chef/vagrant/lucid64.box /tmp/monitor'`
|
142
|
+
|
143
|
+
## API and Step contributions:
|
144
|
+
- Ideally the API methods should be covered by RSpec (I've been slack due to the backlog of pre-existing steps to port).
|
145
|
+
- Have a feature/scenario that illustrates its use, this is the psuedo specs I've been relying on. If you are not
|
146
|
+
convinced this approach is a long term disaster, review Bundler's code base circa v1.0.10.
|
147
|
+
- Refactoring an API method is discouraged before a spec fully describing the current behavior exists.
|
148
|
+
|
149
|
+
## TODO
|
150
|
+
- General passwordless and interactive SSH steps (currently Vagrant VM specific)
|
151
|
+
- Cloud launch and basic management steps, i.e. CRUD operations for Cloud VM
|
152
|
+
- Updating packages on a VM, and repackaging the VM, essentialy CRUD too.
|
74
153
|
|
75
154
|
## Prior Art:
|
76
155
|
- [Aruba][2] confirmed the utility of reusable steps.
|
77
156
|
- [Auxesis' Cucumber-Nagios][4] served as launch pad, and [had this idea early on][10].
|
78
157
|
- [Chef][5] steps are being ported.
|
79
158
|
- [Virtualbox][6] steps are planned to be ported.
|
80
|
-
- [SSH-Forever][7]
|
159
|
+
- [SSH-Forever][7] copied as the API-base for passwordless SSH steps.
|
81
160
|
|
82
161
|
[0]: https://github.com/aslakhellesoy/cucumber
|
83
162
|
[1]: https://github.com/hedgehog/cuken
|
@@ -93,3 +172,7 @@ steps to port).
|
|
93
172
|
[11]: http://vagrantup.com/
|
94
173
|
[12]: http://wiki.opscode.com/display/chef/Home
|
95
174
|
[13]: https://github.com/cookbooks/
|
175
|
+
[14]: http://book.git-scm.com/4_rebasing.html
|
176
|
+
[15]: http://book.git-scm.com/4_interactive_rebasing.html
|
177
|
+
[16]: https://github.com/aslakhellesoy/aruba/issues/69
|
178
|
+
|
@@ -29,8 +29,8 @@ Feature: Cookbook Validity
|
|
29
29
|
Scenario: Clone non-existant Cookbooks from a Cookbooks URI
|
30
30
|
Given the remote Cookbooks URI "git://github.com/cookbooks/"
|
31
31
|
When I clone the Cookbooks:
|
32
|
-
| cookbook |
|
33
|
-
| hfgrt |
|
32
|
+
| cookbook | tag | destination |
|
33
|
+
| hfgrt | 37s.0.1.0 | ckbk/scratch/myapp/cookbooks/hosts3 |
|
34
34
|
Then the output should contain "Could not find Repository cookbooks/hfgrt"
|
35
35
|
|
36
36
|
Scenario: Clone multiple Cookbooks from a Cookbooks URI
|
@@ -0,0 +1,205 @@
|
|
1
|
+
@announce
|
2
|
+
Feature: Zenoss Monitoring
|
3
|
+
In order to launch a Zenoss server
|
4
|
+
As a admin/developer
|
5
|
+
I want to define the Chef admin client configuration via executable features
|
6
|
+
|
7
|
+
Scenario: Create the Chef server Node's Vagrantfile
|
8
|
+
Given the file "Vagrantfile" contains nothing
|
9
|
+
When I write to "Vagrantfile":
|
10
|
+
"""
|
11
|
+
Vagrant::Config.run do |config|
|
12
|
+
|
13
|
+
@cs_root_path = File.dirname(File.absolute_path(__FILE__))
|
14
|
+
@cs_box = "chef"
|
15
|
+
@cs_box_url = (Pathname(@cs_root_path) + 'lucid64.box').to_s
|
16
|
+
@cs_nodename = "chef"
|
17
|
+
@cs_tld = "private.org"
|
18
|
+
@cs_ip = "33.33.33.254" # Host-only networking
|
19
|
+
@cs_port = 4000
|
20
|
+
@cs_ssh_port = 2200
|
21
|
+
@cs_webui_port = 4040
|
22
|
+
@cs_kitchen = @cs_root_path
|
23
|
+
@cs_validation_client_name = "chef-validator"
|
24
|
+
|
25
|
+
config.vm.define :chef do |csc|
|
26
|
+
|
27
|
+
csc.send :eval, IO.read("#{@cs_root_path}/hobos/vm.bo")
|
28
|
+
|
29
|
+
csc.vm.box = "#{@cs_box}"
|
30
|
+
csc.vm.box_url = "#{@cs_box_url}"
|
31
|
+
csc.vm.forward_port("chefs", @cs_port, @cs_port)
|
32
|
+
csc.vm.forward_port("chefs_web", @cs_webui_port, @cs_webui_port)
|
33
|
+
csc.vm.forward_port("ssh", 22, @cs_ssh_port, :auto => true)
|
34
|
+
csc.vm.network(@cs_ip)
|
35
|
+
csc.vm.share_folder("chef", "~/chef", "#{@cs_root_path}/mnt/chef")
|
36
|
+
csc.vm.share_folder("chef-server-etc", "/etc/chef", "#{@cs_kitchen}/mnt/etc" )
|
37
|
+
csc.vm.share_folder("chef-cookbooks-0", "/tmp/vagrant-chef/cookbooks-0", "#{@cs_kitchen}/site-cookbooks")
|
38
|
+
csc.vm.share_folder("chef-cookbooks-1", "/tmp/vagrant-chef/cookbooks-1", "#{@cs_kitchen}/cookbooks")
|
39
|
+
csc.vm.provision :chef_solo do |chef|
|
40
|
+
chef.log_level = :debug # :info or :debug
|
41
|
+
chef.node_name = @cs_nodename
|
42
|
+
chef.cookbooks_path = [
|
43
|
+
File.expand_path("#{@cs_kitchen}/site-cookbooks"),
|
44
|
+
File.expand_path("#{@cs_kitchen}/cookbooks")]
|
45
|
+
chef.add_recipe("hosts::chefserver")
|
46
|
+
chef.add_recipe("apt")
|
47
|
+
chef.add_recipe("build-essential")
|
48
|
+
chef.add_recipe("chef-server::rubygems-install")
|
49
|
+
chef.json.merge!({
|
50
|
+
:chef_server=> {
|
51
|
+
:name=> @cs_nodename,
|
52
|
+
:validation_client_name=> @cs_validation_client_name,
|
53
|
+
:url_type=>"http",
|
54
|
+
:server_fqdn=> "#{@cs_nodename}.#{@cs_tld}",
|
55
|
+
:server_port=> "#{@cs_port}",
|
56
|
+
:webui_port=> "#{@cs_webui_port}",
|
57
|
+
:webui_enabled=> true,
|
58
|
+
:umask => '0644'
|
59
|
+
}
|
60
|
+
})
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
"""
|
65
|
+
Then I place "Vagrantfile" in "/tmp/chef"
|
66
|
+
|
67
|
+
Scenario: Create some shared Vagrant configuration details
|
68
|
+
Given the directory "hobos"
|
69
|
+
And the file "hobos/vm.bo" contains nothing
|
70
|
+
When I write to "hobos/vm.bo":
|
71
|
+
"""
|
72
|
+
vm.customize do |cvm|
|
73
|
+
cvm.memory_size = 1024
|
74
|
+
cvm.vram_size = 12
|
75
|
+
cvm.cpu_count = 2
|
76
|
+
cvm.accelerate_3d_enabled = false
|
77
|
+
cvm.accelerate_2d_video_enabled = false
|
78
|
+
cvm.monitor_count = 1
|
79
|
+
|
80
|
+
cvm.bios.acpi_enabled = true
|
81
|
+
cvm.bios.io_apic_enabled = false
|
82
|
+
|
83
|
+
cvm.cpu.pae = true
|
84
|
+
|
85
|
+
cvm.hw_virt.enabled = false
|
86
|
+
cvm.hw_virt.nested_paging = false
|
87
|
+
# STORAGE
|
88
|
+
end
|
89
|
+
"""
|
90
|
+
And I place "hobos/vm.bo" in "/tmp/chef"
|
91
|
+
|
92
|
+
Scenario: Clone a Chef skeleton repository
|
93
|
+
Given the remote Chef repository "git://github.com/cookbooks/chef-repo.git"
|
94
|
+
When I clone the remote Chef repository branch "master" to "chef"
|
95
|
+
And the local Chef repository exists
|
96
|
+
Then I place all in "chef" in "/tmp/chef"
|
97
|
+
|
98
|
+
Scenario: Download Cookbooks from a Cookbooks URI
|
99
|
+
Given the remote Cookbooks URI "git://github.com/cookbooks/"
|
100
|
+
When I clone the Cookbooks:
|
101
|
+
| cookbook | branch | destination |
|
102
|
+
| apache2 | master | chef/cookbooks/apache2 |
|
103
|
+
| apt | master | chef/cookbooks/apt |
|
104
|
+
| bluepill | master | chef/cookbooks/bluepill |
|
105
|
+
| build-essential | master | chef/cookbooks/build-essential |
|
106
|
+
| chef-client | master | chef/cookbooks/chef-client |
|
107
|
+
| chef-server | master | chef/cookbooks/chef-server |
|
108
|
+
| couchdb | master | chef/cookbooks/couchdb |
|
109
|
+
| daemontools | master | chef/cookbooks/daemontools |
|
110
|
+
| erlang | master | chef/cookbooks/erlang |
|
111
|
+
| gecode | master | chef/cookbooks/gecode |
|
112
|
+
| hosts | master | chef/cookbooks/hosts |
|
113
|
+
| java | master | chef/cookbooks/java |
|
114
|
+
| openssl | master | chef/cookbooks/openssl |
|
115
|
+
| rabbitmq | master | chef/cookbooks/rabbitmq |
|
116
|
+
| runit | master | chef/cookbooks/runit |
|
117
|
+
| ucspi-tcp | master | chef/cookbooks/ucspi-tcp |
|
118
|
+
| xml | master | chef/cookbooks/xml |
|
119
|
+
| zlib | master | chef/cookbooks/zlib |
|
120
|
+
And these local Cookbooks exist:
|
121
|
+
| cookbook |
|
122
|
+
| apache2 |
|
123
|
+
| apt |
|
124
|
+
| bluepill |
|
125
|
+
| build-essential |
|
126
|
+
| chef-client |
|
127
|
+
| chef-server |
|
128
|
+
| couchdb |
|
129
|
+
| daemontools |
|
130
|
+
| erlang |
|
131
|
+
| gecode |
|
132
|
+
| hosts |
|
133
|
+
| java |
|
134
|
+
| openssl |
|
135
|
+
| rabbitmq |
|
136
|
+
| runit |
|
137
|
+
| ucspi-tcp |
|
138
|
+
| xml |
|
139
|
+
| zlib |
|
140
|
+
Then I place all in "chef" in "/tmp/chef"
|
141
|
+
|
142
|
+
Scenario: Download Site-Cookbooks from a Cookbooks URI
|
143
|
+
Given the remote Cookbooks URI "git@github.com:hedgehog/"
|
144
|
+
When I clone the Cookbooks:
|
145
|
+
| cookbook | branch | destination |
|
146
|
+
| hosts | qa | chef/site-cookbooks/hosts |
|
147
|
+
| java | qa | chef/site-cookbooks/java |
|
148
|
+
And these local Cookbooks exist:
|
149
|
+
| site-cookbook |
|
150
|
+
| hosts |
|
151
|
+
| java |
|
152
|
+
Then I place all in "chef" in "/tmp/chef"
|
153
|
+
|
154
|
+
Scenario: Configure Knife file for the Chef administrator's client certificate
|
155
|
+
Given I write to ".chef/knife.rb":
|
156
|
+
"""
|
157
|
+
current_dir = File.dirname(__FILE__)
|
158
|
+
user = ENV['CHEF_USER'] || ENV['OPSCODE_USER'] || ENV['USER'] || `whoami`
|
159
|
+
org = ENV['CHEF_ORGNAME'] || 'Private'
|
160
|
+
email = ENV['CHEF_EMAIL'] || "#{user}@mailinator.com"
|
161
|
+
log_path = "#{current_dir}/../log"
|
162
|
+
|
163
|
+
current_dir = File.dirname(__FILE__)
|
164
|
+
node_name "chef-webui"
|
165
|
+
log_location "#{log_path}/client_#{node_name}.log"
|
166
|
+
log_level :debug
|
167
|
+
verbose_logging true
|
168
|
+
client_key "#{File.dirname(current_dir)}/mnt/etc/webui.pem"
|
169
|
+
chef_server_url "http://localhost:4000"
|
170
|
+
cache_type 'BasicFile'
|
171
|
+
cache_options :path => "#{log_path}/checksums"
|
172
|
+
cookbook_path ["#{current_dir}/../cookbooks","#{current_dir}/../site-cookbooks"]
|
173
|
+
|
174
|
+
"""
|
175
|
+
And I place ".chef/knife.rb" in "/tmp/chef"
|
176
|
+
|
177
|
+
Scenario: Start the Chef server VM
|
178
|
+
Given the Chef root directory "/tmp/chef" exists
|
179
|
+
And the VM "chef" is not "running"
|
180
|
+
And the Vagrantfile "/tmp/chef/Vagrantfile" exists
|
181
|
+
When I launch the VM "chef"
|
182
|
+
Then the state of VM "chef" is "running"
|
183
|
+
|
184
|
+
@ssh_local
|
185
|
+
Scenario: Fix the Chef server key/certificate permissions
|
186
|
+
Given the Chef root directory "/tmp/chef" exists
|
187
|
+
And the Vagrantfile "/tmp/chef/Vagrantfile" exists
|
188
|
+
And the state of VM "chef" is "running"
|
189
|
+
When I ssh to VM "chef"
|
190
|
+
And I type "sudo chmod 0644 /etc/chef/webui.pem"
|
191
|
+
And I type "sudo chmod 0644 /etc/chef/certificates/key.pem"
|
192
|
+
And I type "stat -c %A /etc/chef/webui.pem"
|
193
|
+
And I type "stat -c %A /etc/chef/certificates/key.pem"
|
194
|
+
Then the output should contain:
|
195
|
+
"""
|
196
|
+
-rw-r--r--
|
197
|
+
-rw-r--r--
|
198
|
+
"""
|
199
|
+
|
200
|
+
Scenario: Create the admin client monitor
|
201
|
+
Given the Chef root directory "/tmp/chef" exists
|
202
|
+
And the state of VM "chef" is "running"
|
203
|
+
When I create the Chef admin client "monitor"
|
204
|
+
Then the placed file "/tmp/chef/.chef/monitor.pem" contains "-----END RSA PRIVATE KEY-----"
|
205
|
+
|