sprinkle 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/CREDITS +14 -0
  2. data/History.txt +4 -0
  3. data/MIT-LICENSE +20 -0
  4. data/Manifest.txt +63 -0
  5. data/README.rdoc +218 -0
  6. data/Rakefile +4 -0
  7. data/TODO +56 -0
  8. data/bin/sprinkle +79 -0
  9. data/config/hoe.rb +70 -0
  10. data/config/requirements.rb +17 -0
  11. data/examples/merb/deploy.rb +5 -0
  12. data/examples/rails/README +15 -0
  13. data/examples/rails/deploy.rb +2 -0
  14. data/examples/rails/packages/database.rb +9 -0
  15. data/examples/rails/packages/essential.rb +6 -0
  16. data/examples/rails/packages/rails.rb +28 -0
  17. data/examples/rails/packages/search.rb +11 -0
  18. data/examples/rails/packages/server.rb +28 -0
  19. data/examples/rails/rails.rb +71 -0
  20. data/examples/sprinkle/sprinkle.rb +38 -0
  21. data/lib/sprinkle/actors/capistrano.rb +80 -0
  22. data/lib/sprinkle/actors/vlad.rb +30 -0
  23. data/lib/sprinkle/deployment.rb +33 -0
  24. data/lib/sprinkle/extensions/arbitrary_options.rb +10 -0
  25. data/lib/sprinkle/extensions/array.rb +7 -0
  26. data/lib/sprinkle/extensions/blank_slate.rb +5 -0
  27. data/lib/sprinkle/extensions/dsl_accessor.rb +15 -0
  28. data/lib/sprinkle/extensions/string.rb +10 -0
  29. data/lib/sprinkle/extensions/symbol.rb +7 -0
  30. data/lib/sprinkle/installers/apt.rb +20 -0
  31. data/lib/sprinkle/installers/gem.rb +33 -0
  32. data/lib/sprinkle/installers/installer.rb +85 -0
  33. data/lib/sprinkle/installers/rake.rb +17 -0
  34. data/lib/sprinkle/installers/rpm.rb +20 -0
  35. data/lib/sprinkle/installers/source.rb +120 -0
  36. data/lib/sprinkle/package.rb +94 -0
  37. data/lib/sprinkle/policy.rb +85 -0
  38. data/lib/sprinkle/script.rb +13 -0
  39. data/lib/sprinkle/sequence.rb +21 -0
  40. data/lib/sprinkle/version.rb +9 -0
  41. data/lib/sprinkle.rb +26 -0
  42. data/script/destroy +14 -0
  43. data/script/generate +14 -0
  44. data/spec/spec.opts +1 -0
  45. data/spec/spec_helper.rb +17 -0
  46. data/spec/sprinkle/actors/capistrano_spec.rb +150 -0
  47. data/spec/sprinkle/deployment_spec.rb +80 -0
  48. data/spec/sprinkle/extensions/array_spec.rb +19 -0
  49. data/spec/sprinkle/extensions/string_spec.rb +21 -0
  50. data/spec/sprinkle/installers/apt_spec.rb +53 -0
  51. data/spec/sprinkle/installers/gem_spec.rb +75 -0
  52. data/spec/sprinkle/installers/installer_spec.rb +125 -0
  53. data/spec/sprinkle/installers/rpm_spec.rb +50 -0
  54. data/spec/sprinkle/installers/source_spec.rb +315 -0
  55. data/spec/sprinkle/package_spec.rb +247 -0
  56. data/spec/sprinkle/policy_spec.rb +126 -0
  57. data/spec/sprinkle/script_spec.rb +51 -0
  58. data/spec/sprinkle/sequence_spec.rb +44 -0
  59. data/spec/sprinkle/sprinkle_spec.rb +25 -0
  60. data/sprinkle.gemspec +43 -0
  61. data/tasks/deployment.rake +34 -0
  62. data/tasks/environment.rake +7 -0
  63. data/tasks/rspec.rake +21 -0
  64. metadata +157 -0
data/CREDITS ADDED
@@ -0,0 +1,14 @@
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)
12
+ Matt Allen (http://blog.allen.com.au)
13
+ Eric Hodel (http://blog.segment7.net)
14
+ Pete Yandell (http://notahat.com)
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,63 @@
1
+ CREDITS
2
+ History.txt
3
+ MIT-LICENSE
4
+ Manifest.txt
5
+ README.rdoc
6
+ Rakefile
7
+ TODO
8
+ bin/sprinkle
9
+ config/hoe.rb
10
+ config/requirements.rb
11
+ examples/merb/deploy.rb
12
+ examples/rails/README
13
+ examples/rails/deploy.rb
14
+ examples/rails/packages/database.rb
15
+ examples/rails/packages/essential.rb
16
+ examples/rails/packages/rails.rb
17
+ examples/rails/packages/search.rb
18
+ examples/rails/packages/server.rb
19
+ examples/rails/rails.rb
20
+ examples/sprinkle/sprinkle.rb
21
+ lib/sprinkle.rb
22
+ lib/sprinkle/actors/capistrano.rb
23
+ lib/sprinkle/actors/vlad.rb
24
+ lib/sprinkle/deployment.rb
25
+ lib/sprinkle/extensions/arbitrary_options.rb
26
+ lib/sprinkle/extensions/array.rb
27
+ lib/sprinkle/extensions/blank_slate.rb
28
+ lib/sprinkle/extensions/dsl_accessor.rb
29
+ lib/sprinkle/extensions/string.rb
30
+ lib/sprinkle/extensions/symbol.rb
31
+ lib/sprinkle/installers/apt.rb
32
+ lib/sprinkle/installers/gem.rb
33
+ lib/sprinkle/installers/installer.rb
34
+ lib/sprinkle/installers/rake.rb
35
+ lib/sprinkle/installers/rpm.rb
36
+ lib/sprinkle/installers/source.rb
37
+ lib/sprinkle/package.rb
38
+ lib/sprinkle/policy.rb
39
+ lib/sprinkle/script.rb
40
+ lib/sprinkle/sequence.rb
41
+ lib/sprinkle/version.rb
42
+ script/destroy
43
+ script/generate
44
+ spec/spec.opts
45
+ spec/spec_helper.rb
46
+ spec/sprinkle/actors/capistrano_spec.rb
47
+ spec/sprinkle/deployment_spec.rb
48
+ spec/sprinkle/extensions/array_spec.rb
49
+ spec/sprinkle/extensions/string_spec.rb
50
+ spec/sprinkle/installers/apt_spec.rb
51
+ spec/sprinkle/installers/gem_spec.rb
52
+ spec/sprinkle/installers/installer_spec.rb
53
+ spec/sprinkle/installers/rpm_spec.rb
54
+ spec/sprinkle/installers/source_spec.rb
55
+ spec/sprinkle/package_spec.rb
56
+ spec/sprinkle/policy_spec.rb
57
+ spec/sprinkle/script_spec.rb
58
+ spec/sprinkle/sequence_spec.rb
59
+ spec/sprinkle/sprinkle_spec.rb
60
+ sprinkle.gemspec
61
+ tasks/deployment.rake
62
+ tasks/environment.rake
63
+ tasks/rspec.rake
data/README.rdoc ADDED
@@ -0,0 +1,218 @@
1
+ = SPRINKLE
2
+
3
+ http://redartisan.com/2008/5/27/sprinkle-intro
4
+ http://github.com/crafterm/sprinkle
5
+
6
+ == DESCRIPTION:
7
+
8
+ Sprinkle is a software provisioning tool you can use to build remote servers with, after the base operating
9
+ system has been installed. For example, to install a Rails or Merb stack on a brand new slice directly after
10
+ its been created.
11
+
12
+ Properties of packages such as their name, type, dependencies, etc, and what packages apply to what machines
13
+ is described via a domain specific language that Sprinkle executes (in fact one of the aims of Sprinkle is to
14
+ define as concisely as possible a language for installing software).
15
+
16
+ An example package description follows:
17
+
18
+ package :ruby do
19
+ description 'Ruby Virtual Machine'
20
+ version '1.8.6'
21
+ source "ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-#{version}-p111.tar.gz"
22
+ requires :ruby_dependencies
23
+ end
24
+
25
+ This defines a package called 'ruby', that uses the source based installer to build Ruby 1.8.6 from source,
26
+ installing the package 'ruby_dependencies' beforehand.
27
+
28
+ Reasonable defaults are set by sprinkle, such as the install prefix, download area, etc, but can be customized
29
+ globally or per package (see below for an example).
30
+
31
+ Since packages come in many forms (eg. gems, pre-compiled debs, compressed source tar.gz, etc), Sprinkle supports
32
+ many different installer types, giving you the most amount of flexibility of how you'd like software installed.
33
+ New installer types can be added into the system easily.
34
+
35
+ For example, you could install Rails via gems, nginx via source, and mysql via APT, while retaining the flexibility
36
+ of changing installer types as software is updated upstream.
37
+
38
+ Sprinkle also supports dependencies between packages, allowing you specify pre-requisites that need to be
39
+ installed in order.
40
+
41
+ Packages can be grouped into polices to define several packages that should be installed together.
42
+
43
+ An example policy:
44
+
45
+ policy :rails, :roles => :app do
46
+ requires :rails, :version => '2.1.0'
47
+ requires :appserver
48
+ requires :database
49
+ requires :webserver
50
+ end
51
+
52
+ This defines a policy called Rails, that applies to machines of role :app. The policy includes the packages
53
+ rails (version 2.1.0), appserver, database and webserver.
54
+
55
+ appserver, database and webserver can be virtual packages, where the user will be prompted for selection if
56
+ multiple choices for the virtual package exist.
57
+
58
+ Sprinkle is architected to be extendable in many ways, one of those areas is in its deployment of commands to
59
+ remote hosts. Currently Sprinkle supports the use of Capistrano or Vlad to issue commands on remote hosts via ssh,
60
+ but could also be extended to use any other command transport mechanism or be used to simply issue installation
61
+ commands on the local system.
62
+
63
+ An full example Sprinkle deployment script for deploying Rails (via gems), MySQL (via APT), and Apache (via source):
64
+
65
+ # Sprinkle Rails deployment script
66
+ #
67
+ # This is an example Sprinkle script, configured to install Rails from gems, Apache and Ruby from source,
68
+ # and mysql from apt on an Ubuntu system. Installation is configured to run via Capistrano (and
69
+ # an accompanying deploy.rb recipe script). Source based packages are downloaded and built into
70
+ # /usr/local on the remote system.
71
+ #
72
+ # A sprinkle script is separated into 3 different sections. Packages, policies and deployment.
73
+ #
74
+ # Packages
75
+ #
76
+ # Defines the world of packages as we know it. Each package has a name and
77
+ # set of metadata including its installer type (eg. apt, source, gem, etc). Packages can have
78
+ # relationships to each other via dependencies
79
+ #
80
+ # Policies
81
+ #
82
+ # Names a group of packages (optionally with versions) that apply to a particular set of roles.
83
+ #
84
+ # Deployment
85
+ #
86
+ # Defines script wide settings such as a delivery mechanism for executing commands on the target
87
+ # system (eg. capistrano), and installer defaults (eg. build locations, etc).
88
+
89
+ # Packages
90
+
91
+ package :ruby do
92
+ description 'Ruby Virtual Machine'
93
+ version '1.8.6'
94
+ source "ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-#{version}-p111.tar.gz"
95
+ requires :ruby_dependencies
96
+ end
97
+
98
+ package :ruby_dependencies do
99
+ description 'Ruby Virtual Machine Build Dependencies'
100
+ apt %w( bison zlib1g-dev libssl-dev libreadline5-dev libncurses5-dev file )
101
+ end
102
+
103
+ package :mysql, :provides => :database do
104
+ description 'MySQL Database'
105
+ apt %w( mysql-server mysql-client )
106
+ end
107
+
108
+ package :apache, :provides => :webserver do
109
+ description 'Apache 2 HTTP Server'
110
+ version '2.2.9'
111
+ source "http://apache.wildit.net.au/httpd/httpd-#{version}.tar.bz2" do
112
+ enable %w( mods-shared=all proxy proxy-balancer proxy-http rewrite cache headers ssl deflate so )
113
+ prefix "/opt/local/apache2-#{version}"
114
+ post :install, 'install -m 755 support/apachectl /etc/init.d/apache2', 'update-rc.d -f apache2 defaults'
115
+ end
116
+ requires :apache_dependencies
117
+ end
118
+
119
+ package :apache_dependencies do
120
+ description 'Apache 2 HTTP Server Build Dependencies'
121
+ apt %w( openssl libtool mawk zlib1g-dev libssl-dev )
122
+ end
123
+
124
+ package :rubygems do
125
+ description 'Ruby Gems Package Management System'
126
+ version '1.2.0'
127
+ source "http://rubyforge.org/frs/download.php/38646/rubygems-#{version}.tgz" do
128
+ custom_install 'ruby setup.rb'
129
+ end
130
+ requires :ruby
131
+ end
132
+
133
+ package :rails do
134
+ description 'Ruby on Rails'
135
+ gem 'rails'
136
+ version '2.1.0'
137
+ end
138
+
139
+ package :mongrel do
140
+ description 'Mongrel Application Server'
141
+ gem 'mongrel'
142
+ version '1.1.5'
143
+ end
144
+
145
+ package :mongrel_cluster, :provides => :appserver do
146
+ description 'Cluster Management for Mongrel'
147
+ gem 'mongrel_cluster' # :source => 'http://gems.github.com/' for alternate gem server
148
+ version '1.0.5'
149
+ requires :mongrel
150
+ end
151
+
152
+ # Policies
153
+
154
+ # Associates the rails policy to the application servers. Contains rails, and surrounding
155
+ # packages. Note, appserver, database and webserver are all virtual packages defined above. If
156
+ # there's only one implementation of a virtual package, it's selected automatically, otherwise
157
+ # the user is requested to select which one to use.
158
+
159
+ policy :rails, :roles => :app do
160
+ requires :rails, :version => '2.1.0'
161
+ requires :appserver
162
+ requires :database
163
+ requires :webserver
164
+ end
165
+
166
+ # Deployment
167
+
168
+ # Configures sprinkle to use capistrano for delivery of commands to the remote machines (via
169
+ # the named 'deploy' recipe). Also configures 'source' installer defaults to put package gear
170
+ # in /usr/local
171
+
172
+ deployment do
173
+
174
+ # mechanism for deployment
175
+ delivery :capistrano do
176
+ recipes 'deploy'
177
+ end
178
+
179
+ # source based package installer defaults
180
+ source do
181
+ prefix '/usr/local' # where all source packages will be configured to install
182
+ archives '/usr/local/sources' # where all source packages will be downloaded to
183
+ builds '/usr/local/build' # where all source packages will be built
184
+ end
185
+
186
+ end
187
+
188
+ Please see the examples directory for more complete examples of Sprinkle deployment scripts.
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/TODO ADDED
@@ -0,0 +1,56 @@
1
+ Version 0.1 plan
2
+ ================
3
+
4
+ INSTALLER
5
+ * Fix up apt so that we can handle it if it asks questions, or fail? Check with Ben
6
+ * Support alternate gem package sources - DONE
7
+ * MD5/SHA1 checking on the installation files?
8
+
9
+ MISC
10
+ * Growl support
11
+ * Do a merb example
12
+ * Fix up printing of output so that its nice and a bit more like ports - DONE
13
+ * print ports style output for stages (installing, configuring, etc...)
14
+ * Add an option to print the hierarchy tree of packages to be installed only - DONE
15
+ * BlankSlate - active support has one
16
+ * CREDITS file - DONE
17
+ * Get #!/usr/bin/env sprinkle working - DONE
18
+
19
+ OPERATING SYSTEM
20
+ * OS abstraction
21
+ * build essential on Ubuntu only for example
22
+
23
+ TESTING
24
+ * Test on a base system Ubuntu system - DONE
25
+ * Multiple runs, check system that's partially installed - DONE
26
+ * Resuming downloads with wget ok - DONE
27
+
28
+ ERRORS
29
+ * Need to think about handling errors nicely
30
+ * Recovering from an error, and or successive runs of sprinkle
31
+ * store installed state on the remote server so we can skip installed packages?
32
+ * what about self healing things later? need to think about it
33
+
34
+ DOCUMENTATION
35
+ * Document the code somewhat, at least review that its all ok
36
+ * Wiki
37
+ * Home page somewhere? point to github
38
+ * Blog post
39
+ * Screencast - use that cool screenflow tool?
40
+
41
+ Post Version 0.1 plan
42
+ =====================
43
+
44
+ CONFIGURATION
45
+ * Think about it - talk to Lincoln and Ben
46
+ * Use cap 2.3 send/download file helpers, might be useful somehow for transporting config files
47
+
48
+ ACTOR
49
+ * Investigate a pure net:ssh/gateway delivery mechanism, ie. without cap?
50
+ * Generate a cap task file as output? not sure if people would be interested in this?
51
+ * use ruby2ruby to generate the file, nice :)
52
+
53
+ MISC
54
+ * Slicehost API support for creating a slice on the way
55
+ * active resource
56
+ * SSH keys, have to deploy them somehow?
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.2.0'
18
+ source "http://rubyforge.org/frs/download.php/38646/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.1.0'
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.9'
17
+ source "http://www.apache.org/dist/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