dhill-sprinkle 0.3.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. data/.gitignore +3 -0
  2. data/CREDITS +33 -0
  3. data/Gemfile +4 -0
  4. data/MIT-LICENSE +20 -0
  5. data/README.markdown +242 -0
  6. data/Rakefile +2 -0
  7. data/VERSION +1 -0
  8. data/bin/sprinkle +95 -0
  9. data/examples/packages/build_essential.rb +9 -0
  10. data/examples/packages/databases/mysql.rb +13 -0
  11. data/examples/packages/databases/sqlite3.rb +16 -0
  12. data/examples/packages/phusion.rb +55 -0
  13. data/examples/packages/ruby/rails.rb +9 -0
  14. data/examples/packages/ruby/ruby.rb +17 -0
  15. data/examples/packages/ruby/rubygems.rb +17 -0
  16. data/examples/packages/scm/git.rb +11 -0
  17. data/examples/packages/scm/subversion.rb +4 -0
  18. data/examples/packages/servers/apache.rb +15 -0
  19. data/examples/rails/README +15 -0
  20. data/examples/rails/deploy.rb +2 -0
  21. data/examples/rails/packages/database.rb +9 -0
  22. data/examples/rails/packages/essential.rb +9 -0
  23. data/examples/rails/packages/rails.rb +29 -0
  24. data/examples/rails/packages/scm.rb +11 -0
  25. data/examples/rails/packages/search.rb +11 -0
  26. data/examples/rails/packages/server.rb +28 -0
  27. data/examples/rails/rails.rb +73 -0
  28. data/examples/sprinkle/sprinkle.rb +38 -0
  29. data/lib/sprinkle.rb +3 -0
  30. data/lib/sprinkle/actors/actors.rb +17 -0
  31. data/lib/sprinkle/actors/capistrano.rb +146 -0
  32. data/lib/sprinkle/actors/local.rb +37 -0
  33. data/lib/sprinkle/actors/ssh.rb +177 -0
  34. data/lib/sprinkle/actors/vlad.rb +83 -0
  35. data/lib/sprinkle/configurable.rb +31 -0
  36. data/lib/sprinkle/deployment.rb +73 -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/binary.rb +46 -0
  45. data/lib/sprinkle/installers/bsd_port.rb +33 -0
  46. data/lib/sprinkle/installers/deb.rb +41 -0
  47. data/lib/sprinkle/installers/freebsd_pkg.rb +37 -0
  48. data/lib/sprinkle/installers/freebsd_portinstall.rb +36 -0
  49. data/lib/sprinkle/installers/gem.rb +64 -0
  50. data/lib/sprinkle/installers/install_package.rb +79 -0
  51. data/lib/sprinkle/installers/installer.rb +123 -0
  52. data/lib/sprinkle/installers/mac_port.rb +38 -0
  53. data/lib/sprinkle/installers/noop.rb +20 -0
  54. data/lib/sprinkle/installers/openbsd_pkg.rb +47 -0
  55. data/lib/sprinkle/installers/opensolaris_pkg.rb +43 -0
  56. data/lib/sprinkle/installers/push_text.rb +45 -0
  57. data/lib/sprinkle/installers/rake.rb +37 -0
  58. data/lib/sprinkle/installers/replace_text.rb +45 -0
  59. data/lib/sprinkle/installers/rpm.rb +37 -0
  60. data/lib/sprinkle/installers/runner.rb +18 -0
  61. data/lib/sprinkle/installers/smart.rb +29 -0
  62. data/lib/sprinkle/installers/source.rb +201 -0
  63. data/lib/sprinkle/installers/transfer.rb +178 -0
  64. data/lib/sprinkle/installers/user.rb +15 -0
  65. data/lib/sprinkle/installers/yum.rb +37 -0
  66. data/lib/sprinkle/installers/zypper.rb +43 -0
  67. data/lib/sprinkle/package.rb +326 -0
  68. data/lib/sprinkle/policy.rb +125 -0
  69. data/lib/sprinkle/script.rb +23 -0
  70. data/lib/sprinkle/verifiers/apt.rb +21 -0
  71. data/lib/sprinkle/verifiers/directory.rb +16 -0
  72. data/lib/sprinkle/verifiers/executable.rb +53 -0
  73. data/lib/sprinkle/verifiers/file.rb +34 -0
  74. data/lib/sprinkle/verifiers/package.rb +26 -0
  75. data/lib/sprinkle/verifiers/process.rb +21 -0
  76. data/lib/sprinkle/verifiers/rpm.rb +21 -0
  77. data/lib/sprinkle/verifiers/ruby.rb +25 -0
  78. data/lib/sprinkle/verifiers/symlink.rb +30 -0
  79. data/lib/sprinkle/verify.rb +114 -0
  80. data/lib/sprinkle/version.rb +3 -0
  81. data/script/console +8 -0
  82. data/script/destroy +14 -0
  83. data/script/generate +14 -0
  84. data/spec/spec.opts +1 -0
  85. data/spec/spec_helper.rb +17 -0
  86. data/spec/sprinkle/actors/capistrano_spec.rb +265 -0
  87. data/spec/sprinkle/actors/local_spec.rb +29 -0
  88. data/spec/sprinkle/configurable_spec.rb +46 -0
  89. data/spec/sprinkle/deployment_spec.rb +80 -0
  90. data/spec/sprinkle/extensions/array_spec.rb +19 -0
  91. data/spec/sprinkle/extensions/string_spec.rb +21 -0
  92. data/spec/sprinkle/installers/apt_spec.rb +70 -0
  93. data/spec/sprinkle/installers/bsd_port_spec.rb +42 -0
  94. data/spec/sprinkle/installers/freebsd_pkg_spec.rb +49 -0
  95. data/spec/sprinkle/installers/freebsd_portinstall_spec.rb +42 -0
  96. data/spec/sprinkle/installers/gem_spec.rb +107 -0
  97. data/spec/sprinkle/installers/installer_spec.rb +151 -0
  98. data/spec/sprinkle/installers/mac_port_spec.rb +42 -0
  99. data/spec/sprinkle/installers/noop_spec.rb +23 -0
  100. data/spec/sprinkle/installers/openbsd_pkg_spec.rb +49 -0
  101. data/spec/sprinkle/installers/opensolaris_pkg_spec.rb +49 -0
  102. data/spec/sprinkle/installers/push_text_spec.rb +66 -0
  103. data/spec/sprinkle/installers/rake_spec.rb +29 -0
  104. data/spec/sprinkle/installers/replace_text_spec.rb +45 -0
  105. data/spec/sprinkle/installers/rpm_spec.rb +50 -0
  106. data/spec/sprinkle/installers/runner_spec.rb +31 -0
  107. data/spec/sprinkle/installers/source_spec.rb +371 -0
  108. data/spec/sprinkle/installers/transfer_spec.rb +98 -0
  109. data/spec/sprinkle/installers/yum_spec.rb +49 -0
  110. data/spec/sprinkle/installers/zypper_spec.rb +49 -0
  111. data/spec/sprinkle/package_spec.rb +474 -0
  112. data/spec/sprinkle/policy_spec.rb +126 -0
  113. data/spec/sprinkle/script_spec.rb +51 -0
  114. data/spec/sprinkle/sprinkle_spec.rb +25 -0
  115. data/spec/sprinkle/verify_spec.rb +173 -0
  116. data/sprinkle-0.3.3.1.gem +0 -0
  117. data/sprinkle.gemspec +26 -0
  118. metadata +281 -0
@@ -0,0 +1,3 @@
1
+ .bundle
2
+ Gemfile.lock
3
+ pkg/*
data/CREDITS ADDED
@@ -0,0 +1,33 @@
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 Sprinkle, 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)
22
+ Bodaniel Jeanes (http://bjeanes.github.com)
23
+ Jacob Harris (http://open.nytimes.com)
24
+ Justin Pease (http://jit.nuance9.com)
25
+ Tobias Lütke (http://blog.leetsoft.com)
26
+ Josh Reynolds (http://github.com/jreynolds)
27
+ Jan Ulbrich (http://www.ulbrich.net)
28
+ Chris Gaffney (http://github.com/gaffneyc)
29
+ Maxmpz (http://github.com/maxmpz)
30
+ Geoff Garside (http://geoffgarside.co.uk/)
31
+ Oliver Kiessler (http://inceedo.com)
32
+
33
+ The transfer installer contains a piece of exception reporting code copied from the Chef library (http://wiki.opscode.com/display/chef/Home)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in sprinkle.gemspec
4
+ gemspec
@@ -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.
@@ -0,0 +1,242 @@
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://github.com/trevorturk/sprinkle-packages>
7
+ * <http://www.vimeo.com/2888665>
8
+ * <http://redartisan.lighthouseapp.com/projects/25275-sprinkle/tickets>
9
+
10
+ ## DESCRIPTION:
11
+
12
+ Sprinkle is a software provisioning tool you can use to build remote servers with, after the base operating
13
+ system has been installed. For example, to install a Rails or Merb stack on a brand new slice directly after
14
+ its been created.
15
+
16
+ Properties of packages such as their name, type, dependencies, etc, and what packages apply to what machines
17
+ is described via a domain specific language that Sprinkle executes (in fact one of the aims of Sprinkle is to
18
+ define as concisely as possible a language for installing software).
19
+
20
+ An example package description follows:
21
+
22
+ package :ruby do
23
+ description 'Ruby Virtual Machine'
24
+ version '1.8.6'
25
+ source "ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-#{version}-p111.tar.gz"
26
+ requires :ruby_dependencies
27
+
28
+ verify do
29
+ has_file '/usr/bin/ruby'
30
+ end
31
+ end
32
+
33
+ This defines a package called 'ruby', that uses the source based installer to build Ruby 1.8.6 from source,
34
+ installing the package 'ruby_dependencies' beforehand. Additionally, the package verifies it was installed
35
+ correctly by verifying the file '/usr/bin/ruby' exists after installation. If this verification fails, the
36
+ sprinkle script will gracefully stop.
37
+
38
+ Reasonable defaults are set by sprinkle, such as the install prefix, download area, etc, but can be customized
39
+ globally or per package (see below for an example).
40
+
41
+ Since packages come in many forms (eg. gems, pre-compiled debs, compressed source tar.gz, etc), Sprinkle supports
42
+ many different installer types, giving you the most amount of flexibility of how you'd like software installed.
43
+ New installer types can be added into the system easily.
44
+
45
+ For example, you could install Rails via gems, nginx via source, and mysql via APT, while retaining the flexibility
46
+ of changing installer types as software is updated upstream.
47
+
48
+ Sprinkle also supports dependencies between packages, allowing you specify pre-requisites that need to be
49
+ installed in order.
50
+
51
+ Packages can be grouped into polices to define several packages that should be installed together.
52
+
53
+ An example policy:
54
+
55
+ policy :rails, :roles => :app do
56
+ requires :rails, :version => '2.1.0'
57
+ requires :appserver
58
+ requires :database
59
+ requires :webserver
60
+ end
61
+
62
+ This defines a policy called Rails, that applies to machines of role :app. The policy includes the packages
63
+ rails (version 2.1.0), appserver, database and webserver.
64
+
65
+ appserver, database and webserver can be virtual packages, where the user will be prompted for selection if
66
+ multiple choices for the virtual package exist.
67
+
68
+ Sprinkle is architected to be extendable in many ways, one of those areas is in its deployment of commands to
69
+ remote hosts. Currently Sprinkle supports the use of Capistrano, Vlad, or a direct net/ssh connection to
70
+ issue commands on remote hosts via ssh, but could also be extended to use any other command transport mechanism
71
+ desired. Sprinkle can also be configured to simply issue installation commands to provision the local system.
72
+
73
+ An full example Sprinkle deployment script for deploying Rails (via gems), MySQL (via APT), Apache (via source)
74
+ and Git (via source with dependencies from APT):
75
+
76
+ # Sprinkle Rails deployment script
77
+ #
78
+ # This is an example Sprinkle script, configured to install Rails from gems, Apache, Ruby and Git from source,
79
+ # and mysql and Git dependencies from apt on an Ubuntu system. Installation is configured to run via
80
+ # Capistrano (and an accompanying deploy.rb recipe script). Source based packages are downloaded and built into
81
+ # /usr/local on the remote system.
82
+ #
83
+ # A sprinkle script is separated into 3 different sections. Packages, policies and deployment.
84
+ #
85
+ # Packages
86
+ #
87
+ # Defines the world of packages as we know it. Each package has a name and
88
+ # set of metadata including its installer type (eg. apt, source, gem, etc). Packages can have
89
+ # relationships to each other via dependencies
90
+ #
91
+ # Policies
92
+ #
93
+ # Names a group of packages (optionally with versions) that apply to a particular set of roles.
94
+ #
95
+ # Deployment
96
+ #
97
+ # Defines script wide settings such as a delivery mechanism for executing commands on the target
98
+ # system (eg. capistrano), and installer defaults (eg. build locations, etc).
99
+
100
+ # Packages
101
+
102
+ package :ruby do
103
+ description 'Ruby Virtual Machine'
104
+ version '1.8.6'
105
+ source "ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-#{version}-p111.tar.gz"
106
+ requires :ruby_dependencies
107
+ end
108
+
109
+ package :ruby_dependencies do
110
+ description 'Ruby Virtual Machine Build Dependencies'
111
+ apt %w( bison zlib1g-dev libssl-dev libreadline5-dev libncurses5-dev file )
112
+ end
113
+
114
+ package :mysql, :provides => :database do
115
+ description 'MySQL Database'
116
+ apt %w( mysql-server mysql-client )
117
+ end
118
+
119
+ package :apache, :provides => :webserver do
120
+ description 'Apache 2 HTTP Server'
121
+ version '2.2.9'
122
+ source "http://apache.wildit.net.au/httpd/httpd-#{version}.tar.bz2" do
123
+ enable %w( mods-shared=all proxy proxy-balancer proxy-http rewrite cache headers ssl deflate so )
124
+ prefix "/opt/local/apache2-#{version}"
125
+ post :install, 'install -m 755 support/apachectl /etc/init.d/apache2', 'update-rc.d -f apache2 defaults'
126
+ end
127
+ requires :apache_dependencies
128
+ end
129
+
130
+ package :apache_dependencies do
131
+ description 'Apache 2 HTTP Server Build Dependencies'
132
+ apt %w( openssl libtool mawk zlib1g-dev libssl-dev )
133
+ end
134
+
135
+ package :rubygems do
136
+ description 'Ruby Gems Package Management System'
137
+ version '1.2.0'
138
+ source "http://rubyforge.org/frs/download.php/38646/rubygems-#{version}.tgz" do
139
+ custom_install 'ruby setup.rb'
140
+ end
141
+ requires :ruby
142
+ end
143
+
144
+ package :rails do
145
+ description 'Ruby on Rails'
146
+ gem 'rails'
147
+ version '2.1.0'
148
+ end
149
+
150
+ package :mongrel do
151
+ description 'Mongrel Application Server'
152
+ gem 'mongrel'
153
+ version '1.1.5'
154
+ end
155
+
156
+ package :mongrel_cluster, :provides => :appserver do
157
+ description 'Cluster Management for Mongrel'
158
+ gem 'mongrel_cluster' # :source => 'http://gems.github.com/' for alternate gem server
159
+ version '1.0.5'
160
+ requires :mongrel
161
+ end
162
+
163
+ package :git, :provides => :scm do
164
+ description 'Git Distributed Version Control'
165
+ version '1.5.6.3'
166
+ source "http://kernel.org/pub/software/scm/git/git-#{version}.tar.gz"
167
+ requires :git_dependencies
168
+ end
169
+
170
+ package :git_dependencies do
171
+ description 'Git Build Dependencies'
172
+ apt 'git', :dependencies_only => true
173
+ end
174
+
175
+ # Policies
176
+
177
+ # Associates the rails policy to the application servers. Contains rails, and surrounding
178
+ # packages. Note, appserver, database and webserver are all virtual packages defined above. If
179
+ # there's only one implementation of a virtual package, it's selected automatically, otherwise
180
+ # the user is requested to select which one to use.
181
+
182
+ policy :rails, :roles => :app do
183
+ requires :rails, :version => '2.1.0'
184
+ requires :appserver
185
+ requires :database
186
+ requires :webserver
187
+ requires :scm
188
+ end
189
+
190
+ # Deployment
191
+
192
+ # Configures sprinkle to use capistrano for delivery of commands to the remote machines (via
193
+ # the named 'deploy' recipe). Also configures 'source' installer defaults to put package gear
194
+ # in /usr/local
195
+
196
+ deployment do
197
+
198
+ # mechanism for deployment
199
+ delivery :capistrano do
200
+ recipes 'deploy'
201
+ end
202
+
203
+ # source based package installer defaults
204
+ source do
205
+ prefix '/usr/local' # where all source packages will be configured to install
206
+ archives '/usr/local/sources' # where all source packages will be downloaded to
207
+ builds '/usr/local/build' # where all source packages will be built
208
+ end
209
+
210
+ end
211
+
212
+ 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).
213
+
214
+ Sprinkle is a work in progress and I'm excited to hear if anyone finds it useful - please feel free to
215
+ comment, ask any questions, or send in any ideas, patches, bugs. All most welcome.
216
+
217
+ Marcus Crafter <crafterm@redartisan.com>
218
+
219
+ ## LICENSE:
220
+
221
+ (The MIT License)
222
+
223
+ Copyright (c) 2008-2009 Marcus Crafter <crafterm@redartisan.com>
224
+
225
+ Permission is hereby granted, free of charge, to any person obtaining
226
+ a copy of this software and associated documentation files (the
227
+ 'Software'), to deal in the Software without restriction, including
228
+ without limitation the rights to use, copy, modify, merge, publish,
229
+ distribute, sublicense, and/or sell copies of the Software, and to
230
+ permit persons to whom the Software is furnished to do so, subject to
231
+ the following conditions:
232
+
233
+ The above copyright notice and this permission notice shall be
234
+ included in all copies or substantial portions of the Software.
235
+
236
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
237
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
238
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
239
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
240
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
241
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
242
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.3.1
@@ -0,0 +1,95 @@
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
+ ARGV.each do |arg|
20
+ ENV[$1] = $2 if arg =~ /^(\w+)=(.*)$/
21
+ end
22
+
23
+ parser = OptionParser.new do |opts|
24
+ opts.banner = <<BANNER
25
+ Sprinkle
26
+ ========
27
+
28
+ http://github.com/crafterm/sprinkle
29
+
30
+ Sprinkle is a software provisioning tool you can use to build remote servers with. eg. to
31
+ install a Rails or Merb stack on a brand new slice directly after its been created. It uses
32
+ a Ruby based domain specific language to describe packages and policies to determine what
33
+ should be installed on particular systems.
34
+
35
+ Please see http://github.com/crafterm/sprinkle/tree/master/README.txt for more information.
36
+
37
+ Usage
38
+ =====
39
+
40
+ $> #{File.basename($0)} [options]
41
+
42
+ Options are:
43
+ BANNER
44
+ opts.separator ""
45
+ opts.on("-s", "--script=PATH", String,
46
+ "Path to a sprinkle script to run") { |v| OPTIONS[:path] = v }
47
+ opts.on("-t", "--test",
48
+ "Process but don't perform any actions") { |v| OPTIONS[:testing] = v }
49
+ opts.on("-v", "--verbose",
50
+ "Verbose output") { |v| OPTIONS[:verbose] = v }
51
+ opts.on("-c", "--cloud",
52
+ "Show powder cloud, ie. package hierarchy and installation order") { |v| OPTIONS[:cloud] = v }
53
+ opts.on("-f", "--force",
54
+ "Force installation of all packages even if it is detected that it has been previously installed") { |v| OPTIONS[:force] = v }
55
+ opts.on("-h", "--help",
56
+ "Show this help message.") { puts opts; exit }
57
+ opts.parse!(ARGV)
58
+
59
+ if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| OPTIONS[option.to_sym].nil? }
60
+ puts opts; exit
61
+ end
62
+ end
63
+
64
+ def force_mode(options)
65
+ Sprinkle::OPTIONS[:force] = OPTIONS[:force] || false
66
+ end
67
+
68
+ def operation_mode(options)
69
+ Sprinkle::OPTIONS[:testing] = OPTIONS[:testing] || false
70
+ end
71
+
72
+ def powder_cloud(options)
73
+ Sprinkle::OPTIONS[:cloud] = OPTIONS[:cloud] || false
74
+ end
75
+
76
+ def verbosity(options)
77
+ Sprinkle::OPTIONS[:verbose] = OPTIONS[:verbose] || false
78
+ end
79
+
80
+ def log_level(options)
81
+ Object.logger.level = ActiveSupport::BufferedLogger::Severity::DEBUG if options[:verbose]
82
+ end
83
+
84
+ require File.dirname(__FILE__) + '/../lib/sprinkle'
85
+
86
+ powder = OPTIONS[:path]
87
+ raise "Sprinkle script is not readable: #{powder}" unless File.readable?(powder)
88
+
89
+ force_mode(OPTIONS)
90
+ operation_mode(OPTIONS)
91
+ powder_cloud(OPTIONS)
92
+ log_level(OPTIONS)
93
+ verbosity(OPTIONS)
94
+
95
+ Sprinkle::Script.sprinkle File.read(powder), powder
@@ -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