jsierles-sprinkle 0.1.9

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 (89) hide show
  1. data/CREDITS +19 -0
  2. data/History.txt +4 -0
  3. data/MIT-LICENSE +20 -0
  4. data/Manifest.txt +87 -0
  5. data/README.txt +238 -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.rb +32 -0
  31. data/lib/sprinkle/actors/actors.rb +17 -0
  32. data/lib/sprinkle/actors/capistrano.rb +117 -0
  33. data/lib/sprinkle/actors/local.rb +26 -0
  34. data/lib/sprinkle/actors/ssh.rb +81 -0
  35. data/lib/sprinkle/actors/vlad.rb +65 -0
  36. data/lib/sprinkle/configurable.rb +31 -0
  37. data/lib/sprinkle/deployment.rb +73 -0
  38. data/lib/sprinkle/extensions/arbitrary_options.rb +10 -0
  39. data/lib/sprinkle/extensions/array.rb +5 -0
  40. data/lib/sprinkle/extensions/blank_slate.rb +5 -0
  41. data/lib/sprinkle/extensions/dsl_accessor.rb +15 -0
  42. data/lib/sprinkle/extensions/string.rb +10 -0
  43. data/lib/sprinkle/extensions/symbol.rb +7 -0
  44. data/lib/sprinkle/installers/apt.rb +52 -0
  45. data/lib/sprinkle/installers/deb.rb +38 -0
  46. data/lib/sprinkle/installers/gem.rb +62 -0
  47. data/lib/sprinkle/installers/installer.rb +120 -0
  48. data/lib/sprinkle/installers/rake.rb +37 -0
  49. data/lib/sprinkle/installers/rpm.rb +37 -0
  50. data/lib/sprinkle/installers/source.rb +179 -0
  51. data/lib/sprinkle/installers/yum.rb +37 -0
  52. data/lib/sprinkle/package.rb +233 -0
  53. data/lib/sprinkle/policy.rb +125 -0
  54. data/lib/sprinkle/script.rb +23 -0
  55. data/lib/sprinkle/verifiers/directory.rb +16 -0
  56. data/lib/sprinkle/verifiers/executable.rb +36 -0
  57. data/lib/sprinkle/verifiers/file.rb +20 -0
  58. data/lib/sprinkle/verifiers/process.rb +21 -0
  59. data/lib/sprinkle/verifiers/ruby.rb +25 -0
  60. data/lib/sprinkle/verifiers/symlink.rb +30 -0
  61. data/lib/sprinkle/verify.rb +114 -0
  62. data/lib/sprinkle/version.rb +9 -0
  63. data/script/destroy +14 -0
  64. data/script/generate +14 -0
  65. data/spec/spec.opts +1 -0
  66. data/spec/spec_helper.rb +17 -0
  67. data/spec/sprinkle/actors/capistrano_spec.rb +170 -0
  68. data/spec/sprinkle/actors/local_spec.rb +29 -0
  69. data/spec/sprinkle/configurable_spec.rb +46 -0
  70. data/spec/sprinkle/deployment_spec.rb +80 -0
  71. data/spec/sprinkle/extensions/array_spec.rb +19 -0
  72. data/spec/sprinkle/extensions/string_spec.rb +21 -0
  73. data/spec/sprinkle/installers/apt_spec.rb +70 -0
  74. data/spec/sprinkle/installers/gem_spec.rb +75 -0
  75. data/spec/sprinkle/installers/installer_spec.rb +151 -0
  76. data/spec/sprinkle/installers/rake_spec.rb +29 -0
  77. data/spec/sprinkle/installers/rpm_spec.rb +50 -0
  78. data/spec/sprinkle/installers/source_spec.rb +331 -0
  79. data/spec/sprinkle/installers/yum_spec.rb +49 -0
  80. data/spec/sprinkle/package_spec.rb +422 -0
  81. data/spec/sprinkle/policy_spec.rb +126 -0
  82. data/spec/sprinkle/script_spec.rb +51 -0
  83. data/spec/sprinkle/sprinkle_spec.rb +25 -0
  84. data/spec/sprinkle/verify_spec.rb +160 -0
  85. data/sprinkle.gemspec +70 -0
  86. data/tasks/deployment.rake +34 -0
  87. data/tasks/environment.rake +7 -0
  88. data/tasks/rspec.rake +21 -0
  89. metadata +180 -0
data/CREDITS ADDED
@@ -0,0 +1,19 @@
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)
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,87 @@
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/deb.rb
46
+ lib/sprinkle/installers/gem.rb
47
+ lib/sprinkle/installers/installer.rb
48
+ lib/sprinkle/installers/rake.rb
49
+ lib/sprinkle/installers/rpm.rb
50
+ lib/sprinkle/installers/source.rb
51
+ lib/sprinkle/installers/yum.rb
52
+ lib/sprinkle/package.rb
53
+ lib/sprinkle/policy.rb
54
+ lib/sprinkle/script.rb
55
+ lib/sprinkle/verifiers/directory.rb
56
+ lib/sprinkle/verifiers/executable.rb
57
+ lib/sprinkle/verifiers/file.rb
58
+ lib/sprinkle/verifiers/process.rb
59
+ lib/sprinkle/verifiers/ruby.rb
60
+ lib/sprinkle/verifiers/symlink.rb
61
+ lib/sprinkle/verify.rb
62
+ lib/sprinkle/version.rb
63
+ script/destroy
64
+ script/generate
65
+ spec/spec.opts
66
+ spec/spec_helper.rb
67
+ spec/sprinkle/actors/capistrano_spec.rb
68
+ spec/sprinkle/actors/local_spec.rb
69
+ spec/sprinkle/configurable_spec.rb
70
+ spec/sprinkle/deployment_spec.rb
71
+ spec/sprinkle/extensions/array_spec.rb
72
+ spec/sprinkle/extensions/string_spec.rb
73
+ spec/sprinkle/installers/apt_spec.rb
74
+ spec/sprinkle/installers/gem_spec.rb
75
+ spec/sprinkle/installers/installer_spec.rb
76
+ spec/sprinkle/installers/rpm_spec.rb
77
+ spec/sprinkle/installers/yum_spec.rb
78
+ spec/sprinkle/installers/source_spec.rb
79
+ spec/sprinkle/package_spec.rb
80
+ spec/sprinkle/policy_spec.rb
81
+ spec/sprinkle/script_spec.rb
82
+ spec/sprinkle/sprinkle_spec.rb
83
+ spec/sprinkle/verify_spec.rb
84
+ sprinkle.gemspec
85
+ tasks/deployment.rake
86
+ tasks/environment.rake
87
+ tasks/rspec.rake
data/README.txt ADDED
@@ -0,0 +1,238 @@
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
+
24
+ verify do
25
+ has_file '/usr/bin/ruby'
26
+ end
27
+ end
28
+
29
+ This defines a package called 'ruby', that uses the source based installer to build Ruby 1.8.6 from source,
30
+ installing the package 'ruby_dependencies' beforehand. Additionally, the package verifies it was installed
31
+ correctly by verifying the file '/usr/bin/ruby' exists after installation. If this verification fails, the
32
+ sprinkle script will gracefully stop.
33
+
34
+ Reasonable defaults are set by sprinkle, such as the install prefix, download area, etc, but can be customized
35
+ globally or per package (see below for an example).
36
+
37
+ Since packages come in many forms (eg. gems, pre-compiled debs, compressed source tar.gz, etc), Sprinkle supports
38
+ many different installer types, giving you the most amount of flexibility of how you'd like software installed.
39
+ New installer types can be added into the system easily.
40
+
41
+ For example, you could install Rails via gems, nginx via source, and mysql via APT, while retaining the flexibility
42
+ of changing installer types as software is updated upstream.
43
+
44
+ Sprinkle also supports dependencies between packages, allowing you specify pre-requisites that need to be
45
+ installed in order.
46
+
47
+ Packages can be grouped into polices to define several packages that should be installed together.
48
+
49
+ An example policy:
50
+
51
+ policy :rails, :roles => :app do
52
+ requires :rails, :version => '2.1.0'
53
+ requires :appserver
54
+ requires :database
55
+ requires :webserver
56
+ end
57
+
58
+ This defines a policy called Rails, that applies to machines of role :app. The policy includes the packages
59
+ rails (version 2.1.0), appserver, database and webserver.
60
+
61
+ appserver, database and webserver can be virtual packages, where the user will be prompted for selection if
62
+ multiple choices for the virtual package exist.
63
+
64
+ Sprinkle is architected to be extendable in many ways, one of those areas is in its deployment of commands to
65
+ remote hosts. Currently Sprinkle supports the use of Capistrano, Vlad, or a direct net/ssh connection to
66
+ issue commands on remote hosts via ssh, but could also be extended to use any other command transport mechanism
67
+ desired. Sprinkle can also be configured to simply issue installation commands to provision the local system.
68
+
69
+ An full example Sprinkle deployment script for deploying Rails (via gems), MySQL (via APT), Apache (via source)
70
+ and Git (via source with dependencies from APT):
71
+
72
+ # Sprinkle Rails deployment script
73
+ #
74
+ # This is an example Sprinkle script, configured to install Rails from gems, Apache, Ruby and Git from source,
75
+ # and mysql and Git dependencies from apt on an Ubuntu system. Installation is configured to run via
76
+ # Capistrano (and an accompanying deploy.rb recipe script). Source based packages are downloaded and built into
77
+ # /usr/local on the remote system.
78
+ #
79
+ # A sprinkle script is separated into 3 different sections. Packages, policies and deployment.
80
+ #
81
+ # Packages
82
+ #
83
+ # Defines the world of packages as we know it. Each package has a name and
84
+ # set of metadata including its installer type (eg. apt, source, gem, etc). Packages can have
85
+ # relationships to each other via dependencies
86
+ #
87
+ # Policies
88
+ #
89
+ # Names a group of packages (optionally with versions) that apply to a particular set of roles.
90
+ #
91
+ # Deployment
92
+ #
93
+ # Defines script wide settings such as a delivery mechanism for executing commands on the target
94
+ # system (eg. capistrano), and installer defaults (eg. build locations, etc).
95
+
96
+ # Packages
97
+
98
+ package :ruby do
99
+ description 'Ruby Virtual Machine'
100
+ version '1.8.6'
101
+ source "ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-#{version}-p111.tar.gz"
102
+ requires :ruby_dependencies
103
+ end
104
+
105
+ package :ruby_dependencies do
106
+ description 'Ruby Virtual Machine Build Dependencies'
107
+ apt %w( bison zlib1g-dev libssl-dev libreadline5-dev libncurses5-dev file )
108
+ end
109
+
110
+ package :mysql, :provides => :database do
111
+ description 'MySQL Database'
112
+ apt %w( mysql-server mysql-client )
113
+ end
114
+
115
+ package :apache, :provides => :webserver do
116
+ description 'Apache 2 HTTP Server'
117
+ version '2.2.9'
118
+ source "http://apache.wildit.net.au/httpd/httpd-#{version}.tar.bz2" do
119
+ enable %w( mods-shared=all proxy proxy-balancer proxy-http rewrite cache headers ssl deflate so )
120
+ prefix "/opt/local/apache2-#{version}"
121
+ post :install, 'install -m 755 support/apachectl /etc/init.d/apache2', 'update-rc.d -f apache2 defaults'
122
+ end
123
+ requires :apache_dependencies
124
+ end
125
+
126
+ package :apache_dependencies do
127
+ description 'Apache 2 HTTP Server Build Dependencies'
128
+ apt %w( openssl libtool mawk zlib1g-dev libssl-dev )
129
+ end
130
+
131
+ package :rubygems do
132
+ description 'Ruby Gems Package Management System'
133
+ version '1.2.0'
134
+ source "http://rubyforge.org/frs/download.php/38646/rubygems-#{version}.tgz" do
135
+ custom_install 'ruby setup.rb'
136
+ end
137
+ requires :ruby
138
+ end
139
+
140
+ package :rails do
141
+ description 'Ruby on Rails'
142
+ gem 'rails'
143
+ version '2.1.0'
144
+ end
145
+
146
+ package :mongrel do
147
+ description 'Mongrel Application Server'
148
+ gem 'mongrel'
149
+ version '1.1.5'
150
+ end
151
+
152
+ package :mongrel_cluster, :provides => :appserver do
153
+ description 'Cluster Management for Mongrel'
154
+ gem 'mongrel_cluster' # :source => 'http://gems.github.com/' for alternate gem server
155
+ version '1.0.5'
156
+ requires :mongrel
157
+ end
158
+
159
+ package :git, :provides => :scm do
160
+ description 'Git Distributed Version Control'
161
+ version '1.5.6.3'
162
+ source "http://kernel.org/pub/software/scm/git/git-#{version}.tar.gz"
163
+ requires :git_dependencies
164
+ end
165
+
166
+ package :git_dependencies do
167
+ description 'Git Build Dependencies'
168
+ apt 'git', :dependencies_only => true
169
+ end
170
+
171
+ # Policies
172
+
173
+ # Associates the rails policy to the application servers. Contains rails, and surrounding
174
+ # packages. Note, appserver, database and webserver are all virtual packages defined above. If
175
+ # there's only one implementation of a virtual package, it's selected automatically, otherwise
176
+ # the user is requested to select which one to use.
177
+
178
+ policy :rails, :roles => :app do
179
+ requires :rails, :version => '2.1.0'
180
+ requires :appserver
181
+ requires :database
182
+ requires :webserver
183
+ requires :scm
184
+ end
185
+
186
+ # Deployment
187
+
188
+ # Configures sprinkle to use capistrano for delivery of commands to the remote machines (via
189
+ # the named 'deploy' recipe). Also configures 'source' installer defaults to put package gear
190
+ # in /usr/local
191
+
192
+ deployment do
193
+
194
+ # mechanism for deployment
195
+ delivery :capistrano do
196
+ recipes 'deploy'
197
+ end
198
+
199
+ # source based package installer defaults
200
+ source do
201
+ prefix '/usr/local' # where all source packages will be configured to install
202
+ archives '/usr/local/sources' # where all source packages will be downloaded to
203
+ builds '/usr/local/build' # where all source packages will be built
204
+ end
205
+
206
+ end
207
+
208
+ Please see the examples directory for more complete examples of Sprinkle deployment scripts.
209
+
210
+ Sprinkle is a work in progress and I'm excited to hear if anyone finds it useful - please feel free to
211
+ comment, ask any questions, or send in any ideas, patches, bugs. All most welcome.
212
+
213
+ Marcus Crafter <crafterm@redartisan.com>
214
+
215
+ == LICENSE:
216
+
217
+ (The MIT License)
218
+
219
+ Copyright (c) 2008 Marcus Crafter <crafterm@redartisan.com>
220
+
221
+ Permission is hereby granted, free of charge, to any person obtaining
222
+ a copy of this software and associated documentation files (the
223
+ 'Software'), to deal in the Software without restriction, including
224
+ without limitation the rights to use, copy, modify, merge, publish,
225
+ distribute, sublicense, and/or sell copies of the Software, and to
226
+ permit persons to whom the Software is furnished to do so, subject to
227
+ the following conditions:
228
+
229
+ The above copyright notice and this permission notice shall be
230
+ included in all copies or substantial portions of the Software.
231
+
232
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
233
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
234
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
235
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
236
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
237
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
238
+ 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