crafterm-sprinkle 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. data/CREDITS +11 -0
  2. data/History.txt +4 -0
  3. data/MIT-LICENSE +20 -0
  4. data/Manifest.txt +55 -0
  5. data/README.txt +218 -0
  6. data/Rakefile +4 -0
  7. data/bin/sprinkle +79 -0
  8. data/config/hoe.rb +70 -0
  9. data/config/requirements.rb +17 -0
  10. data/examples/merb/deploy.rb +5 -0
  11. data/examples/rails/README +15 -0
  12. data/examples/rails/deploy.rb +2 -0
  13. data/examples/rails/packages/database.rb +9 -0
  14. data/examples/rails/packages/essential.rb +6 -0
  15. data/examples/rails/packages/rails.rb +28 -0
  16. data/examples/rails/packages/search.rb +11 -0
  17. data/examples/rails/packages/server.rb +28 -0
  18. data/examples/rails/rails.rb +71 -0
  19. data/lib/sprinkle/actors/capistrano.rb +80 -0
  20. data/lib/sprinkle/deployment.rb +33 -0
  21. data/lib/sprinkle/extensions/arbitrary_options.rb +10 -0
  22. data/lib/sprinkle/extensions/array.rb +7 -0
  23. data/lib/sprinkle/extensions/blank_slate.rb +5 -0
  24. data/lib/sprinkle/extensions/dsl_accessor.rb +15 -0
  25. data/lib/sprinkle/extensions/string.rb +10 -0
  26. data/lib/sprinkle/extensions/symbol.rb +7 -0
  27. data/lib/sprinkle/installers/apt.rb +20 -0
  28. data/lib/sprinkle/installers/gem.rb +31 -0
  29. data/lib/sprinkle/installers/installer.rb +47 -0
  30. data/lib/sprinkle/installers/rake.rb +16 -0
  31. data/lib/sprinkle/installers/source.rb +137 -0
  32. data/lib/sprinkle/package.rb +76 -0
  33. data/lib/sprinkle/policy.rb +84 -0
  34. data/lib/sprinkle/script.rb +13 -0
  35. data/lib/sprinkle/version.rb +9 -0
  36. data/lib/sprinkle.rb +29 -0
  37. data/script/destroy +14 -0
  38. data/script/generate +14 -0
  39. data/spec/spec.opts +1 -0
  40. data/spec/spec_helper.rb +17 -0
  41. data/spec/sprinkle/actors/capistrano_spec.rb +150 -0
  42. data/spec/sprinkle/deployment_spec.rb +80 -0
  43. data/spec/sprinkle/extensions/array_spec.rb +19 -0
  44. data/spec/sprinkle/extensions/string_spec.rb +21 -0
  45. data/spec/sprinkle/installers/apt_spec.rb +46 -0
  46. data/spec/sprinkle/installers/gem_spec.rb +64 -0
  47. data/spec/sprinkle/installers/installer_spec.rb +125 -0
  48. data/spec/sprinkle/installers/source_spec.rb +315 -0
  49. data/spec/sprinkle/package_spec.rb +203 -0
  50. data/spec/sprinkle/policy_spec.rb +110 -0
  51. data/spec/sprinkle/script_spec.rb +51 -0
  52. data/spec/sprinkle/sprinkle_spec.rb +25 -0
  53. data/tasks/deployment.rake +34 -0
  54. data/tasks/environment.rake +7 -0
  55. data/tasks/rspec.rake +21 -0
  56. metadata +137 -0
data/CREDITS ADDED
@@ -0,0 +1,11 @@
1
+ = CREDITS
2
+
3
+ Many thanks to the following people who have submitted ideas, patches, helped with testing
4
+ and/or generally provided support to Sprinke, I really appreciate your help:
5
+
6
+ Kristin Baumann (http://crafterm.net/kristin/blog/)
7
+ Ben Schwarz (http://germanforblack.com/)
8
+ Jim Freeze (http://www.artima.com/rubycs/articles/ruby_as_dslP.html)
9
+ Matthew Tanase (http://www.slicehost.com)
10
+ Jared Kuolt (http://www.slicehost.com)
11
+ Jamis Buck (http://www.capify.org)
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2008-03-11
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Marcus Crafter
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,55 @@
1
+ CREDITS
2
+ History.txt
3
+ MIT-LICENSE
4
+ Manifest.txt
5
+ README.txt
6
+ Rakefile
7
+ bin/sprinkle
8
+ config/hoe.rb
9
+ config/requirements.rb
10
+ examples/merb/deploy.rb
11
+ examples/rails/README
12
+ examples/rails/deploy.rb
13
+ examples/rails/packages/database.rb
14
+ examples/rails/packages/essential.rb
15
+ examples/rails/packages/rails.rb
16
+ examples/rails/packages/search.rb
17
+ examples/rails/packages/server.rb
18
+ examples/rails/rails.rb
19
+ lib/sprinkle.rb
20
+ lib/sprinkle/actors/capistrano.rb
21
+ lib/sprinkle/deployment.rb
22
+ lib/sprinkle/extensions/arbitrary_options.rb
23
+ lib/sprinkle/extensions/array.rb
24
+ lib/sprinkle/extensions/blank_slate.rb
25
+ lib/sprinkle/extensions/dsl_accessor.rb
26
+ lib/sprinkle/extensions/string.rb
27
+ lib/sprinkle/extensions/symbol.rb
28
+ lib/sprinkle/installers/apt.rb
29
+ lib/sprinkle/installers/gem.rb
30
+ lib/sprinkle/installers/installer.rb
31
+ lib/sprinkle/installers/rake.rb
32
+ lib/sprinkle/installers/source.rb
33
+ lib/sprinkle/package.rb
34
+ lib/sprinkle/policy.rb
35
+ lib/sprinkle/script.rb
36
+ lib/sprinkle/version.rb
37
+ script/destroy
38
+ script/generate
39
+ spec/spec.opts
40
+ spec/spec_helper.rb
41
+ spec/sprinkle/actors/capistrano_spec.rb
42
+ spec/sprinkle/deployment_spec.rb
43
+ spec/sprinkle/extensions/array_spec.rb
44
+ spec/sprinkle/extensions/string_spec.rb
45
+ spec/sprinkle/installers/apt_spec.rb
46
+ spec/sprinkle/installers/gem_spec.rb
47
+ spec/sprinkle/installers/installer_spec.rb
48
+ spec/sprinkle/installers/source_spec.rb
49
+ spec/sprinkle/package_spec.rb
50
+ spec/sprinkle/policy_spec.rb
51
+ spec/sprinkle/script_spec.rb
52
+ spec/sprinkle/sprinkle_spec.rb
53
+ tasks/deployment.rake
54
+ tasks/environment.rake
55
+ tasks/rspec.rake
data/README.txt ADDED
@@ -0,0 +1,218 @@
1
+ = SPRINKLE
2
+
3
+ http://github.com/crafterm/sprinkle
4
+
5
+ == DESCRIPTION:
6
+
7
+ Sprinkle is a software provisioning tool you can use to build remote servers with, after the base operating
8
+ system has been installed. For example, to install a Rails or Merb stack on a brand new slice directly after
9
+ its been created.
10
+
11
+ Properties of packages such as their name, type, dependencies, etc, and what packages apply to what machines
12
+ is described via a domain specific language that Sprinkle executes (in fact one of the aims of Sprinkle is to
13
+ define as concisely as possible a language for installing software).
14
+
15
+ An example package description follows:
16
+
17
+ package :ruby do
18
+ description 'Ruby Virtual Machine'
19
+ version '1.8.6'
20
+ source "ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-#{version}-p111.tar.gz" # implicit :style => :gnu
21
+ requires :ruby_dependencies
22
+ end
23
+
24
+ This defines a package called 'ruby', that uses the source based installer to build Ruby 1.8.6 from source,
25
+ installing the package 'ruby_dependencies' beforehand.
26
+
27
+ Reasonable defaults are set by sprinkle, such as the install prefix, download area, etc, but can be customized
28
+ globally or per package (see below for an example).
29
+
30
+ Since packages come in many forms (eg. gems, pre-compiled debs, compressed source tar.gz, etc), Sprinkle supports
31
+ many different installer types, giving you the most amount of flexibility of how you'd like software installed.
32
+ New installer types can be added into the system easily.
33
+
34
+ For example, you could install Rails via gems, nginx via source, and mysql via APT.
35
+
36
+ Sprinkle also supports dependencies between packages, allowing you specify pre-requisites that need to be
37
+ installed in order.
38
+
39
+ Packages can be grouped into polices to define several packages that should be installed together.
40
+
41
+ An example policy:
42
+
43
+ policy :rails, :roles => :app do
44
+ requires :rails, :version => '2.0.2'
45
+ requires :appserver
46
+ requires :database
47
+ requires :webserver
48
+ end
49
+
50
+ This defines a policy called Rails, that applies to machines of role :app. The policy includes the packages
51
+ rails (version 2.0.2), appserver, database and webserver.
52
+
53
+ appserver, database and webserver can be virtual packages, where the user will be prompted for selection if
54
+ multiple choices for the virtual package exist.
55
+
56
+ Sprinkle is architected to be extendable in many ways, one of those areas is in its deployment of commands to
57
+ remote hosts. Currently Sprinkle uses Capistrano to issue commands on remote hosts via ssh, but it could also
58
+ conceivably use vlad, etc, or be used to simply issue installation commands on the local system.
59
+
60
+ An full example Sprinkle deployment script for deploying Rails (via gems), MySQL (via APT), and Apache (via source):
61
+
62
+ # Sprinkle Rails deployment script
63
+ #
64
+ # This is an example Sprinkle script, configured to install Rails from gems, Apache and Ruby from source,
65
+ # and mysql from apt on an Ubuntu system. Installation is configured to run via capistrano (and
66
+ # an accompanying deploy.rb recipe script). Source based packages are downloaded and built into
67
+ # /usr/local on the remote system.
68
+ #
69
+ # A sprinkle script is separated into 3 different sections. Packages, policies and deployment.
70
+ #
71
+ # Packages
72
+ #
73
+ # Defines the world of packages as we know it. Each package has a name and
74
+ # set of metadata including its installer type (eg. apt, source, gem, etc). Packages can have
75
+ # relationships to each other via dependencies
76
+ #
77
+ # Policies
78
+ #
79
+ # Names a group of packages (optionally with versions) that apply to a particular set of roles.
80
+ #
81
+ # Deployment
82
+ #
83
+ # Defines script wide settings such as a delivery mechanism for executing commands on the target
84
+ # system (eg. capistrano), and installer defaults (eg. build locations, etc).
85
+
86
+ # Packages
87
+
88
+ package :build_essential do # special package, anything that uses a 'source' installer will have build-essential installed for Ubuntu
89
+ description 'Build tools'
90
+ apt 'build-essential'
91
+ end
92
+
93
+ package :ruby do
94
+ description 'Ruby Virtual Machine'
95
+ version '1.8.6'
96
+ source "ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-#{version}-p111.tar.gz" # implicit :style => :gnu
97
+ requires :ruby_dependencies
98
+ end
99
+
100
+ package :ruby_dependencies do
101
+ description 'Ruby Virtual Machine Build Dependencies'
102
+ apt %w( bison zlib1g-dev libssl-dev libreadline5-dev libncurses5-dev file )
103
+ end
104
+
105
+ package :mysql, :provides => :database do
106
+ description 'MySQL Database'
107
+ apt %w( mysql-server mysql-client )
108
+ end
109
+
110
+ package :apache, :provides => :webserver do
111
+ description 'Apache 2 HTTP Server'
112
+ version '2.2.6'
113
+ source "http://apache.wildit.net.au/httpd/httpd-#{version}.tar.bz2" do
114
+ enable %w( mods-shared=all proxy proxy-balancer proxy-http rewrite cache headers ssl deflate so )
115
+ prefix "/opt/local/apache2-#{version}"
116
+ post :install, 'install -m 755 support/apachectl /etc/init.d/apache2', 'update-rc.d -f apache2 defaults'
117
+ end
118
+ requires :apache_dependencies
119
+ end
120
+
121
+ package :apache_dependencies do
122
+ description 'Apache 2 HTTP Server Build Dependencies'
123
+ apt %w( openssl libtool mawk zlib1g-dev libssl-dev )
124
+ end
125
+
126
+ package :rubygems do
127
+ description 'Ruby Gems Package Management System'
128
+ version '1.0.1'
129
+ source "http://rubyforge.org/frs/download.php/29548/rubygems-#{version}.tgz" do
130
+ custom_install 'ruby setup.rb'
131
+ end
132
+ requires :ruby
133
+ end
134
+
135
+ package :rails do
136
+ description 'Ruby on Rails'
137
+ gem 'rails'
138
+ version '2.0.2'
139
+ end
140
+
141
+ package :mongrel do
142
+ description 'Mongrel Application Server'
143
+ gem 'mongrel'
144
+ version '1.1.4'
145
+ end
146
+
147
+ package :mongrel_cluster, :provides => :appserver do
148
+ description 'Cluster Management for Mongrel'
149
+ gem 'mongrel_cluster' # :source => 'http://gems.github.com/' for alternate gem server
150
+ version '1.0.5'
151
+ requires :mongrel
152
+ end
153
+
154
+ # Policies
155
+
156
+ # Associates the rails policy to the application servers. Contains rails, and surrounding
157
+ # packages. Note, appserver, database and webserver are all virtual packages defined above. If
158
+ # there's only one implementation of a virtual package, it's selected automatically, otherwise
159
+ # the user is requested to select which one to use.
160
+
161
+ policy :rails, :roles => :app do
162
+ requires :rails, :version => '2.0.2'
163
+ requires :appserver
164
+ requires :database
165
+ requires :webserver
166
+ end
167
+
168
+ # Deployment
169
+
170
+ # Configures spinkle to use capistrano for delivery of commands to the remote machines (via
171
+ # the named 'deploy' recipe). Also configures 'source' installer defaults to put package gear
172
+ # in /usr/local
173
+
174
+ deployment do
175
+
176
+ # mechanism for deployment
177
+ delivery :capistrano do
178
+ recipes 'deploy'
179
+ end
180
+
181
+ # source based package installer defaults
182
+ source do
183
+ prefix '/usr/local' # where all source packages will be configured to install
184
+ archives '/usr/local/sources' # where all source packages will be downloaded to
185
+ builds '/usr/local/build' # where all source packages will be built
186
+ end
187
+
188
+ end
189
+
190
+ Sprinkle is a work in progress and I'm excited to hear if anyone finds it useful - please feel free to
191
+ comment, ask any questions, or send in any ideas, patches, bugs. All most welcome.
192
+
193
+ Marcus Crafter <crafterm@redartisan.com>
194
+
195
+ == LICENSE:
196
+
197
+ (The MIT License)
198
+
199
+ Copyright (c) 2008 Marcus Crafter <crafterm@redartisan.com>
200
+
201
+ Permission is hereby granted, free of charge, to any person obtaining
202
+ a copy of this software and associated documentation files (the
203
+ 'Software'), to deal in the Software without restriction, including
204
+ without limitation the rights to use, copy, modify, merge, publish,
205
+ distribute, sublicense, and/or sell copies of the Software, and to
206
+ permit persons to whom the Software is furnished to do so, subject to
207
+ the following conditions:
208
+
209
+ The above copyright notice and this permission notice shall be
210
+ included in all copies or substantial portions of the Software.
211
+
212
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
213
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
214
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
215
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
216
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
217
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
218
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
3
+
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
data/bin/sprinkle ADDED
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created on 2008-3-11.
4
+ # Copyright (c) 2008. All rights reserved.
5
+
6
+ begin
7
+ require 'rubygems'
8
+ rescue LoadError
9
+ # no rubygems to load, so we fail silently
10
+ end
11
+
12
+ require 'optparse'
13
+
14
+ # NOTE: the option -p/--path= is given as an example, and should probably be replaced in your application.
15
+
16
+ OPTIONS = {}
17
+ MANDATORY_OPTIONS = %w( path )
18
+
19
+ parser = OptionParser.new do |opts|
20
+ opts.banner = <<BANNER
21
+ Sprinkle
22
+ ========
23
+
24
+ http://github.com/crafterm/sprinkle
25
+
26
+ Sprinkle is a software provisioning tool you can use to build remote servers with. eg. to
27
+ install a Rails or Merb stack on a brand new slice directly after its been created. It uses
28
+ a Ruby based domain specific language to describe packages and policies to determine what
29
+ should be installed on particular systems.
30
+
31
+ Please see http://github.com/crafterm/sprinkle/tree/master/README.txt for more information.
32
+
33
+ Usage
34
+ =====
35
+
36
+ $> #{File.basename($0)} [options]
37
+
38
+ Options are:
39
+ BANNER
40
+ opts.separator ""
41
+ opts.on("-s", "--script=PATH", String,
42
+ "Path to a sprinkle script to run") { |OPTIONS[:path]| }
43
+ opts.on("-t", "--test",
44
+ "Process but don't perform any actions") { |OPTIONS[:testing]| }
45
+ opts.on("-v", "--verbose",
46
+ "Verbose output") { |OPTIONS[:verbose]| }
47
+ opts.on("-c", "--cloud",
48
+ "Show powder cloud, ie. package hierarchy and installation order") { |OPTIONS[:cloud]| }
49
+ opts.on("-h", "--help",
50
+ "Show this help message.") { puts opts; exit }
51
+ opts.parse!(ARGV)
52
+
53
+ if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| OPTIONS[option.to_sym].nil? }
54
+ puts opts; exit
55
+ end
56
+ end
57
+
58
+ def operation_mode(options)
59
+ Sprinkle::OPTIONS[:testing] = OPTIONS[:testing] || false
60
+ end
61
+
62
+ def powder_cloud(options)
63
+ Sprinkle::OPTIONS[:cloud] = OPTIONS[:cloud] || false
64
+ end
65
+
66
+ def log_level(options)
67
+ Object.logger.level = ActiveSupport::BufferedLogger::Severity::DEBUG if options[:verbose]
68
+ end
69
+
70
+ require 'sprinkle'
71
+
72
+ powder = OPTIONS[:path]
73
+ raise "Sprinkle script is not readable: #{powder}" unless File.readable?(powder)
74
+
75
+ operation_mode(OPTIONS)
76
+ powder_cloud(OPTIONS)
77
+ log_level(OPTIONS)
78
+
79
+ Sprinkle::Script.sprinkle File.read(powder), powder
data/config/hoe.rb ADDED
@@ -0,0 +1,70 @@
1
+ require 'sprinkle/version'
2
+
3
+ AUTHOR = 'Marcus Crafter' # can also be an array of Authors
4
+ EMAIL = "crafterm@redartisan.com"
5
+ DESCRIPTION = "Ruby DSL based software provisioning tool"
6
+ GEM_NAME = 'sprinkle' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = 'sprinkle' # The unix name for your project
8
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
+
11
+ @config_file = "~/.rubyforge/user-config.yml"
12
+ @config = nil
13
+ RUBYFORGE_USERNAME = "unknown"
14
+ def rubyforge_username
15
+ unless @config
16
+ begin
17
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
18
+ rescue
19
+ puts <<-EOS
20
+ ERROR: No rubyforge config file found: #{@config_file}
21
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
22
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
23
+ EOS
24
+ exit
25
+ end
26
+ end
27
+ RUBYFORGE_USERNAME.replace @config["username"]
28
+ end
29
+
30
+
31
+ REV = nil
32
+ # UNCOMMENT IF REQUIRED:
33
+ # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
34
+ VERS = Sprinkle::VERSION::STRING + (REV ? ".#{REV}" : "")
35
+ RDOC_OPTS = ['--quiet', '--title', 'sprinkle documentation',
36
+ "--opname", "index.html",
37
+ "--line-numbers",
38
+ "--main", "README",
39
+ "--inline-source"]
40
+
41
+ class Hoe
42
+ def extra_deps
43
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
44
+ @extra_deps
45
+ end
46
+ end
47
+
48
+ # Generate all the Rake tasks
49
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
50
+ hoe = Hoe.new(GEM_NAME, VERS) do |p|
51
+ p.developer(AUTHOR, EMAIL)
52
+ p.description = DESCRIPTION
53
+ p.summary = DESCRIPTION
54
+ p.url = HOMEPATH
55
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
56
+ p.test_globs = ["test/**/test_*.rb"]
57
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
58
+
59
+ # == Optional
60
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
61
+ p.extra_deps = [ ['activesupport', '>= 2.0.2'], ['highline', '>= 1.4.0'], ['capistrano', '>= 2.2.0'] ] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
62
+
63
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
64
+
65
+ end
66
+
67
+ CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
68
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
69
+ hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
70
+ hoe.rsync_args = '-av --delete --ignore-errors'
@@ -0,0 +1,17 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe newgem rubigen].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
16
+
17
+ require 'sprinkle'
@@ -0,0 +1,5 @@
1
+ set :application, "application"
2
+
3
+ role :app, "yourhost.com"
4
+ role :web, "yourhost.com"
5
+ role :db, "yourhost.com", :primary => true
@@ -0,0 +1,15 @@
1
+ = Example Rails Spinkle Deployment Script
2
+
3
+ The following example shows how you can provision Rails and associated packages onto a remote server (or set of servers).
4
+
5
+ == Usage:
6
+
7
+ $> sprinkle -s rails.rb
8
+
9
+ or in test mode:
10
+
11
+ $> sprinkle -t -s rails.rb
12
+
13
+ == Information
14
+
15
+ For more information, please see: http://github.com/crafterm/sprinkle/tree/master/README.txt
@@ -0,0 +1,2 @@
1
+ set :user, 'root'
2
+ role :app, 'yourhost.com', :primary => true
@@ -0,0 +1,9 @@
1
+ package :mysql, :provides => :database do
2
+ description 'MySQL Database'
3
+ apt %w( mysql-server mysql-client )
4
+ end
5
+
6
+ package :mysql_driver do
7
+ description 'Ruby MySQL database driver'
8
+ gem 'mysql'
9
+ end
@@ -0,0 +1,6 @@
1
+ ## Special package, anything that defines a 'source' package means build-essential should be installed for Ubuntu
2
+
3
+ package :build_essential do
4
+ description 'Build tools'
5
+ apt 'build-essential'
6
+ end
@@ -0,0 +1,28 @@
1
+ ## Defines available packages
2
+
3
+ package :ruby do
4
+ description 'Ruby Virtual Machine'
5
+ version '1.8.6'
6
+ source "ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-#{version}-p111.tar.gz" # implicit :style => :gnu
7
+ requires :ruby_dependencies
8
+ end
9
+
10
+ package :ruby_dependencies do
11
+ description 'Ruby Virtual Machine Build Dependencies'
12
+ apt %w( bison zlib1g-dev libssl-dev libreadline5-dev libncurses5-dev file )
13
+ end
14
+
15
+ package :rubygems do
16
+ description 'Ruby Gems Package Management System'
17
+ version '1.0.1'
18
+ source "http://rubyforge.org/frs/download.php/29548/rubygems-#{version}.tgz" do
19
+ custom_install 'ruby setup.rb'
20
+ end
21
+ requires :ruby
22
+ end
23
+
24
+ package :rails do
25
+ description 'Ruby on Rails'
26
+ gem 'rails'
27
+ version '2.0.2'
28
+ end
@@ -0,0 +1,11 @@
1
+ package :sphinx, :provides => :search do
2
+ description 'MySQL full text search engine'
3
+ version '0.9.8-rc2'
4
+ source "http://www.sphinxsearch.com/downloads/sphinx-#{version}.tar.gz"
5
+ requires :mysql_dev
6
+ end
7
+
8
+ package :mysql_dev do
9
+ description 'MySQL Database development package'
10
+ apt %w( libmysqlclient15-dev )
11
+ end
@@ -0,0 +1,28 @@
1
+ package :mongrel do
2
+ description 'Mongrel Application Server'
3
+ gem 'mongrel'
4
+ version '1.1.4'
5
+ end
6
+
7
+ package :mongrel_cluster, :provides => :appserver do
8
+ description 'Cluster Management for Mongrel'
9
+ gem 'mongrel_cluster'
10
+ version '1.0.5'
11
+ requires :mongrel
12
+ end
13
+
14
+ package :apache, :provides => :webserver do
15
+ description 'Apache 2 HTTP Server'
16
+ version '2.2.6'
17
+ source "http://apache.wildit.net.au/httpd/httpd-#{version}.tar.bz2" do
18
+ enable %w( mods-shared=all proxy proxy-balancer proxy-http rewrite cache headers ssl deflate so )
19
+ prefix "/opt/local/apache2-#{version}"
20
+ post :install, 'install -m 755 support/apachectl /etc/init.d/apache2', 'update-rc.d -f apache2 defaults'
21
+ end
22
+ requires :apache_dependencies
23
+ end
24
+
25
+ package :apache_dependencies do
26
+ description 'Apache 2 HTTP Server Build Dependencies'
27
+ apt %w( openssl libtool mawk zlib1g-dev libssl-dev )
28
+ end
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env sprinkle -s
2
+
3
+ # Annotated Example Sprinkle Rails deployment script
4
+ #
5
+ # This is an example Sprinkle script configured to install Rails from gems, Apache, Ruby and
6
+ # Sphinx from source, and mysql from apt on an Ubuntu system.
7
+ #
8
+ # Installation is configured to run via capistrano (and an accompanying deploy.rb recipe script).
9
+ # Source based packages are downloaded and built into /usr/local on the remote system.
10
+ #
11
+ # A sprinkle script is separated into 3 different sections. Packages, policies and deployment:
12
+
13
+
14
+ # Packages (separate files for brevity)
15
+ #
16
+ # Defines the world of packages as we know it. Each package has a name and
17
+ # set of metadata including its installer type (eg. apt, source, gem, etc). Packages can have
18
+ # relationships to each other via dependencies.
19
+
20
+ require 'packages/essential'
21
+ require 'packages/rails'
22
+ require 'packages/database'
23
+ require 'packages/server'
24
+ require 'packages/search'
25
+
26
+
27
+ # Policies
28
+ #
29
+ # Names a group of packages (optionally with versions) that apply to a particular set of roles:
30
+ #
31
+ # Associates the rails policy to the application servers. Contains rails, and surrounding
32
+ # packages. Note, appserver, database, webserver and search are all virtual packages defined above.
33
+ # If there's only one implementation of a virtual package, it's selected automatically, otherwise
34
+ # the user is requested to select which one to use.
35
+
36
+ policy :rails, :roles => :app do
37
+ requires :rails, :version => '2.0.2'
38
+ requires :appserver
39
+ requires :database
40
+ requires :webserver
41
+ requires :search
42
+ end
43
+
44
+
45
+ # Deployment
46
+ #
47
+ # Defines script wide settings such as a delivery mechanism for executing commands on the target
48
+ # system (eg. capistrano), and installer defaults (eg. build locations, etc):
49
+ #
50
+ # Configures spinkle to use capistrano for delivery of commands to the remote machines (via
51
+ # the named 'deploy' recipe). Also configures 'source' installer defaults to put package gear
52
+ # in /usr/local
53
+
54
+ deployment do
55
+
56
+ # mechanism for deployment
57
+ delivery :capistrano do
58
+ recipes 'deploy'
59
+ end
60
+
61
+ # source based package installer defaults
62
+ source do
63
+ prefix '/usr/local'
64
+ archives '/usr/local/sources'
65
+ builds '/usr/local/build'
66
+ end
67
+
68
+ end
69
+
70
+ # End of script, given the above information, Spinkle will apply the defined policy on all roles using the
71
+ # deployment settings specified.