spiceweasel 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +22 -24
- data/lib/spiceweasel/cli.rb +6 -1
- data/lib/spiceweasel/nodes.rb +23 -9
- data/lib/spiceweasel/version.rb +1 -1
- data/spec/bin/joyent-vsphere_spec.rb +25 -0
- data/spec/bin/spiceweasel_spec.rb +45 -5
- metadata +8 -6
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Spiceweasel is a command-line tool for batch loading Chef infrastructure. It provides a simple syntax in Ruby, 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. The manifest may also be extracted from an existing repository.
|
7
7
|
|
8
|
-
The
|
8
|
+
The https://github.com/mattray/lab-repo provides a working example for bootstrapping a Chef repository with Spiceweasel.
|
9
9
|
|
10
10
|
The [CHANGELOG.md](https://github.com/mattray/spiceweasel/blob/master/CHANGELOG.md) covers current, previous and future development milestones and contains the features backlog.
|
11
11
|
|
@@ -19,26 +19,6 @@ Written and tested with the Chef 11.x series (previous versions of Chef may stil
|
|
19
19
|
|
20
20
|
The syntax for the Spiceweasel file may be Ruby, 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.
|
21
21
|
|
22
|
-
## Manifest syntax changes in Spiceweasel 2.0 ##
|
23
|
-
|
24
|
-
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.
|
25
|
-
|
26
|
-
### New Cookbooks Syntax ###
|
27
|
-
|
28
|
-
The currently supported keys are `version` and `options` and their values are strings.
|
29
|
-
|
30
|
-
### New Data Bags Syntax ###
|
31
|
-
|
32
|
-
The supported keys are `items` (an array of the data bag items) and `secret` for passing a secret key string.
|
33
|
-
|
34
|
-
### New Nodes Syntax ###
|
35
|
-
|
36
|
-
The supported keys are `run_list` and `options` and their values are strings.
|
37
|
-
|
38
|
-
### New Clusters Syntax ###
|
39
|
-
|
40
|
-
Clusters support is completely new, please refer to the Cluster section for documentation.
|
41
|
-
|
42
22
|
## Cookbooks ##
|
43
23
|
|
44
24
|
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
|
@@ -197,6 +177,12 @@ knife bootstrap windows ssh winboxB -x Administrator -P 'super_secret_password'
|
|
197
177
|
knife bootstrap windows ssh winboxC -x Administrator -P 'super_secret_password' -r 'role[base],role[iisserver]'
|
198
178
|
```
|
199
179
|
|
180
|
+
### Providers ###
|
181
|
+
|
182
|
+
The following knife plugins are currently supported as providers: `bluebox, clodo, cs, ec2, gandi, hp, joyent, lxc, openstack, rackspace, slicehost, terremark, vagrant, voxel` and `vsphere`.
|
183
|
+
|
184
|
+
### Bulk node creation ###
|
185
|
+
|
200
186
|
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}}`:
|
201
187
|
|
202
188
|
``` yaml
|
@@ -277,6 +263,10 @@ This will generate the knife commands to build the described infrastructure. Inf
|
|
277
263
|
|
278
264
|
# OPTIONS #
|
279
265
|
|
266
|
+
## --bulkdelete ##
|
267
|
+
|
268
|
+
When using the delete or rebuild commands, whether or not to attempt to delete all nodes managed by a provider. The assumption is that if Spiceweasel manages all the nodes, it is safe to delete them all.
|
269
|
+
|
280
270
|
## -c/--knifeconfig ##
|
281
271
|
|
282
272
|
Specify a knife.rb configuration file to use with the knife commands.
|
@@ -333,11 +323,19 @@ Use the 'install' command with 'knife cookbook site' instead of the default 'dow
|
|
333
323
|
|
334
324
|
Print the version of spiceweasel currently installed.
|
335
325
|
|
336
|
-
#
|
326
|
+
# Testing #
|
327
|
+
|
328
|
+
Spiceweasel uses [RSpec](http://rspec.info/) for testing. You should run the following before commiting.
|
337
329
|
|
338
|
-
|
330
|
+
$ rspec
|
331
|
+
|
332
|
+
# License and Author #
|
339
333
|
|
340
|
-
|
334
|
+
| | |
|
335
|
+
|:---------------------|:---------------------------------------------------|
|
336
|
+
| **Author** | Matt Ray (<matt@opscode.com>) |
|
337
|
+
| | |
|
338
|
+
| **Copyright** | Copyright (c) 2011-2013, Opscode, Inc. |
|
341
339
|
|
342
340
|
Licensed under the Apache License, Version 2.0 (the "License");
|
343
341
|
you may not use this file except in compliance with the License.
|
data/lib/spiceweasel/cli.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Matt Ray (<matt@opscode.com>)
|
3
3
|
#
|
4
|
-
# Copyright:: 2011-
|
4
|
+
# Copyright:: 2011-2013, Opscode, Inc <legal@opscode.com>
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
@@ -48,6 +48,11 @@ module Spiceweasel
|
|
48
48
|
:description => 'Verbose debugging messages',
|
49
49
|
:boolean => true
|
50
50
|
|
51
|
+
option :bulkdelete,
|
52
|
+
:long => '--bulkdelete',
|
53
|
+
:description => 'Delete all nodes for the provider(s) in the infrastructure',
|
54
|
+
:boolean => false
|
55
|
+
|
51
56
|
option :delete,
|
52
57
|
:short => '-d',
|
53
58
|
:long => '--delete',
|
data/lib/spiceweasel/nodes.rb
CHANGED
@@ -21,14 +21,13 @@ module Spiceweasel
|
|
21
21
|
|
22
22
|
include CommandHelper
|
23
23
|
|
24
|
-
PROVIDERS = %w{bluebox clodo cs ec2 gandi hp lxc openstack rackspace slicehost terremark voxel
|
24
|
+
PROVIDERS = %w{bluebox clodo cs ec2 gandi hp joyent lxc openstack rackspace slicehost terremark vagrant voxel vsphere}
|
25
25
|
|
26
26
|
attr_reader :create, :delete
|
27
27
|
|
28
28
|
def initialize(nodes, cookbooks, environments, roles)
|
29
29
|
@create = Array.new
|
30
30
|
@delete = Array.new
|
31
|
-
bulk_delete = false
|
32
31
|
if nodes
|
33
32
|
Spiceweasel::Log.debug("nodes: #{nodes}")
|
34
33
|
nodes.each do |node|
|
@@ -61,24 +60,39 @@ module Spiceweasel
|
|
61
60
|
provided_names = []
|
62
61
|
if Spiceweasel::Config[:parallel]
|
63
62
|
parallel = "seq #{count} | parallel -j 0 -v \""
|
64
|
-
|
63
|
+
if provider[0].eql?('vsphere')
|
64
|
+
parallel += "knife #{provider[0]}#{Spiceweasel::Config[:knife_options]} vm clone #{options}".gsub(/\{\{n\}\}/, '{}')
|
65
|
+
else
|
66
|
+
parallel += "knife #{provider[0]}#{Spiceweasel::Config[:knife_options]} server create #{options}".gsub(/\{\{n\}\}/, '{}')
|
67
|
+
end
|
65
68
|
parallel += " -r '#{run_list}'" unless run_list.empty?
|
66
69
|
parallel += "\""
|
67
70
|
create_command(parallel, create_command_options)
|
68
71
|
else
|
69
72
|
count.to_i.times do |i|
|
70
|
-
|
73
|
+
if provider[0].eql?('vsphere')
|
74
|
+
server = "knife #{provider[0]}#{Spiceweasel::Config[:knife_options]} vm clone #{options}".gsub(/\{\{n\}\}/, (i + 1).to_s)
|
75
|
+
else
|
76
|
+
server = "knife #{provider[0]}#{Spiceweasel::Config[:knife_options]} server create #{options}".gsub(/\{\{n\}\}/, (i + 1).to_s)
|
77
|
+
end
|
71
78
|
server += " -r '#{run_list}'" unless run_list.empty?
|
72
79
|
provided_names << node[name]['name'].gsub('{{n}}', (i + 1).to_s) if node[name]['name']
|
73
80
|
create_command(server, create_command_options)
|
74
81
|
end
|
75
82
|
end
|
76
|
-
if provided_names.empty? && provider[0] != 'windows'
|
77
|
-
|
78
|
-
|
83
|
+
if Spiceweasel::Config[:bulkdelete] && provided_names.empty? && provider[0] != 'windows'
|
84
|
+
if provider[0].eql?('vsphere')
|
85
|
+
delete_command("knife node#{Spiceweasel::Config[:knife_options]} list | xargs knife #{provider[0]} vm delete -y")
|
86
|
+
else
|
87
|
+
delete_command("knife node#{Spiceweasel::Config[:knife_options]} list | xargs knife #{provider[0]} server delete -y")
|
88
|
+
end
|
79
89
|
else
|
80
90
|
provided_names.each do |p_name|
|
81
|
-
|
91
|
+
if provider[0].eql?('vsphere')
|
92
|
+
delete_command("knife #{provider[0]} vm delete -y #{p_name}")
|
93
|
+
else
|
94
|
+
delete_command("knife #{provider[0]} server delete -y #{p_name}")
|
95
|
+
end
|
82
96
|
delete_command("knife node#{Spiceweasel::Config[:knife_options]} delete #{p_name} -y")
|
83
97
|
delete_command("knife client#{Spiceweasel::Config[:knife_options]} delete #{p_name} -y")
|
84
98
|
end
|
@@ -109,7 +123,7 @@ module Spiceweasel
|
|
109
123
|
end
|
110
124
|
end
|
111
125
|
end
|
112
|
-
if
|
126
|
+
if Spiceweasel::Config[:bulkdelete]
|
113
127
|
delete_command("knife node#{Spiceweasel::Config[:knife_options]} bulk delete .* -y")
|
114
128
|
end
|
115
129
|
end
|
data/lib/spiceweasel/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Test new 2.3 functionality
|
2
|
+
describe 'The Spiceweasel binary' do
|
3
|
+
before(:each) do
|
4
|
+
@expected_output = <<-OUTPUT
|
5
|
+
knife cookbook delete apache2 -a -y
|
6
|
+
knife environment delete qa -y
|
7
|
+
knife role delete base -y
|
8
|
+
knife node list | xargs knife joyent server delete -y
|
9
|
+
knife node list | xargs knife vsphere vm delete -y
|
10
|
+
knife node bulk delete .* -y
|
11
|
+
knife cookbook upload apache2
|
12
|
+
knife environment from file qa.rb
|
13
|
+
knife role from file base.rb
|
14
|
+
seq 2 | parallel -j 0 -v "knife joyent server create -i ~/.ssh/joyent.pem -E qa -r 'role[base]'"
|
15
|
+
seq 2 | parallel -j 0 -v "knife vsphere vm clone -P secret_password -x Administrator --template some_template -r 'role[base]'"
|
16
|
+
OUTPUT
|
17
|
+
|
18
|
+
@spiceweasel_binary = File.join(File.dirname(__FILE__), *%w[.. .. bin spiceweasel])
|
19
|
+
end
|
20
|
+
|
21
|
+
it "test joyent, vsphere and --bulkdelete functionality from 2.3" do
|
22
|
+
`#{@spiceweasel_binary} --parallel --bulkdelete -r --novalidation examples/joyent-vsphere-example.yml`.should == @expected_output
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -22,17 +22,12 @@ knife node delete serverB -y
|
|
22
22
|
knife client delete serverB -y
|
23
23
|
knife node delete serverC -y
|
24
24
|
knife client delete serverC -y
|
25
|
-
knife node list | xargs knife rackspace server delete -y
|
26
25
|
knife node delete winboxA -y
|
27
26
|
knife client delete winboxA -y
|
28
27
|
knife node delete winboxB -y
|
29
28
|
knife client delete winboxB -y
|
30
29
|
knife node delete winboxC -y
|
31
30
|
knife client delete winboxC -y
|
32
|
-
knife node bulk delete .* -y
|
33
|
-
knife node list | xargs knife ec2 server delete -y
|
34
|
-
knife node list | xargs knife ec2 server delete -y
|
35
|
-
knife node bulk delete .* -y
|
36
31
|
knife cookbook upload apache2
|
37
32
|
knife cookbook upload apt --freeze
|
38
33
|
knife cookbook upload mysql ntp
|
@@ -73,3 +68,48 @@ knife ec2 server create -S mray -i ~/.ssh/mray.pem -x ubuntu -G default -I ami-7
|
|
73
68
|
`#{@spiceweasel_binary} -r --novalidation examples/example.rb`.should == @expected_output
|
74
69
|
end
|
75
70
|
end
|
71
|
+
|
72
|
+
describe 'The Spiceweasel binary' do
|
73
|
+
before(:each) do
|
74
|
+
@expected_output = <<-OUTPUT
|
75
|
+
knife cookbook delete apache2 -a -y
|
76
|
+
knife cookbook delete apt 1.2.0 -a -y
|
77
|
+
knife cookbook delete mysql -a -y
|
78
|
+
knife cookbook delete ntp -a -y
|
79
|
+
knife environment delete development -y
|
80
|
+
knife environment delete qa -y
|
81
|
+
knife environment delete production -y
|
82
|
+
knife role delete base -y
|
83
|
+
knife role delete iisserver -y
|
84
|
+
knife role delete monitoring -y
|
85
|
+
knife role delete webserver -y
|
86
|
+
knife data bag delete users -y
|
87
|
+
knife data bag delete data -y
|
88
|
+
knife data bag delete passwords -y
|
89
|
+
knife node delete serverA -y
|
90
|
+
knife client delete serverA -y
|
91
|
+
knife node delete serverB -y
|
92
|
+
knife client delete serverB -y
|
93
|
+
knife node delete serverC -y
|
94
|
+
knife client delete serverC -y
|
95
|
+
knife node list | xargs knife rackspace server delete -y
|
96
|
+
knife node delete winboxA -y
|
97
|
+
knife client delete winboxA -y
|
98
|
+
knife node delete winboxB -y
|
99
|
+
knife client delete winboxB -y
|
100
|
+
knife node delete winboxC -y
|
101
|
+
knife client delete winboxC -y
|
102
|
+
knife node bulk delete .* -y
|
103
|
+
knife node list | xargs knife ec2 server delete -y
|
104
|
+
knife node list | xargs knife ec2 server delete -y
|
105
|
+
knife node bulk delete .* -y
|
106
|
+
OUTPUT
|
107
|
+
|
108
|
+
@spiceweasel_binary = File.join(File.dirname(__FILE__), *%w[.. .. bin spiceweasel])
|
109
|
+
end
|
110
|
+
|
111
|
+
it "maintains consistent output deleting from the example config with yml using --bulkdelete" do
|
112
|
+
`#{@spiceweasel_binary} --bulkdelete -d --novalidation examples/example.yml`.should == @expected_output
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spiceweasel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
requirements:
|
99
99
|
- - ! '>='
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
101
|
+
version: '0.10'
|
102
102
|
type: :runtime
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -106,7 +106,7 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
109
|
+
version: '0.10'
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
111
|
name: berkshelf
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -183,6 +183,7 @@ files:
|
|
183
183
|
- lib/spiceweasel/roles.rb
|
184
184
|
- lib/spiceweasel/version.rb
|
185
185
|
- lib/spiceweasel.rb
|
186
|
+
- spec/bin/joyent-vsphere_spec.rb
|
186
187
|
- spec/bin/spiceweasel_spec.rb
|
187
188
|
homepage: https://github.com/mattray/spiceweasel
|
188
189
|
licenses:
|
@@ -196,7 +197,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
196
197
|
requirements:
|
197
198
|
- - ! '>='
|
198
199
|
- !ruby/object:Gem::Version
|
199
|
-
version: '
|
200
|
+
version: '1.9'
|
200
201
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
202
|
none: false
|
202
203
|
requirements:
|
@@ -205,9 +206,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
205
206
|
version: '0'
|
206
207
|
requirements: []
|
207
208
|
rubyforge_project:
|
208
|
-
rubygems_version: 1.8.
|
209
|
+
rubygems_version: 1.8.25
|
209
210
|
signing_key:
|
210
211
|
specification_version: 3
|
211
212
|
summary: CLI for generating Chef knife commands from a simple JSON or YAML file.
|
212
213
|
test_files:
|
214
|
+
- spec/bin/joyent-vsphere_spec.rb
|
213
215
|
- spec/bin/spiceweasel_spec.rb
|