spiceweasel 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +201 -0
- data/README.md +141 -241
- data/bin/spiceweasel +2 -104
- data/lib/spiceweasel.rb +5 -11
- data/lib/spiceweasel/cli.rb +249 -83
- data/lib/spiceweasel/clusters.rb +53 -0
- data/lib/spiceweasel/config.rb +46 -0
- data/lib/spiceweasel/cookbooks.rb +105 -0
- data/lib/spiceweasel/data_bags.rb +89 -0
- data/lib/spiceweasel/environments.rb +103 -0
- data/lib/spiceweasel/execute.rb +42 -0
- data/lib/spiceweasel/extract_local.rb +130 -0
- data/lib/spiceweasel/log.rb +30 -0
- data/lib/spiceweasel/nodes.rb +126 -0
- data/lib/spiceweasel/roles.rb +131 -0
- data/lib/spiceweasel/version.rb +1 -1
- data/spec/bin/spiceweasel_spec.rb +44 -12
- metadata +106 -25
- data/lib/spiceweasel/cookbook_data.rb +0 -66
- data/lib/spiceweasel/cookbook_list.rb +0 -96
- data/lib/spiceweasel/data_bag_list.rb +0 -81
- data/lib/spiceweasel/directory_extractor.rb +0 -121
- data/lib/spiceweasel/environment_list.rb +0 -96
- data/lib/spiceweasel/node_list.rb +0 -98
- data/lib/spiceweasel/role_list.rb +0 -124
data/LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
data/README.md
CHANGED
@@ -1,176 +1,51 @@
|
|
1
|
-
Description
|
2
|
-
===========
|
3
|
-
Spiceweasel is a command-line tool for batch loading Chef infrastructure from a file. It provides a simple syntax in either JSON or YAML for describing and deploying infrastructure in order with the Chef command-line tool `knife`. This manifest may be bundled with a Chef repository to deploy the infrastructure contained within the repository and validate that the components listed are all present.
|
1
|
+
# Description #
|
4
2
|
|
5
|
-
|
3
|
+
Spiceweasel is a command-line tool for batch loading Chef infrastructure from a file. It provides a simple syntax in either JSON or YAML for describing and deploying infrastructure in order with the Chef command-line tool `knife`. This manifest may be bundled with a Chef repository to deploy the infrastructure contained within the repository and validate that the components listed are all present.
|
6
4
|
|
7
|
-
The
|
5
|
+
The `examples` directory provides example manifests based on the Quick Starts provided at http://help.opscode.com/kb/otherhelp. The https://github.com/mattray/vbacd-repo provides a working example for bootstrapping a Chef repository with Spiceweasel.
|
8
6
|
|
9
7
|
The [CHANGELOG.md](https://github.com/mattray/spiceweasel/blob/master/CHANGELOG.md) covers current, previous and future development milestones and contains the features backlog.
|
10
8
|
|
11
|
-
Requirements
|
12
|
-
============
|
13
|
-
Spiceweasel currently depends on `knife` to run commands for it, but does not explicitly depend on the `chef` gem yet. Infrastructure files must either end in .json or .yml to be processed.
|
9
|
+
# Requirements #
|
14
10
|
|
15
|
-
|
11
|
+
Spiceweasel currently depends on `knife` to run commands for it, and requires the `chef` gem for validating cookbook metadata. Infrastructure files must either end in `.json` or `.yml` to be processed.
|
16
12
|
|
17
|
-
|
18
|
-
===========
|
19
|
-
The syntax for the spiceweasel file may be either JSON or YAML format of Chef primitives describing what is to be instantiated. Below or 2 examples describing the same infrastructure.
|
13
|
+
Written and tested initially with Chef 0.9.12 (may still work) and continuing development with the 10.x series. It is tested with Ruby 1.8.7 and 1.9.2.
|
20
14
|
|
21
|
-
|
22
|
-
----
|
23
|
-
From the `example.yml`:
|
15
|
+
# File Syntax #
|
24
16
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
- rabbitmq
|
51
|
-
nodes:
|
52
|
-
- serverA:
|
53
|
-
- role[base]
|
54
|
-
- -i ~/.ssh/mray.pem -x user --sudo -d ubuntu10.04-gems
|
55
|
-
- serverB serverC:
|
56
|
-
- role[base]
|
57
|
-
- -i ~/.ssh/mray.pem -x user --sudo -d ubuntu10.04-gems -E production
|
58
|
-
- ec2 3:
|
59
|
-
- role[webserver] recipe[mysql::client]
|
60
|
-
- -S mray -i ~/.ssh/mray.pem -x ubuntu -G default -I ami-7000f019 -f m1.small
|
61
|
-
- rackspace 3:
|
62
|
-
- recipe[mysql],role[monitoring]
|
63
|
-
- --image 49 --flavor 2 --node-name rs{{n}}.example.com
|
64
|
-
- windows_winrm winboxA:
|
65
|
-
- role[base],role[iisserver]
|
66
|
-
- -x Administrator -P 'super_secret_password'
|
67
|
-
- windows_ssh winboxB winboxC:
|
68
|
-
- role[base],role[iisserver]
|
69
|
-
- -x Administrator -P 'super_secret_password'
|
70
|
-
```
|
71
|
-
|
72
|
-
JSON
|
73
|
-
----
|
74
|
-
From the `example.json`:
|
75
|
-
|
76
|
-
``` json
|
77
|
-
{
|
78
|
-
"cookbooks":
|
79
|
-
[
|
80
|
-
{"apache2":[]},
|
81
|
-
{"apt":
|
82
|
-
[
|
83
|
-
"1.2.0"
|
84
|
-
]
|
85
|
-
},
|
86
|
-
{"mysql":[]}
|
87
|
-
],
|
88
|
-
"environments":
|
89
|
-
[
|
90
|
-
{"development":[]},
|
91
|
-
{"qa":[]},
|
92
|
-
{"production":[]}
|
93
|
-
],
|
94
|
-
"roles":
|
95
|
-
[
|
96
|
-
{"base":[]},
|
97
|
-
{"iisserver":[]},
|
98
|
-
{"monitoring":[]},
|
99
|
-
{"webserver":[]}
|
100
|
-
],
|
101
|
-
"data bags":
|
102
|
-
[
|
103
|
-
{"users":
|
104
|
-
[
|
105
|
-
"alice",
|
106
|
-
"bob",
|
107
|
-
"chuck"
|
108
|
-
]
|
109
|
-
},
|
110
|
-
{"data":
|
111
|
-
[
|
112
|
-
"*"
|
113
|
-
]
|
114
|
-
},
|
115
|
-
{"passwords":
|
116
|
-
[
|
117
|
-
"secret secret_key",
|
118
|
-
"mysql",
|
119
|
-
"rabbitmq"
|
120
|
-
]
|
121
|
-
}
|
122
|
-
],
|
123
|
-
"nodes":
|
124
|
-
[
|
125
|
-
{"serverA":
|
126
|
-
[
|
127
|
-
"role[base]",
|
128
|
-
"-i ~/.ssh/mray.pem -x user --sudo -d ubuntu10.04-gems"
|
129
|
-
]
|
130
|
-
},
|
131
|
-
{"serverB serverC":
|
132
|
-
[
|
133
|
-
"role[base]",
|
134
|
-
"-i ~/.ssh/mray.pem -x user --sudo -d ubuntu10.04-gems -E production"
|
135
|
-
]
|
136
|
-
},
|
137
|
-
{"ec2 3":
|
138
|
-
[
|
139
|
-
"role[webserver] recipe[mysql::client]",
|
140
|
-
"-S mray -i ~/.ssh/mray.pem -x ubuntu -G default -I ami-7000f019 -f m1.small"
|
141
|
-
]
|
142
|
-
},
|
143
|
-
{"rackspace 3":
|
144
|
-
[
|
145
|
-
"recipe[mysql],role[monitoring]",
|
146
|
-
"--image 49 --flavor 2 --node-name rs{{n}}.example.com"
|
147
|
-
]
|
148
|
-
},
|
149
|
-
{"windows_winrm winboxA":
|
150
|
-
[
|
151
|
-
"role[base],role[iisserver]",
|
152
|
-
"-x Administrator -P 'super_secret_password'"
|
153
|
-
]
|
154
|
-
},
|
155
|
-
{"windows_ssh winboxB winboxC":
|
156
|
-
[
|
157
|
-
"role[base],role[iisserver]",
|
158
|
-
"-x Administrator -P 'super_secret_password'"
|
159
|
-
]
|
160
|
-
}
|
161
|
-
]
|
162
|
-
}
|
163
|
-
```
|
164
|
-
|
165
|
-
Cookbooks
|
166
|
-
---------
|
167
|
-
The `cookbooks` section of the manifest currently supports `knife cookbook upload FOO` where `FOO` is the name of the cookbook in the `cookbooks` directory. The default behavior is to download the cookbook as a tarball, untar it and remove the tarball. The `--siteinstall` option will allow for use of `knife cookbook site install` with the cookbook and the creation of a vendor branch if git is the underlying version control. If a version is passed, it is validated against the existing cookbook `metadata.rb` and it must match the `metadata.rb` string exactly. You may pass any additional arguments if necessary. Assuming the apt cookbook was not present, the example YAML snippet
|
17
|
+
The syntax for the Spiceweasel file may be either JSON or YAML format of Chef primitives describing what is to be instantiated. Please refer to the [examples/example.json](https://github.com/mattray/spiceweasel/blob/master/examples/example.json) or [examples/example.yml](https://github.com/mattray/spiceweasel/blob/master/examples/example.yml) for examples of the same infrastructure. Each subsection below shows the YAML syntax converted to knife commands.
|
18
|
+
|
19
|
+
## Manifest syntax changes in Spiceweasel 2.0 ##
|
20
|
+
|
21
|
+
In order to be more explicit and enable a richer set of options, the syntax for the manifests was updated. Rather than depend on the order of arrays for the attributes of cookbooks, data bags and nodes; the attributes are now hashes with keys identifying the features.
|
22
|
+
|
23
|
+
### New Cookbooks Syntax ###
|
24
|
+
|
25
|
+
The currently supported keys are `version` and `options` and their values are strings.
|
26
|
+
|
27
|
+
### New Data Bags Syntax ###
|
28
|
+
|
29
|
+
The supported keys are `items` (an array of the data bag items) and `secret` for passing a secret key string.
|
30
|
+
|
31
|
+
### New Nodes Syntax ###
|
32
|
+
|
33
|
+
The supported keys are `run_list` and `options` and their values are strings.
|
34
|
+
|
35
|
+
### New Clusters Syntax ###
|
36
|
+
|
37
|
+
Clusters support is completely new, please refer to the Cluster section for documentation.
|
38
|
+
|
39
|
+
## Cookbooks ##
|
40
|
+
|
41
|
+
The `cookbooks` section of the manifest currently supports `knife cookbook upload FOO` where `FOO` is the name of the cookbook in the `cookbooks` directory. The default behavior is to download the cookbook as a tarball, untar it and remove the tarball. The `--siteinstall` option will allow for use of `knife cookbook site install` with the cookbook and the creation of a vendor branch if git is the underlying version control. Validation is done to ensure the cookbook matches the name (and version if given) in the metadata and that any cookbook dependencies are listed in the manifest. You may pass any additional options if necessary. Assuming the apt cookbook was not present, the example YAML snippet
|
168
42
|
|
169
43
|
``` yaml
|
170
44
|
cookbooks:
|
171
45
|
- apache2:
|
172
46
|
- apt:
|
173
|
-
|
47
|
+
version: 1.2.0
|
48
|
+
options: --freeze
|
174
49
|
- mysql:
|
175
50
|
```
|
176
51
|
|
@@ -181,12 +56,12 @@ knife cookbook upload apache2
|
|
181
56
|
knife cookbook site download apt 1.2.0 --file cookbooks/apt.tgz
|
182
57
|
tar -C cookbooks/ -xf cookbooks/apt.tgz
|
183
58
|
rm -f cookbooks/apt.tgz
|
184
|
-
knife cookbook upload apt
|
59
|
+
knife cookbook upload apt --freeze
|
185
60
|
knife cookbook upload mysql
|
186
61
|
```
|
187
62
|
|
188
|
-
Environments
|
189
|
-
|
63
|
+
## Environments ##
|
64
|
+
|
190
65
|
The `environments` section of the manifest currently supports `knife environment from file FOO` where `FOO` is the name of the environment file ending in `.rb` or `.json` in the `environments` directory. Validation is done to ensure the filename matches the environment and that any cookbooks referenced are listed in the manifest. The example YAML snippet
|
191
66
|
|
192
67
|
``` yaml
|
@@ -204,13 +79,14 @@ knife environment from file qa.rb
|
|
204
79
|
knife environment from file production.rb
|
205
80
|
```
|
206
81
|
|
207
|
-
Roles
|
208
|
-
|
82
|
+
## Roles ##
|
83
|
+
|
209
84
|
The `roles` section of the manifest currently supports `knife role from file FOO` where `FOO` is the name of the role file ending in `.rb` or `.json` in the `roles` directory. Validation is done to ensure the filename matches the role name and that any cookbooks or roles referenced are listed in the manifest. The example YAML snippet
|
210
85
|
|
211
86
|
``` yaml
|
212
87
|
roles:
|
213
88
|
- base:
|
89
|
+
- iisserver:
|
214
90
|
- monitoring:
|
215
91
|
- webserver:
|
216
92
|
```
|
@@ -219,26 +95,30 @@ produces the knife commands
|
|
219
95
|
|
220
96
|
```
|
221
97
|
knife role from file base.rb
|
98
|
+
knife role from file iisserver.rb
|
222
99
|
knife role from file monitoring.rb
|
223
100
|
knife role from file webserver.rb
|
224
101
|
```
|
225
102
|
|
226
|
-
Data Bags
|
227
|
-
|
228
|
-
The `data bags` section of the manifest currently creates the data bags listed with `knife data bag create FOO` where `FOO` is the name of the data bag. Individual items may be added to the data bag as part of a JSON or YAML sequence, the assumption is made that they `.json` files and in the proper `data_bags/FOO` directory. You may also pass a wildcard as an entry to load all matching data bags (ie. `"*"`). Encrypted data bags are supported by
|
103
|
+
n## Data Bags ##
|
104
|
+
|
105
|
+
The `data bags` section of the manifest currently creates the data bags listed with `knife data bag create FOO` where `FOO` is the name of the data bag. Individual items may be added to the data bag as part of a JSON or YAML sequence, the assumption is made that they `.json` files and in the proper `data_bags/FOO` directory. You may also pass a wildcard as an entry to load all matching data bags (ie. `"*"`). Encrypted data bags are supported by using the `secret: secret_key_filename` attribute. Validation is done to ensure the JSON is properly formatted, the id matches and any secret key files are in the correct locations. Assuming the presence of `dataA.json` and `dataB.json` in the `data_bags/data` directory, the YAML snippet
|
229
106
|
|
230
107
|
``` yaml
|
231
108
|
data bags:
|
232
109
|
- users:
|
233
|
-
|
234
|
-
|
235
|
-
|
110
|
+
items:
|
111
|
+
- alice
|
112
|
+
- bob
|
113
|
+
- chuck
|
236
114
|
- data:
|
237
|
-
|
115
|
+
items:
|
116
|
+
- "*"
|
238
117
|
- passwords:
|
239
|
-
|
240
|
-
|
241
|
-
|
118
|
+
secret: secret_key_filename
|
119
|
+
items:
|
120
|
+
- mysql
|
121
|
+
- rabbitmq
|
242
122
|
```
|
243
123
|
|
244
124
|
produces the knife commands
|
@@ -252,48 +132,39 @@ knife data bag create data
|
|
252
132
|
knife data bag from file data dataA.json
|
253
133
|
knife data bag from file data dataB.json
|
254
134
|
knife data bag create passwords
|
255
|
-
knife data bag from file passwords mysql.json --secret-file
|
256
|
-
knife data bag from file passwords rabbitmq.json --secret-file
|
135
|
+
knife data bag from file passwords mysql.json --secret-file secret_key_filename
|
136
|
+
knife data bag from file passwords rabbitmq.json --secret-file secret_key_filename
|
257
137
|
```
|
258
138
|
|
259
|
-
Nodes
|
260
|
-
-----
|
261
|
-
The `nodes` section of the manifest bootstraps a node for each entry where the entry is a hostname or provider and count. A shortcut syntax for bulk-creating nodes with various providers where the line starts with the provider and ends with the number of nodes to be provisioned. Windows nodes need to specify either `windows_winrm` or `windows_ssh` depending on the protocol used, followed by the name of the node(s). Each node requires 2 items after it in a sequence. You may also use the `--parallel` flag from the command line, allowing provider commands to run simultaneously for faster deployment. If you want to give your nodes names, simply pass `-N NAME{{n}}` or `--node-name NAME{{n}}` and the `{{n}}` will be substituted by a number (works with or without --parallel).
|
139
|
+
## Nodes ##
|
262
140
|
|
263
|
-
The
|
141
|
+
The `nodes` section of the manifest bootstraps a node for each entry given a hostname or a provider with a count. Windows nodes need to specify either `windows_winrm` or `windows_ssh` depending on the protocol used, followed by the name of the node(s). Each node may have a `run_list` and `options`. The `run_list` may be space or comma-delimited. Validation is performed on the `run_list` components to ensure that only `cookbooks` and `roles` listed in the manifest are used. Validation on the options ensures that any `environments` referenced are also listed. You may specify multiple nodes to have the same configuration by listing them separated by a space. If you want to give your nodes names, simply pass `-N NAME{{n}}` or `--node-name NAME{{n}}` and the `{{n}}` will be substituted by a number. The example YAML snippet
|
264
142
|
|
265
143
|
``` yaml
|
266
144
|
nodes:
|
267
145
|
- serverA:
|
268
|
-
|
269
|
-
|
146
|
+
run_list: role[base]
|
147
|
+
options: -i ~/.ssh/mray.pem -x user --sudo
|
270
148
|
- serverB serverC:
|
271
|
-
|
272
|
-
|
273
|
-
- ec2 3:
|
274
|
-
- role[webserver] recipe[mysql::client]
|
275
|
-
- -S mray -i ~/.ssh/mray.pem -x ubuntu -G default -I ami-7000f019 -f m1.small
|
149
|
+
run_list: role[base]
|
150
|
+
options: -i ~/.ssh/mray.pem -x user --sudo -E production
|
276
151
|
- rackspace 3:
|
277
|
-
|
278
|
-
|
152
|
+
run_list: recipe[mysql],role[monitoring]
|
153
|
+
options: --image 49 --flavor 2 -N db{{n}}
|
279
154
|
- windows_winrm winboxA:
|
280
|
-
|
281
|
-
|
155
|
+
run_list: role[base],role[iisserver]
|
156
|
+
options: -x Administrator -P 'super_secret_password'
|
282
157
|
- windows_ssh winboxB winboxC:
|
283
|
-
|
284
|
-
|
158
|
+
run_list: role[base],role[iisserver]
|
159
|
+
options: -x Administrator -P 'super_secret_password'
|
285
160
|
```
|
286
161
|
|
287
162
|
produces the knife commands
|
288
163
|
|
289
164
|
```
|
290
|
-
knife bootstrap serverA -i ~/.ssh/mray.pem -x user --sudo -
|
291
|
-
knife bootstrap serverB -i ~/.ssh/mray.pem -x user --sudo -
|
292
|
-
knife bootstrap serverC -i ~/.ssh/mray.pem -x user --sudo -
|
293
|
-
knife ec2 server create -S mray -i ~/.ssh/mray.pem -x ubuntu -G default -I ami-7000f019 -f m1.small -r 'role[webserver],recipe[mysql::client]'
|
294
|
-
knife ec2 server create -S mray -i ~/.ssh/mray.pem -x ubuntu -G default -I ami-7000f019 -f m1.small -r 'role[webserver],recipe[mysql::client]'
|
295
|
-
knife ec2 server create -S mray -i ~/.ssh/mray.pem -x ubuntu -G default -I ami-7000f019 -f m1.small -r 'role[webserver],recipe[mysql::client]'
|
296
|
-
knife ec2 server create -S mray -i ~/.ssh/mray.pem -x ubuntu -G default -I ami-7000f019 -f m1.small -r 'role[webserver],recipe[mysql::client]'
|
165
|
+
knife bootstrap serverA -i ~/.ssh/mray.pem -x user --sudo -r 'role[base]'
|
166
|
+
knife bootstrap serverB -i ~/.ssh/mray.pem -x user --sudo -E production -r 'role[base]'
|
167
|
+
knife bootstrap serverC -i ~/.ssh/mray.pem -x user --sudo -E production -r 'role[base]'
|
297
168
|
knife rackspace server create --image 49 --flavor 2 --node-name rs1.example.com -r 'recipe[mysql],role[monitoring]'
|
298
169
|
knife rackspace server create --image 49 --flavor 2 --node-name rs2.example.com -r 'recipe[mysql],role[monitoring]'
|
299
170
|
knife rackspace server create --image 49 --flavor 2 --node-name rs3.example.com -r 'recipe[mysql],role[monitoring]'
|
@@ -302,7 +173,7 @@ knife bootstrap windows ssh winboxB -x Administrator -P 'super_secret_password'
|
|
302
173
|
knife bootstrap windows ssh winboxC -x Administrator -P 'super_secret_password' -r 'role[base],role[iisserver]'
|
303
174
|
```
|
304
175
|
|
305
|
-
Using `--parallel` with the following block and the `-N webserver{{n}}
|
176
|
+
You may also use the `--parallel` flag from the command line, allowing provider commands to run simultaneously for faster deployment. Using `--parallel` with the following block and the `-N webserver{{n}}`:
|
306
177
|
|
307
178
|
``` yaml
|
308
179
|
nodes:
|
@@ -319,8 +190,34 @@ seq 3 | parallel -j 0 -v "knife ec2 server create -S mray -i ~/.ssh/mray.pem -x
|
|
319
190
|
|
320
191
|
which generates nodes named "webserver1", "webserver2" and "webserver3".
|
321
192
|
|
322
|
-
|
323
|
-
|
193
|
+
## Clusters ##
|
194
|
+
|
195
|
+
Clusters are not a type supported by Chef, this is a logical construct added by Spiceweasel to enable managing sets of infrastructure together. The `clusters` section is a special case of `nodes`, where each member of the named cluster in the manifest will be tagged to ensure that the entire cluster may be created in sync (refresh and delete coming soon). The node syntax is the same as that under `nodes`, the only addition is the cluster name.
|
196
|
+
|
197
|
+
```
|
198
|
+
clusters:
|
199
|
+
- amazon:
|
200
|
+
- ec2 1:
|
201
|
+
run_list: role[mysql]
|
202
|
+
options: -S mray -i ~/.ssh/mray.pem -x ubuntu -G default -I ami-8af0f326 -f m1.medium
|
203
|
+
- ec2 3:
|
204
|
+
run_list: role[webserver] recipe[mysql::client]
|
205
|
+
options: -S mray -i ~/.ssh/mray.pem -x ubuntu -G default -I ami-7000f019 -f m1.small
|
206
|
+
```
|
207
|
+
|
208
|
+
produces the knife commands
|
209
|
+
|
210
|
+
```
|
211
|
+
knife ec2 server create -S mray -i ~/.ssh/mray.pem -x ubuntu -G default -I ami-8af0f326 -f m1.medium -j '{"tags":["amazon+rolemysql"]}' -r 'role[mysql]'
|
212
|
+
knife ec2 server create -S mray -i ~/.ssh/mray.pem -x ubuntu -G default -I ami-7000f019 -f m1.small -j '{"tags":["amazon+rolewebserverrecipemysqlclient"]}' -r 'role[webserver],recipe[mysql::client]'
|
213
|
+
knife ec2 server create -S mray -i ~/.ssh/mray.pem -x ubuntu -G default -I ami-7000f019 -f m1.small -j '{"tags":["amazon+rolewebserverrecipemysqlclient"]}' -r 'role[webserver],recipe[mysql::client]'
|
214
|
+
knife ec2 server create -S mray -i ~/.ssh/mray.pem -x ubuntu -G default -I ami-7000f019 -f m1.small -j '{"tags":["amazon+rolewebserverrecipemysqlclient"]}' -r 'role[webserver],recipe[mysql::client]'
|
215
|
+
```
|
216
|
+
|
217
|
+
Another use of `clusters` is with the `--cluster-file` option, which will allow the use of a different file to define the members of the cluster. If there are any `nodes` or `clusters` defined in the primary manifest file, they will be removed and the content of the `--cluster-file` will be used instead. This allows you to switch the target destination of infrastructure by picking different `--cluster-file` endpoints.
|
218
|
+
|
219
|
+
# Extract #
|
220
|
+
|
324
221
|
Spiceweasel may also be used to generate knife commands or Spiceweasel manifests in JSON or YAML.
|
325
222
|
|
326
223
|
```
|
@@ -338,9 +235,9 @@ spiceweasel --extractyaml
|
|
338
235
|
```
|
339
236
|
When run in your Chef repository generates YAML-formatted output that may be captured and used as your Spiceweasel manifest file.
|
340
237
|
|
341
|
-
Usage
|
342
|
-
|
343
|
-
To parse a
|
238
|
+
# Usage #
|
239
|
+
|
240
|
+
To parse a Spiceweasel manifest, run the following from your Chef repository directory:
|
344
241
|
|
345
242
|
```
|
346
243
|
spiceweasel path/to/infrastructure.json
|
@@ -354,63 +251,66 @@ spiceweasel path/to/infrastructure.yml
|
|
354
251
|
|
355
252
|
This will generate the knife commands to build the described infrastructure. Infrastructure manifest files must end in either `.json` or `.yml`.
|
356
253
|
|
357
|
-
OPTIONS
|
358
|
-
|
254
|
+
# OPTIONS #
|
255
|
+
|
256
|
+
## -c/--knifeconfig ##
|
359
257
|
|
360
|
-
-c/--knifeconfig
|
361
|
-
----------------
|
362
258
|
Specify a knife.rb configuration file to use with the knife commands.
|
363
259
|
|
364
|
-
--
|
365
|
-
|
260
|
+
## --cluster-file ##
|
261
|
+
|
262
|
+
Specify the file to use to override the `nodes` and `clusters` from the primary manifest file. This allows you to switch the target destination of infrastructure by picking different `--cluster-file` endpoints.
|
263
|
+
|
264
|
+
## --debug ##
|
265
|
+
|
366
266
|
This provides verbose debugging messages.
|
367
267
|
|
368
|
-
-d/--delete
|
369
|
-
|
370
|
-
The delete
|
268
|
+
## -d/--delete ##
|
269
|
+
|
270
|
+
The `delete` option will generate the knife commands to delete the infrastructure described in the manifest. This includes each cookbook, environment, role, data bag and node listed. Node deletion will specify individual nodes and their clients, and attempt to pass the list of nodes to the cloud provider for deletion, and finish with `knife node bulk delete`. If you are mixing individual nodes with cloud provider nodes it is possible that nodes may be missed from cloud provider deletion and you should double-check (ie. `knife ec2 server list`).
|
271
|
+
|
272
|
+
## -e/--execute ##
|
273
|
+
|
274
|
+
The `execute` option will directly execute the knife commands, creating (or deleting or rebuilding) the infrastructure described in the manifest.
|
371
275
|
|
372
|
-
--
|
373
|
-
--------
|
374
|
-
This is the default action, printing the knife commands to be run without executing them.
|
276
|
+
## --extractlocal ##
|
375
277
|
|
376
|
-
--extractlocal
|
377
|
-
--------------
|
378
278
|
When run in a chef repository, this will print the knife commands to be run.
|
379
279
|
|
380
|
-
--extractjson
|
381
|
-
--------------
|
382
|
-
When run in a chef repository, this will print a new JSON manifest that may be used as input to Spiceweasel.
|
280
|
+
## --extractjson ##
|
383
281
|
|
384
|
-
|
385
|
-
|
386
|
-
|
282
|
+
When run in a chef repository, this will print a new JSON manifest that may be used as input to spiceweasel.
|
283
|
+
|
284
|
+
## --extractyaml ##
|
285
|
+
|
286
|
+
When run in a chef repository, this will print a new YAML manifest that may be used as input to spiceweasel.
|
287
|
+
|
288
|
+
## -h/--help ##
|
387
289
|
|
388
|
-
-h/--help
|
389
|
-
---------
|
390
290
|
Print the currently-supported usage options for spiceweasel.
|
391
291
|
|
392
|
-
--novalidation
|
393
|
-
|
292
|
+
## --novalidation ##
|
293
|
+
|
394
294
|
Disable validation ensuring existence of the cookbooks, environments, roles, data bags and nodes in infrastructure file.
|
395
295
|
|
396
|
-
--parallel
|
397
|
-
|
296
|
+
## --parallel ##
|
297
|
+
|
398
298
|
Use the GNU 'parallel' command to execute 'knife VENDOR server create' commands that may be run simultaneously.
|
399
299
|
|
400
|
-
-r/--rebuild
|
401
|
-
|
402
|
-
The rebuild
|
300
|
+
## -r/--rebuild ##
|
301
|
+
|
302
|
+
The rebuild option will generate the knife commands to delete and recreate the infrastructure described in the manifest. This includes each cookbook, environment, role, data bag and node listed.
|
303
|
+
|
304
|
+
## --siteinstall ##
|
403
305
|
|
404
|
-
--siteinstall
|
405
|
-
-------------
|
406
306
|
Use the 'install' command with 'knife cookbook site' instead of the default 'download'.
|
407
307
|
|
408
|
-
-v/--version
|
409
|
-
|
308
|
+
## -v/--version ##
|
309
|
+
|
410
310
|
Print the version of spiceweasel currently installed.
|
411
311
|
|
412
|
-
License and Author
|
413
|
-
|
312
|
+
# License and Author #
|
313
|
+
|
414
314
|
Author: Matt Ray <matt@opscode.com>
|
415
315
|
|
416
316
|
Copyright: 2011-2012 Opscode, Inc
|