spiceweasel 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/MILESTONES.md +51 -0
- data/README.md +149 -0
- data/Rakefile +2 -0
- data/bin/spiceweasel +84 -0
- data/example.yml +27 -0
- data/lib/spiceweasel/version.rb +3 -0
- data/lib/spiceweasel.rb +3 -0
- data/spiceweasel.gemspec +21 -0
- metadata +74 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/MILESTONES.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
This is the current, previous and future development milestones and contains the features backlog.
|
2
|
+
|
3
|
+
0.1
|
4
|
+
===
|
5
|
+
* initial README.md describing goals
|
6
|
+
* command-line tool
|
7
|
+
* basic options all supported
|
8
|
+
* create repo on GitHub
|
9
|
+
* publish as a gem on RubyGems
|
10
|
+
|
11
|
+
0.2
|
12
|
+
===
|
13
|
+
* new CLI args
|
14
|
+
* --chef-client The option `--chef-client` will make a `knife ssh` call to each box and run `chef-client` on each.
|
15
|
+
* --delete The option `--delete` will delete each cookbook, role, data bag, environment and node described in the yml file. All nodes from the system are deleted with `knife node bulk_delete`. Since knife does not currently manage deletion of the instances from cloud providers, that is still a required step.
|
16
|
+
* --rebuild The option `--rebuild` will remove all currently managed infrastructure for this chef repository and rebuild it from scratch.
|
17
|
+
|
18
|
+
0.3
|
19
|
+
===
|
20
|
+
* --chef-client validation
|
21
|
+
|
22
|
+
BACKLOG
|
23
|
+
=======
|
24
|
+
Cookbooks
|
25
|
+
---------
|
26
|
+
* site vendor?
|
27
|
+
* JSON?
|
28
|
+
|
29
|
+
Roles
|
30
|
+
-----
|
31
|
+
* JSON?
|
32
|
+
* validate recipes and roles have been uploaded
|
33
|
+
|
34
|
+
Data Bags
|
35
|
+
---------
|
36
|
+
|
37
|
+
Environments
|
38
|
+
------------
|
39
|
+
|
40
|
+
Nodes
|
41
|
+
-----
|
42
|
+
* Provider
|
43
|
+
* on delete... what to do?
|
44
|
+
* knife windows bootstrap FQDN [RUN LIST...] (options)
|
45
|
+
|
46
|
+
Wishlist
|
47
|
+
--------
|
48
|
+
* use GNU parallel
|
49
|
+
* make the JSON calls directly (and possibly parallelize)
|
50
|
+
* --dryrun The option `--dryrun` will print the commands to run, but not actually execute them.
|
51
|
+
|
data/README.md
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
Description
|
2
|
+
===========
|
3
|
+
Spiceweasel is a command-line tool for batch loading Chef infrastructure. It provides a simple syntax for describing and deploying infrastructure with the Chef command-line tool `knife`.
|
4
|
+
|
5
|
+
MILESTONES.md covers current, previous and future development milestones and contains the features backlog.
|
6
|
+
|
7
|
+
Requirements
|
8
|
+
============
|
9
|
+
Spiceweasel currently depends on `knife` to run commands for it.
|
10
|
+
|
11
|
+
Written with Chef 0.9.12 and supports cookbooks, recipes, roles, data bags and nodes. Support for environments will be added with the Chef 0.10 release.
|
12
|
+
|
13
|
+
Testing
|
14
|
+
-------
|
15
|
+
Tested with Ubuntu 10.04 and 10.10 and Chef 0.9.12.
|
16
|
+
|
17
|
+
File Syntax
|
18
|
+
===========
|
19
|
+
The syntax for the spiceweasel file is a simple YAML format of Chef primitives describing what is to be instantiated.
|
20
|
+
|
21
|
+
cookbooks:
|
22
|
+
- apache2
|
23
|
+
- apt
|
24
|
+
- mysql
|
25
|
+
|
26
|
+
roles:
|
27
|
+
- base
|
28
|
+
- monitoring
|
29
|
+
- webserver
|
30
|
+
|
31
|
+
data bags:
|
32
|
+
users:
|
33
|
+
- alice
|
34
|
+
- bob
|
35
|
+
- chuck
|
36
|
+
data:
|
37
|
+
|
38
|
+
nodes:
|
39
|
+
serverA:
|
40
|
+
- role[loadbalancer]
|
41
|
+
- -i ~/.ssh/mray.pem -x user --sudo -d ubuntu10.04-gems
|
42
|
+
ec2 5:
|
43
|
+
- role[webserver]
|
44
|
+
- -S mray -I ~/.ssh/mray.pem -x ubuntu -G default -i ami-a403f7cd -f m1.small
|
45
|
+
rackspace 3:
|
46
|
+
- recipe[mysql] role[clustered_mysql]
|
47
|
+
- --image 49 --flavor 2
|
48
|
+
|
49
|
+
Cookbooks
|
50
|
+
---------
|
51
|
+
The `cookbooks` section of the YAML file currently supports `knife cookbook upload FOO` where `FOO` is the name of the cookbook in the `cookbooks` directory. The YAML snippet
|
52
|
+
|
53
|
+
cookbooks:
|
54
|
+
- apache2
|
55
|
+
- apt
|
56
|
+
- mysql
|
57
|
+
|
58
|
+
produces the knife commands
|
59
|
+
|
60
|
+
knife cookbook upload apache2
|
61
|
+
knife cookbook upload apt
|
62
|
+
knife cookbook upload mysql
|
63
|
+
|
64
|
+
Roles
|
65
|
+
-----
|
66
|
+
The `roles` section of the YAML file currently supports `knife role from file FOO` where `FOO` is the name of the role file ending in `.rb` in the `roles` directory. The YAML snippet
|
67
|
+
|
68
|
+
roles:
|
69
|
+
- base
|
70
|
+
- monitoring
|
71
|
+
- webserver
|
72
|
+
|
73
|
+
produces the knife commands
|
74
|
+
|
75
|
+
knife role from file base.rb
|
76
|
+
knife role from file monitoring.rb
|
77
|
+
knife role from file webserver.rb
|
78
|
+
|
79
|
+
Data Bags
|
80
|
+
---------
|
81
|
+
The `data bags` section of the YAML file 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 YAML sequence, the assumption is made that they `.json` files and in the `data_bags` directory. The YAML snippet
|
82
|
+
|
83
|
+
data bags:
|
84
|
+
users:
|
85
|
+
- alice
|
86
|
+
- bob
|
87
|
+
- chuck
|
88
|
+
data:
|
89
|
+
|
90
|
+
produces the knife commands
|
91
|
+
|
92
|
+
knife data bag create data
|
93
|
+
knife data bag create users
|
94
|
+
knife data bag from file users data_bags/alice.json
|
95
|
+
knife data bag from file users data_bags/bob.json
|
96
|
+
knife data bag from file users data_bags/chuck.json
|
97
|
+
|
98
|
+
Nodes
|
99
|
+
-----
|
100
|
+
The `nodes` section of the YAML file bootstraps a node for each entry where the entry is a hostname or provider and count. Each node requires 2 items after it in a YAML sequence. The first item is the run_list and the second the CLI options used. 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. The YAML snippet
|
101
|
+
|
102
|
+
nodes:
|
103
|
+
serverA:
|
104
|
+
- role[loadbalancer]
|
105
|
+
- -i ~/.ssh/mray.pem -x user --sudo -d ubuntu10.04-gems
|
106
|
+
ec2 5:
|
107
|
+
- role[webserver]
|
108
|
+
- -S mray -I ~/.ssh/mray.pem -x ubuntu -G default -i ami-a403f7cd -f m1.small
|
109
|
+
rackspace 3:
|
110
|
+
- recipe[mysql] role[clustered_mysql]
|
111
|
+
- --image 49 --flavor 2
|
112
|
+
|
113
|
+
produces the knife commands
|
114
|
+
|
115
|
+
knife bootstrap serverA 'role[loadbalancer]' -i ~/.ssh/mray.pem -x user --sudo -d ubuntu10.04-gems
|
116
|
+
knife ec2 server create 'role[webserver]' -S mray -I ~/.ssh/mray.pem -x ubuntu -G default -i ami-a403f7cd -f m1.small
|
117
|
+
knife ec2 server create 'role[webserver]' -S mray -I ~/.ssh/mray.pem -x ubuntu -G default -i ami-a403f7cd -f m1.small
|
118
|
+
knife ec2 server create 'role[webserver]' -S mray -I ~/.ssh/mray.pem -x ubuntu -G default -i ami-a403f7cd -f m1.small
|
119
|
+
knife ec2 server create 'role[webserver]' -S mray -I ~/.ssh/mray.pem -x ubuntu -G default -i ami-a403f7cd -f m1.small
|
120
|
+
knife ec2 server create 'role[webserver]' -S mray -I ~/.ssh/mray.pem -x ubuntu -G default -i ami-a403f7cd -f m1.small
|
121
|
+
knife rackspace server create 'recipe[mysql]' 'role[clustered_mysql]' --image 49 --flavor 2
|
122
|
+
knife rackspace server create 'recipe[mysql]' 'role[clustered_mysql]' --image 49 --flavor 2
|
123
|
+
knife rackspace server create 'recipe[mysql]' 'role[clustered_mysql]' --image 49 --flavor 2
|
124
|
+
|
125
|
+
Usage
|
126
|
+
=====
|
127
|
+
To run a spiceweasel file, run the following from you Chef repository directory:
|
128
|
+
|
129
|
+
spiceweasel path/to/infrastructure.yml
|
130
|
+
|
131
|
+
This will generate the knife commands to build the described infrastructure.
|
132
|
+
|
133
|
+
License and Author
|
134
|
+
==================
|
135
|
+
Author: Matt Ray <matt@opscode.com>
|
136
|
+
|
137
|
+
Copyright: 2011 Opscode, Inc
|
138
|
+
|
139
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
140
|
+
you may not use this file except in compliance with the License.
|
141
|
+
You may obtain a copy of the License at
|
142
|
+
|
143
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
144
|
+
|
145
|
+
Unless required by applicable law or agreed to in writing, software
|
146
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
148
|
+
See the License for the specific language governing permissions and
|
149
|
+
limitations under the License.
|
data/Rakefile
ADDED
data/bin/spiceweasel
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
options = {}
|
7
|
+
optparse = OptionParser.new do |opts|
|
8
|
+
opts.banner = "Usage: spiceweasel [options] file"
|
9
|
+
opts.on('-h', '--help', 'Show this message') do
|
10
|
+
puts opts
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
opts.on('-v', '--version', 'Version') do
|
14
|
+
puts "spiceweasel 0.1"
|
15
|
+
exit
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
begin
|
20
|
+
ARGV << "-h" if ARGV.empty?
|
21
|
+
optparse.parse!(ARGV)
|
22
|
+
rescue OptionParser::ParseError => e
|
23
|
+
STDERR.puts e.message, "\n", optparse
|
24
|
+
exit(-1)
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
yml = YAML.load_file ARGV[0]
|
29
|
+
knife = ""
|
30
|
+
|
31
|
+
#cookbooks
|
32
|
+
cookbooks = yml['cookbooks'] || []
|
33
|
+
cookbooks.each do |cookbook|
|
34
|
+
knife += "knife cookbook upload #{cookbook}\n"
|
35
|
+
end
|
36
|
+
|
37
|
+
#roles
|
38
|
+
roles = yml['roles'] || []
|
39
|
+
roles.each do |role|
|
40
|
+
knife += "knife role from file #{role}.rb\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
#data bags
|
44
|
+
bags = yml['data bags'] || []
|
45
|
+
bags.keys.each do |bag|
|
46
|
+
knife += "knife data bag create #{bag}\n"
|
47
|
+
items = bags[bag] || []
|
48
|
+
items.each do |item|
|
49
|
+
knife += "knife data bag from file #{bag} data_bags/#{item}.json\n"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
nodes = yml['nodes'] || []
|
54
|
+
nodes.keys.each do |node|
|
55
|
+
run_list = nodes[node][0].split()
|
56
|
+
#TODO verify the run_list against the nodes and recipes
|
57
|
+
if node.start_with?("bluebox","ec2","rackspace","slicehost","terremark")
|
58
|
+
provider = node.split()
|
59
|
+
count = 1
|
60
|
+
if (provider.length == 2)
|
61
|
+
count = provider[1]
|
62
|
+
end
|
63
|
+
count.to_i.times do
|
64
|
+
knife += "knife #{provider[0]} server create "
|
65
|
+
run_list.each do |x|
|
66
|
+
knife += "\'#{x}\' "
|
67
|
+
end
|
68
|
+
knife +="#{nodes[node][1]}\n"
|
69
|
+
end
|
70
|
+
else
|
71
|
+
knife += "knife bootstrap #{node} "
|
72
|
+
run_list.each do |x|
|
73
|
+
knife += "\'#{x}\' "
|
74
|
+
end
|
75
|
+
knife +="#{nodes[node][1]}\n"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
puts knife
|
80
|
+
#--clientsync
|
81
|
+
#--delete
|
82
|
+
#--dryrun
|
83
|
+
#--rebuild
|
84
|
+
#remember to -y
|
data/example.yml
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
cookbooks:
|
2
|
+
- apache2
|
3
|
+
- apt
|
4
|
+
- mysql
|
5
|
+
|
6
|
+
roles:
|
7
|
+
- base
|
8
|
+
- monitoring
|
9
|
+
- webserver
|
10
|
+
|
11
|
+
data bags:
|
12
|
+
users:
|
13
|
+
- alice
|
14
|
+
- bob
|
15
|
+
- chuck
|
16
|
+
data:
|
17
|
+
|
18
|
+
nodes:
|
19
|
+
serverA:
|
20
|
+
- role[loadbalancer]
|
21
|
+
- -i ~/.ssh/mray.pem -x user --sudo -d ubuntu10.04-gems
|
22
|
+
ec2 5:
|
23
|
+
- role[webserver]
|
24
|
+
- -S mray -I ~/.ssh/mray.pem -x ubuntu -G default -i ami-a403f7cd -f m1.small
|
25
|
+
rackspace 3:
|
26
|
+
- recipe[mysql] role[clustered_mysql]
|
27
|
+
- --image 49 --flavor 2
|
data/lib/spiceweasel.rb
ADDED
data/spiceweasel.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "spiceweasel/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "spiceweasel"
|
7
|
+
s.version = Spiceweasel::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Matt Ray"]
|
10
|
+
s.email = ["matt@opscode.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{CLI for generating Chef knife commands from a simple YAML file.}
|
13
|
+
s.description = %q{This provides a CLI for generating knife commands to build Chef-managed infrastructure from a simple YAML file.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "spiceweasel"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spiceweasel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Matt Ray
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-03-04 00:00:00 -06:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: This provides a CLI for generating knife commands to build Chef-managed infrastructure from a simple YAML file.
|
22
|
+
email:
|
23
|
+
- matt@opscode.com
|
24
|
+
executables:
|
25
|
+
- spiceweasel
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- Gemfile
|
33
|
+
- MILESTONES.md
|
34
|
+
- README.md
|
35
|
+
- Rakefile
|
36
|
+
- bin/spiceweasel
|
37
|
+
- example.yml
|
38
|
+
- lib/spiceweasel.rb
|
39
|
+
- lib/spiceweasel/version.rb
|
40
|
+
- spiceweasel.gemspec
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: ""
|
43
|
+
licenses: []
|
44
|
+
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
version: "0"
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
version: "0"
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project: spiceweasel
|
69
|
+
rubygems_version: 1.3.7
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: CLI for generating Chef knife commands from a simple YAML file.
|
73
|
+
test_files: []
|
74
|
+
|