jemmyw-sprinkle 0.2.3

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 (105) hide show
  1. data/CREDITS +21 -0
  2. data/History.txt +4 -0
  3. data/MIT-LICENSE +20 -0
  4. data/Manifest.txt +104 -0
  5. data/README.txt +241 -0
  6. data/Rakefile +4 -0
  7. data/bin/sprinkle +86 -0
  8. data/config/hoe.rb +70 -0
  9. data/config/requirements.rb +17 -0
  10. data/examples/packages/build_essential.rb +9 -0
  11. data/examples/packages/databases/mysql.rb +13 -0
  12. data/examples/packages/databases/sqlite3.rb +16 -0
  13. data/examples/packages/phusion.rb +55 -0
  14. data/examples/packages/ruby/rails.rb +9 -0
  15. data/examples/packages/ruby/ruby.rb +17 -0
  16. data/examples/packages/ruby/rubygems.rb +17 -0
  17. data/examples/packages/scm/git.rb +11 -0
  18. data/examples/packages/scm/subversion.rb +4 -0
  19. data/examples/packages/servers/apache.rb +15 -0
  20. data/examples/rails/README +15 -0
  21. data/examples/rails/deploy.rb +2 -0
  22. data/examples/rails/packages/database.rb +9 -0
  23. data/examples/rails/packages/essential.rb +9 -0
  24. data/examples/rails/packages/rails.rb +28 -0
  25. data/examples/rails/packages/scm.rb +11 -0
  26. data/examples/rails/packages/search.rb +11 -0
  27. data/examples/rails/packages/server.rb +28 -0
  28. data/examples/rails/rails.rb +73 -0
  29. data/examples/sprinkle/sprinkle.rb +38 -0
  30. data/lib/sprinkle/actors/actors.rb +17 -0
  31. data/lib/sprinkle/actors/capistrano.rb +147 -0
  32. data/lib/sprinkle/actors/local.rb +50 -0
  33. data/lib/sprinkle/actors/ssh.rb +81 -0
  34. data/lib/sprinkle/actors/vlad.rb +65 -0
  35. data/lib/sprinkle/configurable.rb +31 -0
  36. data/lib/sprinkle/deployment.rb +77 -0
  37. data/lib/sprinkle/extensions/arbitrary_options.rb +10 -0
  38. data/lib/sprinkle/extensions/array.rb +5 -0
  39. data/lib/sprinkle/extensions/blank_slate.rb +5 -0
  40. data/lib/sprinkle/extensions/dsl_accessor.rb +15 -0
  41. data/lib/sprinkle/extensions/string.rb +10 -0
  42. data/lib/sprinkle/extensions/symbol.rb +7 -0
  43. data/lib/sprinkle/installers/apt.rb +52 -0
  44. data/lib/sprinkle/installers/bsd_port.rb +33 -0
  45. data/lib/sprinkle/installers/custom.rb +28 -0
  46. data/lib/sprinkle/installers/deb.rb +38 -0
  47. data/lib/sprinkle/installers/freebsd_pkg.rb +37 -0
  48. data/lib/sprinkle/installers/gem.rb +63 -0
  49. data/lib/sprinkle/installers/installer.rb +120 -0
  50. data/lib/sprinkle/installers/mac_port.rb +38 -0
  51. data/lib/sprinkle/installers/openbsd_pkg.rb +47 -0
  52. data/lib/sprinkle/installers/opensolaris_pkg.rb +43 -0
  53. data/lib/sprinkle/installers/push_text.rb +45 -0
  54. data/lib/sprinkle/installers/rake.rb +37 -0
  55. data/lib/sprinkle/installers/rpm.rb +37 -0
  56. data/lib/sprinkle/installers/source.rb +179 -0
  57. data/lib/sprinkle/installers/yum.rb +37 -0
  58. data/lib/sprinkle/package.rb +293 -0
  59. data/lib/sprinkle/policy.rb +126 -0
  60. data/lib/sprinkle/script.rb +23 -0
  61. data/lib/sprinkle/verifiers/directory.rb +16 -0
  62. data/lib/sprinkle/verifiers/dpkg.rb +14 -0
  63. data/lib/sprinkle/verifiers/executable.rb +36 -0
  64. data/lib/sprinkle/verifiers/file.rb +26 -0
  65. data/lib/sprinkle/verifiers/process.rb +21 -0
  66. data/lib/sprinkle/verifiers/ruby.rb +25 -0
  67. data/lib/sprinkle/verifiers/symlink.rb +30 -0
  68. data/lib/sprinkle/verifiers/user.rb +11 -0
  69. data/lib/sprinkle/verify.rb +114 -0
  70. data/lib/sprinkle/version.rb +9 -0
  71. data/lib/sprinkle.rb +32 -0
  72. data/script/destroy +14 -0
  73. data/script/generate +14 -0
  74. data/spec/spec.opts +1 -0
  75. data/spec/spec_helper.rb +17 -0
  76. data/spec/sprinkle/actors/capistrano_spec.rb +194 -0
  77. data/spec/sprinkle/actors/local_spec.rb +29 -0
  78. data/spec/sprinkle/configurable_spec.rb +46 -0
  79. data/spec/sprinkle/deployment_spec.rb +80 -0
  80. data/spec/sprinkle/extensions/array_spec.rb +19 -0
  81. data/spec/sprinkle/extensions/string_spec.rb +21 -0
  82. data/spec/sprinkle/installers/apt_spec.rb +70 -0
  83. data/spec/sprinkle/installers/bsd_port_spec.rb +42 -0
  84. data/spec/sprinkle/installers/custom_spec.rb +29 -0
  85. data/spec/sprinkle/installers/freebsd_pkg_spec.rb +49 -0
  86. data/spec/sprinkle/installers/gem_spec.rb +91 -0
  87. data/spec/sprinkle/installers/installer_spec.rb +151 -0
  88. data/spec/sprinkle/installers/mac_port_spec.rb +42 -0
  89. data/spec/sprinkle/installers/openbsd_pkg_spec.rb +49 -0
  90. data/spec/sprinkle/installers/opensolaris_pkg_spec.rb +49 -0
  91. data/spec/sprinkle/installers/push_text_spec.rb +55 -0
  92. data/spec/sprinkle/installers/rake_spec.rb +29 -0
  93. data/spec/sprinkle/installers/rpm_spec.rb +50 -0
  94. data/spec/sprinkle/installers/source_spec.rb +331 -0
  95. data/spec/sprinkle/installers/yum_spec.rb +49 -0
  96. data/spec/sprinkle/package_spec.rb +452 -0
  97. data/spec/sprinkle/policy_spec.rb +133 -0
  98. data/spec/sprinkle/script_spec.rb +51 -0
  99. data/spec/sprinkle/sprinkle_spec.rb +25 -0
  100. data/spec/sprinkle/verify_spec.rb +185 -0
  101. data/sprinkle.gemspec +45 -0
  102. data/tasks/deployment.rake +34 -0
  103. data/tasks/environment.rake +7 -0
  104. data/tasks/rspec.rake +21 -0
  105. metadata +199 -0
data/CREDITS ADDED
@@ -0,0 +1,21 @@
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)
15
+ Adam Meehan (http://duckpunching.com)
16
+ Mitchell Hashimoto (http://mitchellhashimoto.com)
17
+ Ari Lerner (http://www.citrusbyte.com)
18
+ Jorgen Orehøj Erichsen (http://blog.erichsen.net)
19
+ Joshua Sierles (http://diluvia.net)
20
+ Julian Russell (http://github.com/plusplus)
21
+ Dave (Gassto) (http://github.com/gassto)
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,104 @@
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/packages/build_essential.rb
11
+ examples/packages/databases/mysql.rb
12
+ examples/packages/databases/sqlite3.rb
13
+ examples/packages/phusion.rb
14
+ examples/packages/ruby/rails.rb
15
+ examples/packages/ruby/ruby.rb
16
+ examples/packages/ruby/rubygems.rb
17
+ examples/packages/scm/git.rb
18
+ examples/packages/scm/subversion.rb
19
+ examples/packages/servers/apache.rb
20
+ examples/rails/README
21
+ examples/rails/deploy.rb
22
+ examples/rails/packages/database.rb
23
+ examples/rails/packages/essential.rb
24
+ examples/rails/packages/rails.rb
25
+ examples/rails/packages/scm.rb
26
+ examples/rails/packages/search.rb
27
+ examples/rails/packages/server.rb
28
+ examples/rails/rails.rb
29
+ examples/sprinkle/sprinkle.rb
30
+ lib/sprinkle.rb
31
+ lib/sprinkle/actors/actors.rb
32
+ lib/sprinkle/actors/capistrano.rb
33
+ lib/sprinkle/actors/local.rb
34
+ lib/sprinkle/actors/ssh.rb
35
+ lib/sprinkle/actors/vlad.rb
36
+ lib/sprinkle/configurable.rb
37
+ lib/sprinkle/deployment.rb
38
+ lib/sprinkle/extensions/arbitrary_options.rb
39
+ lib/sprinkle/extensions/array.rb
40
+ lib/sprinkle/extensions/blank_slate.rb
41
+ lib/sprinkle/extensions/dsl_accessor.rb
42
+ lib/sprinkle/extensions/string.rb
43
+ lib/sprinkle/extensions/symbol.rb
44
+ lib/sprinkle/installers/apt.rb
45
+ lib/sprinkle/installers/bsd_port.rb
46
+ lib/sprinkle/installers/deb.rb
47
+ lib/sprinkle/installers/freebsd_pkg.rb
48
+ lib/sprinkle/installers/gem.rb
49
+ lib/sprinkle/installers/installer.rb
50
+ lib/sprinkle/installers/mac_port.rb
51
+ lib/sprinkle/installers/openbsd_pkg.rb
52
+ lib/sprinkle/installers/opensolaris_pkg.rb
53
+ lib/sprinkle/installers/push_text.rb
54
+ lib/sprinkle/installers/rake.rb
55
+ lib/sprinkle/installers/rpm.rb
56
+ lib/sprinkle/installers/source.rb
57
+ lib/sprinkle/installers/yum.rb
58
+ lib/sprinkle/installers/custom.rb
59
+ lib/sprinkle/package.rb
60
+ lib/sprinkle/policy.rb
61
+ lib/sprinkle/script.rb
62
+ lib/sprinkle/verifiers/directory.rb
63
+ lib/sprinkle/verifiers/dpkg.rb
64
+ lib/sprinkle/verifiers/executable.rb
65
+ lib/sprinkle/verifiers/file.rb
66
+ lib/sprinkle/verifiers/process.rb
67
+ lib/sprinkle/verifiers/ruby.rb
68
+ lib/sprinkle/verifiers/symlink.rb
69
+ lib/sprinkle/verifiers/user.rb
70
+ lib/sprinkle/verify.rb
71
+ lib/sprinkle/version.rb
72
+ script/destroy
73
+ script/generate
74
+ spec/spec.opts
75
+ spec/spec_helper.rb
76
+ spec/sprinkle/actors/capistrano_spec.rb
77
+ spec/sprinkle/actors/local_spec.rb
78
+ spec/sprinkle/configurable_spec.rb
79
+ spec/sprinkle/deployment_spec.rb
80
+ spec/sprinkle/extensions/array_spec.rb
81
+ spec/sprinkle/extensions/string_spec.rb
82
+ spec/sprinkle/installers/apt_spec.rb
83
+ spec/sprinkle/installers/bsd_port_spec.rb
84
+ spec/sprinkle/installers/freebsd_pkg_spec.rb
85
+ spec/sprinkle/installers/gem_spec.rb
86
+ spec/sprinkle/installers/installer_spec.rb
87
+ spec/sprinkle/installers/mac_port_spec.rb
88
+ spec/sprinkle/installers/openbsd_pkg_spec.rb
89
+ spec/sprinkle/installers/opensolaris_pkg_spec.rb
90
+ spec/sprinkle/installers/push_text_spec.rb
91
+ spec/sprinkle/installers/rake_spec.rb
92
+ spec/sprinkle/installers/rpm_spec.rb
93
+ spec/sprinkle/installers/source_spec.rb
94
+ spec/sprinkle/installers/yum_spec.rb
95
+ spec/sprinkle/installers/custom_spec.rb
96
+ spec/sprinkle/package_spec.rb
97
+ spec/sprinkle/policy_spec.rb
98
+ spec/sprinkle/script_spec.rb
99
+ spec/sprinkle/sprinkle_spec.rb
100
+ spec/sprinkle/verify_spec.rb
101
+ sprinkle.gemspec
102
+ tasks/deployment.rake
103
+ tasks/environment.rake
104
+ tasks/rspec.rake
data/README.txt ADDED
@@ -0,0 +1,241 @@
1
+ = SPRINKLE
2
+
3
+ http://redartisan.com/2008/5/27/sprinkle-intro
4
+ http://github.com/crafterm/sprinkle
5
+ http://github.com/benschwarz/passenger-stack
6
+ http://www.vimeo.com/2888665
7
+ http://redartisan.lighthouseapp.com/projects/25275-sprinkle/tickets
8
+
9
+ == DESCRIPTION:
10
+
11
+ Sprinkle is a software provisioning tool you can use to build remote servers with, after the base operating
12
+ system has been installed. For example, to install a Rails or Merb stack on a brand new slice directly after
13
+ its been created.
14
+
15
+ Properties of packages such as their name, type, dependencies, etc, and what packages apply to what machines
16
+ is described via a domain specific language that Sprinkle executes (in fact one of the aims of Sprinkle is to
17
+ define as concisely as possible a language for installing software).
18
+
19
+ An example package description follows:
20
+
21
+ package :ruby do
22
+ description 'Ruby Virtual Machine'
23
+ version '1.8.6'
24
+ source "ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-#{version}-p111.tar.gz"
25
+ requires :ruby_dependencies
26
+
27
+ verify do
28
+ has_file '/usr/bin/ruby'
29
+ end
30
+ end
31
+
32
+ This defines a package called 'ruby', that uses the source based installer to build Ruby 1.8.6 from source,
33
+ installing the package 'ruby_dependencies' beforehand. Additionally, the package verifies it was installed
34
+ correctly by verifying the file '/usr/bin/ruby' exists after installation. If this verification fails, the
35
+ sprinkle script will gracefully stop.
36
+
37
+ Reasonable defaults are set by sprinkle, such as the install prefix, download area, etc, but can be customized
38
+ globally or per package (see below for an example).
39
+
40
+ Since packages come in many forms (eg. gems, pre-compiled debs, compressed source tar.gz, etc), Sprinkle supports
41
+ many different installer types, giving you the most amount of flexibility of how you'd like software installed.
42
+ New installer types can be added into the system easily.
43
+
44
+ For example, you could install Rails via gems, nginx via source, and mysql via APT, while retaining the flexibility
45
+ of changing installer types as software is updated upstream.
46
+
47
+ Sprinkle also supports dependencies between packages, allowing you specify pre-requisites that need to be
48
+ installed in order.
49
+
50
+ Packages can be grouped into polices to define several packages that should be installed together.
51
+
52
+ An example policy:
53
+
54
+ policy :rails, :roles => :app do
55
+ requires :rails, :version => '2.1.0'
56
+ requires :appserver
57
+ requires :database
58
+ requires :webserver
59
+ end
60
+
61
+ This defines a policy called Rails, that applies to machines of role :app. The policy includes the packages
62
+ rails (version 2.1.0), appserver, database and webserver.
63
+
64
+ appserver, database and webserver can be virtual packages, where the user will be prompted for selection if
65
+ multiple choices for the virtual package exist.
66
+
67
+ Sprinkle is architected to be extendable in many ways, one of those areas is in its deployment of commands to
68
+ remote hosts. Currently Sprinkle supports the use of Capistrano, Vlad, or a direct net/ssh connection to
69
+ issue commands on remote hosts via ssh, but could also be extended to use any other command transport mechanism
70
+ desired. Sprinkle can also be configured to simply issue installation commands to provision the local system.
71
+
72
+ An full example Sprinkle deployment script for deploying Rails (via gems), MySQL (via APT), Apache (via source)
73
+ and Git (via source with dependencies from APT):
74
+
75
+ # Sprinkle Rails deployment script
76
+ #
77
+ # This is an example Sprinkle script, configured to install Rails from gems, Apache, Ruby and Git from source,
78
+ # and mysql and Git dependencies from apt on an Ubuntu system. Installation is configured to run via
79
+ # Capistrano (and an accompanying deploy.rb recipe script). Source based packages are downloaded and built into
80
+ # /usr/local on the remote system.
81
+ #
82
+ # A sprinkle script is separated into 3 different sections. Packages, policies and deployment.
83
+ #
84
+ # Packages
85
+ #
86
+ # Defines the world of packages as we know it. Each package has a name and
87
+ # set of metadata including its installer type (eg. apt, source, gem, etc). Packages can have
88
+ # relationships to each other via dependencies
89
+ #
90
+ # Policies
91
+ #
92
+ # Names a group of packages (optionally with versions) that apply to a particular set of roles.
93
+ #
94
+ # Deployment
95
+ #
96
+ # Defines script wide settings such as a delivery mechanism for executing commands on the target
97
+ # system (eg. capistrano), and installer defaults (eg. build locations, etc).
98
+
99
+ # Packages
100
+
101
+ package :ruby do
102
+ description 'Ruby Virtual Machine'
103
+ version '1.8.6'
104
+ source "ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-#{version}-p111.tar.gz"
105
+ requires :ruby_dependencies
106
+ end
107
+
108
+ package :ruby_dependencies do
109
+ description 'Ruby Virtual Machine Build Dependencies'
110
+ apt %w( bison zlib1g-dev libssl-dev libreadline5-dev libncurses5-dev file )
111
+ end
112
+
113
+ package :mysql, :provides => :database do
114
+ description 'MySQL Database'
115
+ apt %w( mysql-server mysql-client )
116
+ end
117
+
118
+ package :apache, :provides => :webserver do
119
+ description 'Apache 2 HTTP Server'
120
+ version '2.2.9'
121
+ source "http://apache.wildit.net.au/httpd/httpd-#{version}.tar.bz2" do
122
+ enable %w( mods-shared=all proxy proxy-balancer proxy-http rewrite cache headers ssl deflate so )
123
+ prefix "/opt/local/apache2-#{version}"
124
+ post :install, 'install -m 755 support/apachectl /etc/init.d/apache2', 'update-rc.d -f apache2 defaults'
125
+ end
126
+ requires :apache_dependencies
127
+ end
128
+
129
+ package :apache_dependencies do
130
+ description 'Apache 2 HTTP Server Build Dependencies'
131
+ apt %w( openssl libtool mawk zlib1g-dev libssl-dev )
132
+ end
133
+
134
+ package :rubygems do
135
+ description 'Ruby Gems Package Management System'
136
+ version '1.2.0'
137
+ source "http://rubyforge.org/frs/download.php/38646/rubygems-#{version}.tgz" do
138
+ custom_install 'ruby setup.rb'
139
+ end
140
+ requires :ruby
141
+ end
142
+
143
+ package :rails do
144
+ description 'Ruby on Rails'
145
+ gem 'rails'
146
+ version '2.1.0'
147
+ end
148
+
149
+ package :mongrel do
150
+ description 'Mongrel Application Server'
151
+ gem 'mongrel'
152
+ version '1.1.5'
153
+ end
154
+
155
+ package :mongrel_cluster, :provides => :appserver do
156
+ description 'Cluster Management for Mongrel'
157
+ gem 'mongrel_cluster' # :source => 'http://gems.github.com/' for alternate gem server
158
+ version '1.0.5'
159
+ requires :mongrel
160
+ end
161
+
162
+ package :git, :provides => :scm do
163
+ description 'Git Distributed Version Control'
164
+ version '1.5.6.3'
165
+ source "http://kernel.org/pub/software/scm/git/git-#{version}.tar.gz"
166
+ requires :git_dependencies
167
+ end
168
+
169
+ package :git_dependencies do
170
+ description 'Git Build Dependencies'
171
+ apt 'git', :dependencies_only => true
172
+ end
173
+
174
+ # Policies
175
+
176
+ # Associates the rails policy to the application servers. Contains rails, and surrounding
177
+ # packages. Note, appserver, database and webserver are all virtual packages defined above. If
178
+ # there's only one implementation of a virtual package, it's selected automatically, otherwise
179
+ # the user is requested to select which one to use.
180
+
181
+ policy :rails, :roles => :app do
182
+ requires :rails, :version => '2.1.0'
183
+ requires :appserver
184
+ requires :database
185
+ requires :webserver
186
+ requires :scm
187
+ end
188
+
189
+ # Deployment
190
+
191
+ # Configures sprinkle to use capistrano for delivery of commands to the remote machines (via
192
+ # the named 'deploy' recipe). Also configures 'source' installer defaults to put package gear
193
+ # in /usr/local
194
+
195
+ deployment do
196
+
197
+ # mechanism for deployment
198
+ delivery :capistrano do
199
+ recipes 'deploy'
200
+ end
201
+
202
+ # source based package installer defaults
203
+ source do
204
+ prefix '/usr/local' # where all source packages will be configured to install
205
+ archives '/usr/local/sources' # where all source packages will be downloaded to
206
+ builds '/usr/local/build' # where all source packages will be built
207
+ end
208
+
209
+ end
210
+
211
+ Please see the examples directory for more complete examples of Sprinkle deployment scripts, and also the Passenger Stack github page and video by Ben Schwarz (http://github.com/benschwarz/passenger-stack and http://www.vimeo.com/2888665 respectively).
212
+
213
+ Sprinkle is a work in progress and I'm excited to hear if anyone finds it useful - please feel free to
214
+ comment, ask any questions, or send in any ideas, patches, bugs. All most welcome.
215
+
216
+ Marcus Crafter <crafterm@redartisan.com>
217
+
218
+ == LICENSE:
219
+
220
+ (The MIT License)
221
+
222
+ Copyright (c) 2008 Marcus Crafter <crafterm@redartisan.com>
223
+
224
+ Permission is hereby granted, free of charge, to any person obtaining
225
+ a copy of this software and associated documentation files (the
226
+ 'Software'), to deal in the Software without restriction, including
227
+ without limitation the rights to use, copy, modify, merge, publish,
228
+ distribute, sublicense, and/or sell copies of the Software, and to
229
+ permit persons to whom the Software is furnished to do so, subject to
230
+ the following conditions:
231
+
232
+ The above copyright notice and this permission notice shall be
233
+ included in all copies or substantial portions of the Software.
234
+
235
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
236
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
237
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
238
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
239
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
240
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
241
+ 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,86 @@
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("-f", "--force",
50
+ "Force installation of all packages even if it is detected that it has been previously installed") { |OPTIONS[:force]| }
51
+ opts.on("-h", "--help",
52
+ "Show this help message.") { puts opts; exit }
53
+ opts.parse!(ARGV)
54
+
55
+ if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| OPTIONS[option.to_sym].nil? }
56
+ puts opts; exit
57
+ end
58
+ end
59
+
60
+ def force_mode(options)
61
+ Sprinkle::OPTIONS[:force] = OPTIONS[:force] || false
62
+ end
63
+
64
+ def operation_mode(options)
65
+ Sprinkle::OPTIONS[:testing] = OPTIONS[:testing] || false
66
+ end
67
+
68
+ def powder_cloud(options)
69
+ Sprinkle::OPTIONS[:cloud] = OPTIONS[:cloud] || false
70
+ end
71
+
72
+ def log_level(options)
73
+ Object.logger.level = ActiveSupport::BufferedLogger::Severity::DEBUG if options[:verbose]
74
+ end
75
+
76
+ require 'sprinkle'
77
+
78
+ powder = OPTIONS[:path]
79
+ raise "Sprinkle script is not readable: #{powder}" unless File.readable?(powder)
80
+
81
+ force_mode(OPTIONS)
82
+ operation_mode(OPTIONS)
83
+ powder_cloud(OPTIONS)
84
+ log_level(OPTIONS)
85
+
86
+ 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.txt",
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.5.5'] ] # 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,9 @@
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' do
6
+ # Update the sources and upgrade the lists before we build essentials
7
+ pre :install, ['aptitude update', 'aptitude safe-upgrade', 'aptitude full-upgrade']
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ package :mysql, :provides => :database do
2
+ description 'MySQL Database'
3
+ apt %w( mysql-server mysql-client libmysqlclient15-dev )
4
+ end
5
+
6
+ package :mysql_ruby_driver do
7
+ description 'Ruby MySQL database driver'
8
+ gem 'mysql' # :build_flags => "—with-mysql-config=/usr/local/mysql/bin/mysql_config"
9
+
10
+ verify do
11
+ ruby_can_load 'mysql'
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ # Packages to install sqlite3 and the sqlite3 ruby driver.
2
+ package :sqlite3, :provides => :database do
3
+ description 'SQLite3 database'
4
+ apt 'sqlite3'
5
+ end
6
+
7
+ package :sqlite3_ruby_driver do
8
+ description 'Ruby SQLite3 library.'
9
+ apt 'libsqlite3-dev libsqlite3-ruby1.8'
10
+
11
+ requires :rubygems
12
+
13
+ verify do
14
+ ruby_can_load 'sqlite3'
15
+ end
16
+ end
@@ -0,0 +1,55 @@
1
+ # Contains software created by Phusion.nl which is Ruby Enterprise Edition
2
+ # and mod_rails
3
+
4
+ package :ruby_enterprise do
5
+ description 'Ruby Enterprise Edition'
6
+ version '1.8.6-20080810'
7
+ source 'http://rubyforge.org/frs/download.php/41040/ruby-enterprise-1.8.6-20080810.tar.gz' do
8
+ custom_install 'echo -en "\n\n\n\n" | ./installer'
9
+
10
+ # Modify the passenger conf file to point to REE
11
+ post :install, 'sed -i "s|^PassengerRuby [/a-zA-Z0-9.]*$|PassengerRuby /opt/ruby-enterprise-1.8.6-20080810/bin/ruby|" /etc/apache2/extras/passenger.conf'
12
+
13
+ # Restart apache
14
+ post :install, '/etc/init.d/apache2 restart'
15
+ end
16
+
17
+ verify do
18
+ has_directory '/opt/ruby-enterprise-1.8.6-20080810'
19
+ has_executable '/opt/ruby-enterprise-1.8.6-20080810/bin/ruby'
20
+ end
21
+
22
+ requires :apache
23
+ requires :passenger
24
+ end
25
+
26
+ package :passenger, :provides => :appserver do
27
+ description 'Phusion Passenger (mod_rails)'
28
+ gem 'passenger' do
29
+ post :install, 'echo -en "\n\n\n\n" | passenger-install-apache2-module'
30
+
31
+ # Create the passenger conf file
32
+ post :install, 'mkdir /etc/apache2/extras'
33
+ post :install, 'touch /etc/apache2/extras/passenger.conf'
34
+ post :install, "echo 'Include /etc/apache2/extras/passenger.conf' >> /etc/apache2/apache2.conf"
35
+
36
+ [%q(LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.3/ext/apache2/mod_passenger.so),
37
+ %q(PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.3),
38
+ %q(PassengerRuby /usr/bin/ruby1.8),
39
+ %q(RailsEnv development)].each do |line|
40
+ post :install, "echo '#{line}' >> /etc/apache2/extras/passenger.conf"
41
+ end
42
+
43
+ # Restart apache to note changes
44
+ post :install, '/etc/init.d/apache2 restart'
45
+ end
46
+
47
+ verify do
48
+ has_file '/etc/apache2/extras/passenger.conf'
49
+ has_file '/usr/lib/ruby/gems/1.8/gems/passenger-2.0.3/ext/apache2/mod_passenger.so'
50
+ has_directory '/usr/lib/ruby/gems/1.8/gems/passenger-2.0.3'
51
+ end
52
+
53
+ requires :apache
54
+ requires :apache2_prefork_dev
55
+ end