cucumber-chef 1.0.3 → 2.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -35
- data/.rspec +1 -0
- data/.rvmrc.template +2 -0
- data/.travis.yml +22 -0
- data/Gemfile +2 -15
- data/LICENSE +202 -201
- data/NOTICE +9 -0
- data/README.md +696 -92
- data/Rakefile +39 -25
- data/TODO.md +28 -0
- data/bin/cc-knife +32 -0
- data/bin/cucumber-chef +409 -79
- data/chef_repo/cookbooks/cucumber-chef/LICENSE +202 -0
- data/chef_repo/cookbooks/cucumber-chef/README.md +69 -0
- data/chef_repo/cookbooks/cucumber-chef/attributes/default.rb +27 -0
- data/chef_repo/cookbooks/cucumber-chef/metadata.rb +13 -0
- data/chef_repo/cookbooks/cucumber-chef/recipes/default.rb +23 -0
- data/chef_repo/cookbooks/cucumber-chef/recipes/lxc.rb +315 -0
- data/chef_repo/cookbooks/cucumber-chef/recipes/test_lab.rb +146 -0
- data/chef_repo/cookbooks/cucumber-chef/templates/default/db-168-192.erb +15 -0
- data/chef_repo/cookbooks/cucumber-chef/templates/default/db-test-lab.erb +15 -0
- data/chef_repo/cookbooks/cucumber-chef/templates/default/dhcpd-conf.erb +44 -0
- data/chef_repo/cookbooks/cucumber-chef/templates/default/gemrc.erb +10 -0
- data/{cookbooks/cucumber-chef/files/default/cucumber-net → chef_repo/cookbooks/cucumber-chef/templates/default/lxc-initializer-config.erb} +1 -1
- data/chef_repo/cookbooks/cucumber-chef/templates/default/lxc-install-chef.erb +3 -0
- data/chef_repo/cookbooks/cucumber-chef/templates/default/motd.erb +10 -0
- data/chef_repo/cookbooks/cucumber-chef/templates/default/named-conf-local.erb +25 -0
- data/{cookbooks/cucumber-chef/files/default/permissive-ssh-config → chef_repo/cookbooks/cucumber-chef/templates/default/ssh-config.erb} +3 -1
- data/chef_repo/roles/test_lab.rb +24 -0
- data/cucumber-chef.gemspec +50 -123
- data/examples/README.md +7 -0
- data/examples/users_add.feature +51 -0
- data/examples/users_auto_remove.feature +50 -0
- data/features/support/env.rb +3 -2
- data/lib/cucumber/chef/bootstrap.rb +94 -0
- data/lib/cucumber/chef/command.rb +78 -0
- data/lib/cucumber/chef/config.rb +143 -93
- data/lib/cucumber/chef/helpers/chef_client.rb +87 -0
- data/lib/cucumber/chef/helpers/chef_server.rb +90 -0
- data/lib/cucumber/chef/helpers/command.rb +57 -0
- data/lib/cucumber/chef/helpers/container.rb +154 -0
- data/lib/cucumber/chef/helpers/minitest.rb +35 -0
- data/lib/cucumber/chef/helpers/server.rb +81 -0
- data/lib/cucumber/chef/helpers/test_lab.rb +46 -0
- data/lib/cucumber/chef/helpers/utility.rb +73 -0
- data/lib/cucumber/chef/helpers.rb +56 -0
- data/lib/cucumber/chef/logger.rb +90 -0
- data/lib/cucumber/chef/provisioner.rb +275 -69
- data/lib/cucumber/chef/ssh.rb +190 -0
- data/lib/cucumber/chef/steps/chef_steps.rb +32 -0
- data/lib/cucumber/chef/steps/minitest_steps.rb +29 -0
- data/lib/cucumber/chef/steps/provision_steps.rb +60 -0
- data/lib/cucumber/chef/steps/ssh_steps.rb +95 -0
- data/lib/cucumber/chef/steps.rb +27 -0
- data/lib/cucumber/chef/tcp_socket.rb +83 -0
- data/lib/cucumber/chef/template.rb +57 -0
- data/lib/cucumber/chef/templates/bootstrap/ubuntu-precise-test-lab.erb +99 -0
- data/lib/cucumber/chef/templates/cucumber/env.rb +56 -0
- data/lib/cucumber/chef/templates/cucumber/example_feature.erb +49 -0
- data/lib/cucumber/chef/templates/cucumber/example_steps.erb +11 -0
- data/lib/cucumber/chef/templates/cucumber/readme-data_bags.erb +1 -0
- data/lib/cucumber/chef/templates/cucumber/readme-keys.erb +1 -0
- data/lib/cucumber/chef/templates/cucumber/readme-roles.erb +1 -0
- data/lib/cucumber/chef/templates/cucumber/readme.erb +18 -0
- data/lib/cucumber/chef/templates/cucumber-chef/config-rb.erb +33 -0
- data/lib/cucumber/chef/templates/cucumber-chef/cucumber-yml.erb +2 -0
- data/lib/cucumber/chef/templates/cucumber-chef/knife-rb.erb +18 -0
- data/lib/cucumber/chef/test_lab.rb +308 -52
- data/lib/cucumber/chef/test_runner.rb +86 -15
- data/lib/cucumber/chef/utility.rb +128 -0
- data/lib/cucumber/chef/version.rb +30 -1
- data/lib/cucumber/chef.rb +53 -20
- data/lib/cucumber-chef.rb +24 -1
- data/spec/cucumber/chef/config_spec.rb +144 -78
- data/spec/cucumber/chef/provisioner_spec.rb +60 -16
- data/spec/cucumber/chef/test_lab_spec.rb +62 -19
- data/spec/spec_helper.rb +30 -26
- data/todo.org +17 -0
- metadata +267 -163
- data/.document +0 -5
- data/VERSION +0 -1
- data/cookbooks/cucumber-chef/README.rdoc +0 -8
- data/cookbooks/cucumber-chef/files/default/add-git-identity +0 -2
- data/cookbooks/cucumber-chef/files/default/controller-first-boot +0 -1
- data/cookbooks/cucumber-chef/files/default/cucumber-private-key +0 -27
- data/cookbooks/cucumber-chef/files/default/cucumber-run_list +0 -1
- data/cookbooks/cucumber-chef/files/default/git-private-key +0 -27
- data/cookbooks/cucumber-chef/files/default/install-chef +0 -1
- data/cookbooks/cucumber-chef/files/default/lxc-controller-network-config +0 -5
- data/cookbooks/cucumber-chef/files/default/lxc-lucid-chef +0 -378
- data/cookbooks/cucumber-chef/metadata.rb +0 -6
- data/cookbooks/cucumber-chef/recipes/controller.rb +0 -51
- data/cookbooks/cucumber-chef/recipes/lxc.rb +0 -35
- data/cookbooks/cucumber-chef/recipes/test_lab.rb +0 -23
- data/cookbooks/cucumber-chef/recipes/testrunner.rb +0 -46
- data/cookbooks/cucumber-chef/roles/controller.rb +0 -7
- data/cookbooks/cucumber-chef/roles/test_lab_test.rb +0 -9
- data/cookbooks/cucumber-chef/templates/default/controller-client.erb +0 -5
- data/cookbooks/cucumber-chef/templates/default/lxc-lucid-chef +0 -385
- data/lib/cucumber/chef/handy.rb +0 -90
- data/lib/cucumber/chef/templates/controller.erb +0 -35
- data/lib/cucumber/chef/templates/env.rb +0 -16
- data/lib/cucumber/chef/templates/example_feature.erb +0 -11
- data/lib/cucumber/chef/templates/example_step.erb +0 -19
- data/lib/cucumber/chef/templates/readme.erb +0 -14
- data/lib/cucumber/chef/templates/ubuntu10.04-gems.erb +0 -43
- data/lib/cucumber/ec2_server_create.rb +0 -99
- data/website/website.html +0 -385
@@ -0,0 +1,202 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|
@@ -0,0 +1,69 @@
|
|
1
|
+
Description
|
2
|
+
===========
|
3
|
+
|
4
|
+
This cookbook is used to configure a Cucumber-Chef test lab.
|
5
|
+
|
6
|
+
Requirements
|
7
|
+
============
|
8
|
+
|
9
|
+
LXC 0.7.2 or higher is required.
|
10
|
+
|
11
|
+
Platforms
|
12
|
+
---------
|
13
|
+
|
14
|
+
The following platforms are supported by this cookbook:
|
15
|
+
|
16
|
+
* Debian
|
17
|
+
* Ubuntu
|
18
|
+
|
19
|
+
Recipes
|
20
|
+
=======
|
21
|
+
|
22
|
+
This section describes the recipes in the cookbook and how to use them in your environment.
|
23
|
+
|
24
|
+
lxc
|
25
|
+
---
|
26
|
+
|
27
|
+
Sets up Linux Containers for use by Cucumber-Chef.
|
28
|
+
|
29
|
+
test_lab
|
30
|
+
--------
|
31
|
+
|
32
|
+
Sets up the Cucumber-Chef test lab environment.
|
33
|
+
|
34
|
+
default
|
35
|
+
-------
|
36
|
+
|
37
|
+
Includes the `cucumber-chef::lxc` and `cucumber-chef::test_lab` recipes.
|
38
|
+
|
39
|
+
Roles
|
40
|
+
=====
|
41
|
+
|
42
|
+
This section describes the roles in the cookbook and how to use them in your environment.
|
43
|
+
|
44
|
+
test_lab
|
45
|
+
--------
|
46
|
+
|
47
|
+
Sets up the `default` recipe in the `run_list`.
|
48
|
+
|
49
|
+
Attributes
|
50
|
+
==========
|
51
|
+
|
52
|
+
Usage
|
53
|
+
=====
|
54
|
+
|
55
|
+
License and Author
|
56
|
+
==================
|
57
|
+
|
58
|
+
Author: Zachary Patten <zpatten@jovelabs.com>
|
59
|
+
|
60
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
61
|
+
you may not use this file except in compliance with the License.
|
62
|
+
You may obtain a copy of the License at
|
63
|
+
|
64
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
65
|
+
|
66
|
+
Unless required by applicable law or agreed to in writing, software
|
67
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
68
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
69
|
+
See the License for the specific language governing permissions and
|
@@ -0,0 +1,27 @@
|
|
1
|
+
################################################################################
|
2
|
+
#
|
3
|
+
# Author: Zachary Patten <zachary@jovelabs.com>
|
4
|
+
# Copyright: Copyright (c) 2011-2012 Atalanta Systems Ltd
|
5
|
+
# License: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
################################################################################
|
20
|
+
|
21
|
+
|
22
|
+
case platform
|
23
|
+
when "debian", "ubuntu"
|
24
|
+
|
25
|
+
when "redhat", "centos", "fedora"
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
maintainer "Zachary Patten"
|
2
|
+
maintainer_email "zpatten@jovelabs.com"
|
3
|
+
license "Apache 2.0"
|
4
|
+
description "Installs/Configures Cucumber-Chef"
|
5
|
+
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
6
|
+
version "2.0.0"
|
7
|
+
recipe "cucumber-chef", "Includes the lxc and test_lab recipes by default."
|
8
|
+
recipe "cucumber-chef::lxc", "Sets up and configures LXC for use by the Cucumber-Chef Test Lab."
|
9
|
+
recipe "cucumber-chef::test_lab", "Sets up the Cucumber-Chef Test Lab environment."
|
10
|
+
|
11
|
+
%w( ubuntu ).each do |os|
|
12
|
+
supports os
|
13
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
################################################################################
|
2
|
+
#
|
3
|
+
# Author: Zachary Patten <zachary@jovelabs.com>
|
4
|
+
# Copyright: Copyright (c) 2011-2012 Atalanta Systems Ltd
|
5
|
+
# License: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
################################################################################
|
20
|
+
|
21
|
+
|
22
|
+
include_recipe "cucumber-chef::lxc"
|
23
|
+
include_recipe "cucumber-chef::test_lab"
|
@@ -0,0 +1,315 @@
|
|
1
|
+
################################################################################
|
2
|
+
#
|
3
|
+
# Author: Zachary Patten <zachary@jovelabs.com>
|
4
|
+
# Copyright: Copyright (c) 2011-2012 Atalanta Systems Ltd
|
5
|
+
# License: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
################################################################################
|
20
|
+
|
21
|
+
|
22
|
+
%w( lxc bridge-utils debootstrap yum isc-dhcp-server bind9 ntpdate ntp ).each do |p|
|
23
|
+
package p
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
################################################################################
|
28
|
+
# APPARMOR
|
29
|
+
################################################################################
|
30
|
+
service "apparmor"
|
31
|
+
|
32
|
+
bash "configure apparmor so dhcp3 can read /etc/bind" do
|
33
|
+
code <<-EOH
|
34
|
+
cat <<EOF >> /etc/apparmor.d/local/usr.sbin.dhcpd
|
35
|
+
/etc/bind/ r,
|
36
|
+
/etc/bind/** r,
|
37
|
+
EOF
|
38
|
+
EOH
|
39
|
+
|
40
|
+
notifies :restart, "service[apparmor]"
|
41
|
+
|
42
|
+
not_if do
|
43
|
+
%x( cat /etc/apparmor.d/local/usr.sbin.dhcpd3 | grep "\/etc\/bind\/" )
|
44
|
+
($? == 0)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
################################################################################
|
50
|
+
# NETWORKING
|
51
|
+
################################################################################
|
52
|
+
service "networking"
|
53
|
+
|
54
|
+
execute "add local bind to dhclient" do
|
55
|
+
command "sed -i \"s/#prepend domain-name-servers 127.0.0.1;/prepend domain-name-servers 127.0.0.1;\\nsupersede domain-name \\\"test-lab\\\";\\nsupersede domain-search \\\"test-lab\\\";/\" /etc/dhcp/dhclient.conf"
|
56
|
+
|
57
|
+
notifies :restart, "service[networking]"
|
58
|
+
|
59
|
+
only_if do
|
60
|
+
%x( cat /etc/dhcp/dhclient.conf | grep "#prepend domain-name-servers 127.0.0.1;" )
|
61
|
+
($? == 0)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
bash "configure bridge interface" do
|
66
|
+
code <<-EOH
|
67
|
+
cat <<EOF >> /etc/network/interfaces
|
68
|
+
|
69
|
+
# The bridge network interface
|
70
|
+
auto br0
|
71
|
+
iface br0 inet static
|
72
|
+
address 192.168.255.254
|
73
|
+
netmask 255.255.0.0
|
74
|
+
pre-up brctl addbr br0
|
75
|
+
post-down brctl delbr br0
|
76
|
+
EOF
|
77
|
+
EOH
|
78
|
+
|
79
|
+
notifies :restart, "service[networking]"
|
80
|
+
|
81
|
+
not_if do
|
82
|
+
%x( cat /etc/network/interfaces | grep "iface br0 inet static" )
|
83
|
+
($? == 0)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
execute "enable ipv4 packet forwarding" do
|
88
|
+
command "sysctl -w net.ipv4.ip_forward=1"
|
89
|
+
|
90
|
+
notifies :restart, "service[networking]"
|
91
|
+
|
92
|
+
not_if do
|
93
|
+
%x( sysctl net.ipv4.ip_forward | grep "net.ipv4.ip_forward = 1" )
|
94
|
+
($? == 0)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
execute "enable nat for outbound traffic" do
|
99
|
+
command "iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE"
|
100
|
+
|
101
|
+
notifies :restart, "service[networking]"
|
102
|
+
|
103
|
+
not_if do
|
104
|
+
%x( iptables -t nat --list | grep "MASQUERADE" )
|
105
|
+
($? == 0)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
################################################################################
|
111
|
+
# BIND9
|
112
|
+
################################################################################
|
113
|
+
service "bind9"
|
114
|
+
|
115
|
+
file "make mode on rndc.key o+r" do
|
116
|
+
path "/etc/bind/rndc.key"
|
117
|
+
mode 0644
|
118
|
+
|
119
|
+
notifies :restart, "service[bind9]"
|
120
|
+
|
121
|
+
not_if { ("%o" % File.stat("/etc/bind/rndc.key").mode) == "100644" }
|
122
|
+
end
|
123
|
+
|
124
|
+
template "setup our bind9 zone and controls configuration" do
|
125
|
+
path "/etc/bind/named.conf.test-lab"
|
126
|
+
source "named-conf-local.erb"
|
127
|
+
owner "root"
|
128
|
+
group "bind"
|
129
|
+
mode "0644"
|
130
|
+
|
131
|
+
notifies :restart, "service[bind9]"
|
132
|
+
|
133
|
+
not_if { File.exists?("/etc/bind/named.conf.test-lab") }
|
134
|
+
end
|
135
|
+
|
136
|
+
bash "inject test-lab bind9 configuration" do
|
137
|
+
code <<-EOH
|
138
|
+
cat <<EOF >> /etc/bind/named.conf
|
139
|
+
include "/etc/bind/named.conf.test-lab";
|
140
|
+
EOF
|
141
|
+
EOH
|
142
|
+
|
143
|
+
notifies :restart, "service[bind9]"
|
144
|
+
|
145
|
+
not_if do
|
146
|
+
%x( cat /etc/bind/named.conf | grep "\/etc\/bind\/named\.conf\.test-lab" )
|
147
|
+
($? == 0)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
template "create test-lab zone file" do
|
152
|
+
path "/var/lib/bind/db.test-lab"
|
153
|
+
source "db-test-lab.erb"
|
154
|
+
owner "root"
|
155
|
+
group "bind"
|
156
|
+
mode "0644"
|
157
|
+
|
158
|
+
notifies :restart, "service[bind9]"
|
159
|
+
|
160
|
+
not_if { File.exists?("/var/lib/bind/db.test-lab") }
|
161
|
+
end
|
162
|
+
|
163
|
+
template "create 168.192 zone file" do
|
164
|
+
path "/var/lib/bind/db.168.192"
|
165
|
+
source "db-168-192.erb"
|
166
|
+
owner "root"
|
167
|
+
group "bind"
|
168
|
+
mode "0644"
|
169
|
+
|
170
|
+
notifies :restart, "service[bind9]"
|
171
|
+
|
172
|
+
not_if { File.exists?("/var/lib/bind/db.168.192") }
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
################################################################################
|
177
|
+
# ISC-DHCP-SERVER
|
178
|
+
################################################################################
|
179
|
+
service "isc-dhcp-server"
|
180
|
+
|
181
|
+
file "touch our dhcp3 include file" do
|
182
|
+
path "/etc/dhcp/test-lab.conf"
|
183
|
+
action :touch
|
184
|
+
|
185
|
+
notifies :restart, "service[isc-dhcp-server]"
|
186
|
+
|
187
|
+
not_if { File.exists?("/etc/dhcp/test-lab.conf") }
|
188
|
+
end
|
189
|
+
|
190
|
+
template "configure isc-dhcp-server for test-lab" do
|
191
|
+
path "/etc/dhcp/dhcpd.conf"
|
192
|
+
source "dhcpd-conf.erb"
|
193
|
+
owner "root"
|
194
|
+
group "root"
|
195
|
+
mode "0644"
|
196
|
+
|
197
|
+
notifies :restart, "service[isc-dhcp-server]"
|
198
|
+
|
199
|
+
not_if do
|
200
|
+
%x( cat /etc/dhcp/dhcpd.conf | grep "\/etc\/dhcp\/test-lab\.conf" )
|
201
|
+
($? == 0)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
execute "configure isc-dhcp-server listener interface" do
|
206
|
+
command "sed -i \"s/INTERFACES=\\\"\\\"/INTERFACES=\\\"br0\\\"/\" /etc/default/isc-dhcp-server"
|
207
|
+
|
208
|
+
notifies :restart, "service[isc-dhcp-server]"
|
209
|
+
|
210
|
+
not_if do
|
211
|
+
%x( cat /etc/default/isc-dhcp-server | grep "INTERFACES=\\\"br0\\\"" )
|
212
|
+
($? == 0)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
|
217
|
+
################################################################################
|
218
|
+
# LXC
|
219
|
+
################################################################################
|
220
|
+
service "lxc-net"
|
221
|
+
service "lxc"
|
222
|
+
|
223
|
+
#directory "create cgroup mount point" do
|
224
|
+
# path "/cgroup"
|
225
|
+
#
|
226
|
+
# not_if { File.exists?("/cgroup") && File.directory?("/cgroup") }
|
227
|
+
#end
|
228
|
+
|
229
|
+
#mount "mount cgroup device" do
|
230
|
+
# mount_point "/cgroup"
|
231
|
+
# device "cgroup"
|
232
|
+
# fstype "cgroup"
|
233
|
+
# pass 0
|
234
|
+
# action [:mount, :enable]
|
235
|
+
|
236
|
+
# not_if do
|
237
|
+
# %x( mount | grep "cgroup" )
|
238
|
+
# ($? == 0)
|
239
|
+
# end
|
240
|
+
#end
|
241
|
+
|
242
|
+
execute "set LXC_AUTO to false" do
|
243
|
+
command "sed -i \"s/LXC_AUTO=\\\"true\\\"/LXC_AUTO=\\\"false\\\"/\" /etc/default/lxc"
|
244
|
+
|
245
|
+
notifies :stop, "service[lxc-net]"
|
246
|
+
|
247
|
+
only_if do
|
248
|
+
%x( cat /etc/default/lxc | grep "LXC_AUTO=\\\"true\\\"" )
|
249
|
+
($? == 0)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
execute "set USE_LXC_BRIDGE to false" do
|
254
|
+
command "sed -i \"s/USE_LXC_BRIDGE=\\\"true\\\"/USE_LXC_BRIDGE=\\\"false\\\"/\" /etc/default/lxc"
|
255
|
+
|
256
|
+
notifies :stop, "service[lxc-net]"
|
257
|
+
|
258
|
+
only_if do
|
259
|
+
%x( cat /etc/default/lxc | grep "USE_LXC_BRIDGE=\\\"true\\\"" )
|
260
|
+
($? == 0)
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
directory "create lxc configuration directory" do
|
265
|
+
path "/etc/lxc"
|
266
|
+
|
267
|
+
not_if { File.exists?("/etc/lxc") && File.directory?("/etc/lxc") }
|
268
|
+
end
|
269
|
+
|
270
|
+
=begin
|
271
|
+
# load the chef client into our distro lxc cache
|
272
|
+
install_chef_sh = "/tmp/install-chef.sh"
|
273
|
+
distros = { "ubuntu" => [ "lucid", "maverick", "natty", "oneiric", "precise" ] }
|
274
|
+
arch = (%x( arch ).include?("i686") ? "i386" : "amd64")
|
275
|
+
|
276
|
+
template "create lxc initializer container configuration" do
|
277
|
+
path "/etc/lxc/initializer"
|
278
|
+
source "lxc-initializer-config.erb"
|
279
|
+
|
280
|
+
not_if { File.exists?("/etc/lxc/initializer") }
|
281
|
+
end
|
282
|
+
|
283
|
+
distros.each do |distro, releases|
|
284
|
+
releases.each do |release|
|
285
|
+
cache_rootfs = File.join("/", "var", "cache", "lxc", release, "rootfs-#{arch}")
|
286
|
+
initializer_rootfs = File.join("/", "var", "lib", "lxc", "initializer", "rootfs")
|
287
|
+
|
288
|
+
execute "create the lxc initializer container for #{distro}/#{release}" do
|
289
|
+
command "lxc-create -n initializer -f /etc/lxc/initializer -t #{distro} -- -r #{release}"
|
290
|
+
|
291
|
+
not_if { File.exists?(cache_rootfs) && File.directory?(cache_rootfs) }
|
292
|
+
end
|
293
|
+
|
294
|
+
execute "destroy the lxc initializer container for #{distro}/#{release}" do
|
295
|
+
command "lxc-destroy -n initializer"
|
296
|
+
|
297
|
+
only_if { File.exists?(initializer_rootfs) && File.directory?(initializer_rootfs) }
|
298
|
+
end
|
299
|
+
|
300
|
+
template "create opscode omnibus installer in lxc container cache for #{distro}/#{release}" do
|
301
|
+
path "#{cache_rootfs}#{install_chef_sh}"
|
302
|
+
source "lxc-install-chef.erb"
|
303
|
+
mode "0755"
|
304
|
+
|
305
|
+
not_if { File.exists?(File.join(cache_rootfs, install_chef_sh)) }
|
306
|
+
end
|
307
|
+
|
308
|
+
execute "install chef-client using omnibus in lxc container cache for #{distro}/#{release}" do
|
309
|
+
command "chroot #{cache_rootfs} /bin/bash -c '#{install_chef_sh}'"
|
310
|
+
|
311
|
+
not_if { File.exists?(File.join(cache_rootfs, "opt", "opscode", "bin", "chef-client")) }
|
312
|
+
end
|
313
|
+
end
|
314
|
+
end
|
315
|
+
=end
|