sprinkle 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/CREDITS CHANGED
@@ -3,15 +3,17 @@
3
3
  Many thanks to the following people who have submitted ideas, patches, helped with testing
4
4
  and/or generally provided support to Sprinke, I really appreciate your help:
5
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)
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/Manifest.txt CHANGED
@@ -7,11 +7,22 @@ Rakefile
7
7
  bin/sprinkle
8
8
  config/hoe.rb
9
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
10
20
  examples/rails/README
11
21
  examples/rails/deploy.rb
12
22
  examples/rails/packages/database.rb
13
23
  examples/rails/packages/essential.rb
14
24
  examples/rails/packages/rails.rb
25
+ examples/rails/packages/scm.rb
15
26
  examples/rails/packages/search.rb
16
27
  examples/rails/packages/server.rb
17
28
  examples/rails/rails.rb
@@ -19,6 +30,8 @@ examples/sprinkle/sprinkle.rb
19
30
  lib/sprinkle.rb
20
31
  lib/sprinkle/actors/actors.rb
21
32
  lib/sprinkle/actors/capistrano.rb
33
+ lib/sprinkle/actors/local.rb
34
+ lib/sprinkle/actors/ssh.rb
22
35
  lib/sprinkle/actors/vlad.rb
23
36
  lib/sprinkle/configurable.rb
24
37
  lib/sprinkle/deployment.rb
@@ -29,11 +42,13 @@ lib/sprinkle/extensions/dsl_accessor.rb
29
42
  lib/sprinkle/extensions/string.rb
30
43
  lib/sprinkle/extensions/symbol.rb
31
44
  lib/sprinkle/installers/apt.rb
45
+ lib/sprinkle/installers/deb.rb
32
46
  lib/sprinkle/installers/gem.rb
33
47
  lib/sprinkle/installers/installer.rb
34
48
  lib/sprinkle/installers/rake.rb
35
49
  lib/sprinkle/installers/rpm.rb
36
50
  lib/sprinkle/installers/source.rb
51
+ lib/sprinkle/installers/yum.rb
37
52
  lib/sprinkle/package.rb
38
53
  lib/sprinkle/policy.rb
39
54
  lib/sprinkle/script.rb
@@ -50,6 +65,8 @@ script/generate
50
65
  spec/spec.opts
51
66
  spec/spec_helper.rb
52
67
  spec/sprinkle/actors/capistrano_spec.rb
68
+ spec/sprinkle/actors/local_spec.rb
69
+ spec/sprinkle/configurable_spec.rb
53
70
  spec/sprinkle/deployment_spec.rb
54
71
  spec/sprinkle/extensions/array_spec.rb
55
72
  spec/sprinkle/extensions/string_spec.rb
@@ -57,6 +74,7 @@ spec/sprinkle/installers/apt_spec.rb
57
74
  spec/sprinkle/installers/gem_spec.rb
58
75
  spec/sprinkle/installers/installer_spec.rb
59
76
  spec/sprinkle/installers/rpm_spec.rb
77
+ spec/sprinkle/installers/yum_spec.rb
60
78
  spec/sprinkle/installers/source_spec.rb
61
79
  spec/sprinkle/package_spec.rb
62
80
  spec/sprinkle/policy_spec.rb
data/README.txt CHANGED
@@ -62,17 +62,18 @@ appserver, database and webserver can be virtual packages, where the user will b
62
62
  multiple choices for the virtual package exist.
63
63
 
64
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 or Vlad to issue commands on remote hosts via ssh,
66
- but could also be extended to use any other command transport mechanism or be used to simply issue installation
67
- commands on the local system.
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
68
 
69
- An full example Sprinkle deployment script for deploying Rails (via gems), MySQL (via APT), and Apache (via source):
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):
70
71
 
71
72
  # Sprinkle Rails deployment script
72
73
  #
73
- # This is an example Sprinkle script, configured to install Rails from gems, Apache and Ruby from source,
74
- # and mysql from apt on an Ubuntu system. Installation is configured to run via Capistrano (and
75
- # an accompanying deploy.rb recipe script). Source based packages are downloaded and built into
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
76
77
  # /usr/local on the remote system.
77
78
  #
78
79
  # A sprinkle script is separated into 3 different sections. Packages, policies and deployment.
@@ -154,6 +155,18 @@ An full example Sprinkle deployment script for deploying Rails (via gems), MySQL
154
155
  version '1.0.5'
155
156
  requires :mongrel
156
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
157
170
 
158
171
  # Policies
159
172
 
@@ -167,6 +180,7 @@ An full example Sprinkle deployment script for deploying Rails (via gems), MySQL
167
180
  requires :appserver
168
181
  requires :database
169
182
  requires :webserver
183
+ requires :scm
170
184
  end
171
185
 
172
186
  # Deployment
@@ -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'
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
@@ -0,0 +1,9 @@
1
+ package :rails do
2
+ description 'Ruby on Rails'
3
+ gem 'rails'
4
+ version '2.1.0'
5
+
6
+ verify do
7
+ has_executable 'rails'
8
+ end
9
+ end
@@ -0,0 +1,17 @@
1
+ package :ruby do
2
+ description 'Ruby Virtual Machine'
3
+ version '1.8.6'
4
+ apt %q(ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby) do
5
+ post :install, [%q(ln -s /usr/bin/ruby1.8 /usr/bin/ruby),
6
+ %q(ln -s /usr/bin/ri1.8 /usr/bin/ri),
7
+ %q(ln -s /usr/bin/rdoc1.8 /usr/bin/rdoc),
8
+ %q(ln -s /usr/bin/irb1.8 /usr/bin/irb)]
9
+ end
10
+
11
+ verify 'binaries' do
12
+ has_file '/usr/bin/ruby1.8'
13
+ has_file '/usr/bin/ri1.8'
14
+ has_file '/usr/bin/rdoc1.8'
15
+ has_file '/usr/bin/irb1.8'
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ package :rubygems do
2
+ description 'Ruby Gems Package Management System'
3
+ version '1.2.0'
4
+ source "http://rubyforge.org/frs/download.php/38646/rubygems-#{version}.tgz" do
5
+ custom_install 'ruby setup.rb'
6
+ post :install, 'ln -s /usr/bin/gem1.8 /usr/bin/gem'
7
+ post :install, 'gem update'
8
+ post :install, 'gem update --system'
9
+ end
10
+
11
+ verify 'binary' do
12
+ has_file '/usr/bin/gem1.8'
13
+ has_symlink '/usr/bin/gem', '/usr/bin/gem1.8'
14
+ end
15
+
16
+ requires :ruby
17
+ end
@@ -0,0 +1,11 @@
1
+ package :git, :provides => :scm do
2
+ description 'Git Distributed Version Control'
3
+ version '1.5.6.3'
4
+ source "http://kernel.org/pub/software/scm/git/git-#{version}.tar.gz"
5
+ requires :git_dependencies
6
+ end
7
+
8
+ package :git_dependencies do
9
+ description 'Git Build Dependencies'
10
+ apt 'git', :dependencies_only => true
11
+ end
@@ -0,0 +1,4 @@
1
+ package :subversion, :provides => :scm do
2
+ description 'Subversion Version Control'
3
+ apt 'subversion'
4
+ end
@@ -0,0 +1,15 @@
1
+ package :apache, :provides => :webserver do
2
+ description 'Apache2 web server.'
3
+ apt 'apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert' do
4
+ post :install, 'a2enmod rewrite'
5
+ end
6
+
7
+ verify do
8
+ has_process 'apache2'
9
+ end
10
+ end
11
+
12
+ package :apache2_prefork_dev do
13
+ description 'A dependency required by some packages.'
14
+ apt 'apache2-prefork-dev'
15
+ end
@@ -2,5 +2,8 @@
2
2
 
3
3
  package :build_essential do
4
4
  description 'Build tools'
5
- apt 'build-essential'
5
+ apt 'build-essential' do
6
+ # Update the sources and upgrade the lists before we build essentials
7
+ pre :install, 'apt-get update'
8
+ end
6
9
  end
@@ -0,0 +1,11 @@
1
+ package :git, :provides => :scm do
2
+ description 'Git Distributed Version Control'
3
+ version '1.5.6.3'
4
+ source "http://kernel.org/pub/software/scm/git/git-#{version}.tar.gz"
5
+ requires :git_dependencies
6
+ end
7
+
8
+ package :git_dependencies do
9
+ description 'Git Build Dependencies'
10
+ apt 'git', :dependencies_only => true
11
+ end
@@ -2,8 +2,8 @@
2
2
 
3
3
  # Annotated Example Sprinkle Rails deployment script
4
4
  #
5
- # This is an example Sprinkle script configured to install Rails from gems, Apache, Ruby and
6
- # Sphinx from source, and mysql from apt on an Ubuntu system.
5
+ # This is an example Sprinkle script configured to install Rails from gems, Apache, Ruby,
6
+ # Sphinx and Git from source, and mysql and Git dependencies from apt on an Ubuntu system.
7
7
  #
8
8
  # Installation is configured to run via capistrano (and an accompanying deploy.rb recipe script).
9
9
  # Source based packages are downloaded and built into /usr/local on the remote system.
@@ -22,6 +22,7 @@ require 'packages/rails'
22
22
  require 'packages/database'
23
23
  require 'packages/server'
24
24
  require 'packages/search'
25
+ require 'packages/scm'
25
26
 
26
27
 
27
28
  # Policies
@@ -39,6 +40,7 @@ policy :rails, :roles => :app do
39
40
  requires :database
40
41
  requires :webserver
41
42
  requires :search
43
+ requires :scm
42
44
  end
43
45
 
44
46
 
data/lib/sprinkle.rb CHANGED
@@ -2,11 +2,11 @@ require 'rubygems'
2
2
  require 'active_support'
3
3
 
4
4
  # Use active supports auto load mechanism
5
- Dependencies.load_paths << File.dirname(__FILE__)
5
+ ActiveSupport::Dependencies.load_paths << File.dirname(__FILE__)
6
6
 
7
7
  # Configure active support to log auto-loading of dependencies
8
- #Dependencies::RAILS_DEFAULT_LOGGER = Logger.new($stdout)
9
- #Dependencies.log_activity = true
8
+ #ActiveSupport::Dependencies::RAILS_DEFAULT_LOGGER = Logger.new($stdout)
9
+ #ActiveSupport::Dependencies.log_activity = true
10
10
 
11
11
  # Load up extensions to existing classes
12
12
  Dir[File.dirname(__FILE__) + '/sprinkle/extensions/*.rb'].each { |e| require e }
@@ -0,0 +1,26 @@
1
+ module Sprinkle
2
+ module Actors
3
+ # = Local Delivery Method
4
+ #
5
+ # This actor implementation performs any given commands on your local system, as
6
+ # opposed to other implementations that generally run commands on a remote system
7
+ # via the network.
8
+ #
9
+ # This is useful if you'd like to use Sprinkle to provision your local machine.
10
+ # To enable this actor, in your Sprinkle script specify the :local delivery mechanism.
11
+ #
12
+ # deployment do
13
+ # delivery :local
14
+ # end
15
+ #
16
+ # Note, your local machine will be assumed to be a member of all roles when applying policies
17
+ #
18
+ class Local
19
+
20
+ def process(name, commands, roles, suppress_and_return_failures = false) #:nodoc:
21
+ commands.each { |command| system command }
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,81 @@
1
+ require 'net/ssh/gateway'
2
+
3
+ module Sprinkle
4
+ module Actors
5
+ class Ssh
6
+ attr_accessor :options
7
+
8
+ def initialize(options = {}, &block) #:nodoc:
9
+ @options = options.update(:user => 'root')
10
+ self.instance_eval &block if block
11
+ end
12
+
13
+ def roles(roles)
14
+ @options[:roles] = roles
15
+ end
16
+
17
+ def gateway(gateway)
18
+ @options[:gateway] = gateway
19
+ end
20
+
21
+ def user(user)
22
+ @options[:user] = user
23
+ end
24
+
25
+ def process(name, commands, roles, suppress_and_return_failures = false)
26
+ return process_with_gateway(name, commands, roles) if gateway_defined?
27
+ process_direct(name, commands, roles)
28
+ end
29
+
30
+ protected
31
+
32
+ def process_with_gateway(name, commands, roles)
33
+ on_gateway do |gateway|
34
+ Array(roles).each { |role| execute_on_role(commands, role, gateway) }
35
+ end
36
+ end
37
+
38
+ def process_direct(name, commands, roles)
39
+ Array(roles).each { |role| execute_on_role(commands, role) }
40
+ end
41
+
42
+ def execute_on_role(commands, role, gateway = nil)
43
+ hosts = @options[:roles][role]
44
+ Array(hosts).each { |host| execute_on_host(commands, host, gateway) }
45
+ end
46
+
47
+ def execute_on_host(commands, host, gateway = nil)
48
+ if gateway # SSH connection via gateway
49
+ gateway.ssh(host, @options[:user]) do |ssh|
50
+ execute_on_connection(commands, ssh)
51
+ end
52
+ else # direct SSH connection
53
+ Net::SSH.start(host, @options[:user]) do |ssh|
54
+ execute_on_connection(commands, ssh)
55
+ end
56
+ end
57
+ end
58
+
59
+ def execute_on_connection(commands, connection)
60
+ Array(commands).each do |command|
61
+ connection.exec! command do |ch, stream, data|
62
+ logger.send((stream == :stderr ? 'error' : 'debug'), data)
63
+ end
64
+ end
65
+ end
66
+
67
+ private
68
+
69
+ def gateway_defined?
70
+ !! @options[:gateway]
71
+ end
72
+
73
+ def on_gateway(&block)
74
+ gateway = Net::SSH::Gateway.new(@options[:gateway], @options[:user])
75
+ block.call gateway
76
+ ensure
77
+ gateway.shutdown!
78
+ end
79
+ end
80
+ end
81
+ end
@@ -30,20 +30,21 @@ module Sprinkle
30
30
  attr_accessor :packages #:nodoc:
31
31
 
32
32
  def initialize(parent, *packages, &block) #:nodoc:
33
- super parent, &block
34
33
  packages.flatten!
35
34
 
36
35
  options = { :dependencies_only => false }
37
36
  options.update(packages.pop) if packages.last.is_a?(Hash)
38
37
 
39
- @command = options[:dependencies_only] ? 'build-dep' : 'install'
38
+ super parent, options, &block
39
+
40
40
  @packages = packages
41
41
  end
42
42
 
43
43
  protected
44
44
 
45
45
  def install_commands #:nodoc:
46
- "DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get -qyu #{@command} #{@packages.join(' ')}"
46
+ command = @options[:dependencies_only] ? 'build-dep' : 'install'
47
+ "DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get -qyu #{command} #{@packages.join(' ')}"
47
48
  end
48
49
 
49
50
  end
@@ -0,0 +1,32 @@
1
+ module Sprinkle
2
+ module Installers
3
+ # = Deb Package Installer
4
+ #
5
+ # The Deb installer installs deb packages sourced from a remote URL
6
+ #
7
+ # == Example Usage
8
+ #
9
+ # Installing the magic_beans deb.
10
+ #
11
+ # package :magic_beans do
12
+ # deb 'http://debs.example.com/magic_beans.deb'
13
+ # end
14
+ #
15
+ class Deb < Installer
16
+ attr_accessor :packages #:nodoc:
17
+
18
+ def initialize(parent, packages, &block) #:nodoc:
19
+ super parent, &block
20
+ packages = [packages] unless packages.is_a? Array
21
+ @packages = packages
22
+ end
23
+
24
+ protected
25
+
26
+ def install_commands #:nodoc:
27
+ "wget -cq --directory-prefix=/tmp #{@packages.join(' ')}; dpkg -i #{@packages.collect{|p| "/tmp/#{p}"}.join(" ")}"
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,37 @@
1
+ module Sprinkle
2
+ module Installers
3
+ # = Yum Package Installer
4
+ #
5
+ # The Yum package installer installs RPM packages.
6
+ #
7
+ # == Example Usage
8
+ #
9
+ # Installing the magic_beans RPM via Yum. Its all the craze these days.
10
+ #
11
+ # package :magic_beans do
12
+ # yum 'magic_beans'
13
+ # end
14
+ #
15
+ # You may also specify multiple rpms as an array:
16
+ #
17
+ # package :magic_beans do
18
+ # yum %w(magic_beans magic_sauce)
19
+ # end
20
+ class Yum < Installer
21
+ attr_accessor :packages #:nodoc:
22
+
23
+ def initialize(parent, packages, &block) #:nodoc:
24
+ super parent, &block
25
+ packages = [packages] unless packages.is_a? Array
26
+ @packages = packages
27
+ end
28
+
29
+ protected
30
+
31
+ def install_commands #:nodoc:
32
+ "yum #{@packages.join(' ')} -y"
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -165,6 +165,8 @@ module Sprinkle
165
165
  end
166
166
 
167
167
  def process_verifications(deployment, roles, pre = false)
168
+ return if @verifications.blank?
169
+
168
170
  if pre
169
171
  logger.info "--> Checking if #{self.name} is already installed for roles: #{roles}"
170
172
  else
@@ -2,7 +2,7 @@ module Sprinkle #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 6
5
+ TINY = 7
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -0,0 +1,29 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Sprinkle::Actors::Local do
4
+
5
+ before do
6
+ @local = Sprinkle::Actors::Local.new
7
+ end
8
+
9
+ describe 'when processing commands' do
10
+
11
+ before do
12
+ @commands = %w( op1 op2 )
13
+ @roles = %w( app )
14
+ @name = 'name'
15
+
16
+ @local.stub!(:system).and_return
17
+ end
18
+
19
+ it 'should run the commands on the local system' do
20
+ @local.should_receive(:system).twice.and_return
21
+ end
22
+
23
+ after do
24
+ @local.process @name, @commands, @roles
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,46 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Sprinkle::Configurable do
4
+ module MyPrefix
5
+ class Configurable
6
+ include Sprinkle::Configurable
7
+ end
8
+ end
9
+
10
+ before do
11
+ @configurable = MyPrefix::Configurable.new
12
+ @default = Proc.new { }
13
+ @defaults = { :configurable => @default }
14
+ @deployment.stub!(:defaults).and_return(@defaults)
15
+ @deployment.stub!(:style)
16
+ end
17
+
18
+ it 'should be configurable via external defaults' do
19
+ @configurable.should respond_to(:defaults)
20
+ end
21
+
22
+ it 'should select the defaults for the particular concrete installer class' do
23
+ @deployment.should_receive(:defaults).and_return(@defaults)
24
+ @defaults.should_receive(:[]).with(:configurable).and_return(@default)
25
+ end
26
+
27
+ it 'should configure the installer delivery mechansim' do
28
+ @configurable.should_receive(:instance_eval)
29
+ end
30
+
31
+ it 'should maintain an options hash set arbitrarily via method missing' do
32
+ @configurable.instance_eval do
33
+ hsv 'gts'
34
+ end
35
+ @configurable.hsv.should == 'gts'
36
+ end
37
+
38
+ it 'should allow the delivery instance variable to be accessed' do
39
+ @configurable.delivery = "string"
40
+ @configurable.instance_variable_get(:@delivery).should eql("string")
41
+ end
42
+
43
+ after do
44
+ @configurable.defaults(@deployment)
45
+ end
46
+ end
@@ -22,10 +22,6 @@ describe Sprinkle::Installers::Apt do
22
22
  @installer.packages.should == ['gcc', 'gdb', 'g++']
23
23
  end
24
24
 
25
- end
26
-
27
- describe 'when created for dependencies only install' do
28
-
29
25
  it 'should remove options from packages list' do
30
26
  @installer = create_apt 'ruby', :dependencies_only => true
31
27
  @installer.packages.should == [ 'ruby' ]
@@ -62,7 +58,7 @@ describe Sprinkle::Installers::Apt do
62
58
  describe 'during dependencies only installation' do
63
59
 
64
60
  before do
65
- @installer = create_apt 'ruby', :dependencies_only => true
61
+ @installer = create_apt('ruby') { dependencies_only true }
66
62
  @install_commands = @installer.send :install_commands
67
63
  end
68
64
 
@@ -0,0 +1,49 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Sprinkle::Installers::Yum do
4
+
5
+ before do
6
+ @package = mock(Sprinkle::Package, :name => 'package')
7
+ end
8
+
9
+ def create_rpm(rpms, &block)
10
+ Sprinkle::Installers::Yum.new(@package, rpms, &block)
11
+ end
12
+
13
+ describe 'when created' do
14
+
15
+ it 'should accept a single package to install' do
16
+ @installer = create_rpm 'ruby'
17
+ @installer.packages.should == [ 'ruby' ]
18
+ end
19
+
20
+ it 'should accept an array of packages to install' do
21
+ @installer = create_rpm %w( gcc gdb g++ )
22
+ @installer.packages.should == ['gcc', 'gdb', 'g++']
23
+ end
24
+
25
+ end
26
+
27
+ describe 'during installation' do
28
+
29
+ before do
30
+ @installer = create_rpm 'ruby' do
31
+ pre :install, 'op1'
32
+ post :install, 'op2'
33
+ end
34
+ @install_commands = @installer.send :install_commands
35
+ end
36
+
37
+ it 'should invoke the rpm installer for all specified packages' do
38
+ @install_commands.should =~ /yum ruby -y/
39
+ end
40
+
41
+ it 'should automatically insert pre/post commands for the specified package' do
42
+ @installer.send(:install_sequence).should == [ 'op1', 'yum ruby -y', 'op2' ]
43
+ end
44
+
45
+ it 'should install a specific version if defined'
46
+
47
+ end
48
+
49
+ end
data/sprinkle.gemspec CHANGED
@@ -1,16 +1,16 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{sprinkle}
3
- s.version = "0.1.6"
3
+ s.version = "0.1.7"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Marcus Crafter", "Mitchell Hashimoto"]
7
- s.date = %q{2008-07-19}
7
+ s.date = %q{2008-11-04}
8
8
  s.default_executable = %q{sprinkle}
9
9
  s.description = %q{Ruby DSL based software provisioning tool}
10
10
  s.email = ["crafterm@redartisan.com", "mitchell.hashimoto@citrusbyte.com"]
11
11
  s.executables = ["sprinkle"]
12
12
  s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
13
- s.files = ["CREDITS", "History.txt", "MIT-LICENSE", "Manifest.txt", "README.txt", "Rakefile", "bin/sprinkle", "config/hoe.rb", "config/requirements.rb", "examples/rails/README", "examples/rails/deploy.rb", "examples/rails/packages/database.rb", "examples/rails/packages/essential.rb", "examples/rails/packages/rails.rb", "examples/rails/packages/search.rb", "examples/rails/packages/server.rb", "examples/rails/rails.rb", "examples/sprinkle/sprinkle.rb", "lib/sprinkle.rb", "lib/sprinkle/actors/actors.rb", "lib/sprinkle/actors/capistrano.rb", "lib/sprinkle/actors/vlad.rb", "lib/sprinkle/configurable.rb", "lib/sprinkle/deployment.rb", "lib/sprinkle/extensions/arbitrary_options.rb", "lib/sprinkle/extensions/array.rb", "lib/sprinkle/extensions/blank_slate.rb", "lib/sprinkle/extensions/dsl_accessor.rb", "lib/sprinkle/extensions/string.rb", "lib/sprinkle/extensions/symbol.rb", "lib/sprinkle/installers/apt.rb", "lib/sprinkle/installers/gem.rb", "lib/sprinkle/installers/installer.rb", "lib/sprinkle/installers/rake.rb", "lib/sprinkle/installers/rpm.rb", "lib/sprinkle/installers/source.rb", "lib/sprinkle/package.rb", "lib/sprinkle/policy.rb", "lib/sprinkle/script.rb", "lib/sprinkle/verifiers/directory.rb", "lib/sprinkle/verifiers/executable.rb", "lib/sprinkle/verifiers/file.rb", "lib/sprinkle/verifiers/process.rb", "lib/sprinkle/verifiers/ruby.rb", "lib/sprinkle/verifiers/symlink.rb", "lib/sprinkle/verify.rb", "lib/sprinkle/version.rb", "script/destroy", "script/generate", "spec/spec.opts", "spec/spec_helper.rb", "spec/sprinkle/actors/capistrano_spec.rb", "spec/sprinkle/configurable_spec.rb", "spec/sprinkle/deployment_spec.rb", "spec/sprinkle/extensions/array_spec.rb", "spec/sprinkle/extensions/string_spec.rb", "spec/sprinkle/installers/apt_spec.rb", "spec/sprinkle/installers/gem_spec.rb", "spec/sprinkle/installers/installer_spec.rb", "spec/sprinkle/installers/rpm_spec.rb", "spec/sprinkle/installers/source_spec.rb", "spec/sprinkle/package_spec.rb", "spec/sprinkle/policy_spec.rb", "spec/sprinkle/script_spec.rb", "spec/sprinkle/sprinkle_spec.rb", "spec/sprinkle/verify_spec.rb", "sprinkle.gemspec", "tasks/deployment.rake", "tasks/environment.rake", "tasks/rspec.rake"]
13
+ s.files = ["CREDITS", "History.txt", "MIT-LICENSE", "Manifest.txt", "README.txt", "Rakefile", "bin/sprinkle", "config/hoe.rb", "config/requirements.rb", "examples/packages/build_essential.rb", "examples/packages/databases/mysql.rb", "examples/packages/databases/sqlite3.rb", "examples/packages/phusion.rb", "examples/packages/ruby/rails.rb", "examples/packages/ruby/ruby.rb", "examples/packages/ruby/rubygems.rb", "examples/packages/scm/git.rb", "examples/packages/scm/subversion.rb", "examples/packages/servers/apache.rb", "examples/rails/README", "examples/rails/deploy.rb", "examples/rails/packages/database.rb", "examples/rails/packages/essential.rb", "examples/rails/packages/rails.rb", "examples/rails/packages/scm.rb", "examples/rails/packages/search.rb", "examples/rails/packages/server.rb", "examples/rails/rails.rb", "examples/sprinkle/sprinkle.rb", "lib/sprinkle.rb", "lib/sprinkle/actors/actors.rb", "lib/sprinkle/actors/capistrano.rb", "lib/sprinkle/actors/local.rb", "lib/sprinkle/actors/ssh.rb", "lib/sprinkle/actors/vlad.rb", "lib/sprinkle/configurable.rb", "lib/sprinkle/deployment.rb", "lib/sprinkle/extensions/arbitrary_options.rb", "lib/sprinkle/extensions/array.rb", "lib/sprinkle/extensions/blank_slate.rb", "lib/sprinkle/extensions/dsl_accessor.rb", "lib/sprinkle/extensions/string.rb", "lib/sprinkle/extensions/symbol.rb", "lib/sprinkle/installers/apt.rb", "lib/sprinkle/installers/deb.rb", "lib/sprinkle/installers/gem.rb", "lib/sprinkle/installers/installer.rb", "lib/sprinkle/installers/rake.rb", "lib/sprinkle/installers/rpm.rb", "lib/sprinkle/installers/source.rb", "lib/sprinkle/installers/yum.rb", "lib/sprinkle/package.rb", "lib/sprinkle/policy.rb", "lib/sprinkle/script.rb", "lib/sprinkle/verifiers/directory.rb", "lib/sprinkle/verifiers/executable.rb", "lib/sprinkle/verifiers/file.rb", "lib/sprinkle/verifiers/process.rb", "lib/sprinkle/verifiers/ruby.rb", "lib/sprinkle/verifiers/symlink.rb", "lib/sprinkle/verify.rb", "lib/sprinkle/version.rb", "script/destroy", "script/generate", "spec/spec.opts", "spec/spec_helper.rb", "spec/sprinkle/actors/capistrano_spec.rb", "spec/sprinkle/actors/local_spec.rb", "spec/sprinkle/configurable_spec.rb", "spec/sprinkle/deployment_spec.rb", "spec/sprinkle/extensions/array_spec.rb", "spec/sprinkle/extensions/string_spec.rb", "spec/sprinkle/installers/apt_spec.rb", "spec/sprinkle/installers/gem_spec.rb", "spec/sprinkle/installers/installer_spec.rb", "spec/sprinkle/installers/rpm_spec.rb", "spec/sprinkle/installers/yum_spec.rb", "spec/sprinkle/installers/source_spec.rb", "spec/sprinkle/package_spec.rb", "spec/sprinkle/policy_spec.rb", "spec/sprinkle/script_spec.rb", "spec/sprinkle/sprinkle_spec.rb", "spec/sprinkle/verify_spec.rb", "sprinkle.gemspec", "tasks/deployment.rake", "tasks/environment.rake", "tasks/rspec.rake"]
14
14
  s.has_rdoc = true
15
15
  s.homepage = %q{http://sprinkle.rubyforge.org}
16
16
  s.rdoc_options = ["--main", "README.txt"]
@@ -27,17 +27,17 @@ Gem::Specification.new do |s|
27
27
  s.add_runtime_dependency(%q<activesupport>, [">= 2.0.2"])
28
28
  s.add_runtime_dependency(%q<highline>, [">= 1.4.0"])
29
29
  s.add_runtime_dependency(%q<capistrano>, [">= 2.2.0"])
30
- s.add_development_dependency(%q<hoe>, [">= 1.7.0"])
30
+ s.add_development_dependency(%q<hoe>, [">= 1.8.2"])
31
31
  else
32
32
  s.add_dependency(%q<activesupport>, [">= 2.0.2"])
33
33
  s.add_dependency(%q<highline>, [">= 1.4.0"])
34
34
  s.add_dependency(%q<capistrano>, [">= 2.2.0"])
35
- s.add_dependency(%q<hoe>, [">= 1.7.0"])
35
+ s.add_dependency(%q<hoe>, [">= 1.8.2"])
36
36
  end
37
37
  else
38
38
  s.add_dependency(%q<activesupport>, [">= 2.0.2"])
39
39
  s.add_dependency(%q<highline>, [">= 1.4.0"])
40
40
  s.add_dependency(%q<capistrano>, [">= 2.2.0"])
41
- s.add_dependency(%q<hoe>, [">= 1.7.0"])
41
+ s.add_dependency(%q<hoe>, [">= 1.8.2"])
42
42
  end
43
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprinkle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Crafter
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-21 00:00:00 +10:00
12
+ date: 2008-11-04 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 1.7.0
53
+ version: 1.8.2
54
54
  version:
55
55
  description: Ruby DSL based software provisioning tool
56
56
  email:
@@ -73,11 +73,22 @@ files:
73
73
  - bin/sprinkle
74
74
  - config/hoe.rb
75
75
  - config/requirements.rb
76
+ - examples/packages/build_essential.rb
77
+ - examples/packages/databases/mysql.rb
78
+ - examples/packages/databases/sqlite3.rb
79
+ - examples/packages/phusion.rb
80
+ - examples/packages/ruby/rails.rb
81
+ - examples/packages/ruby/ruby.rb
82
+ - examples/packages/ruby/rubygems.rb
83
+ - examples/packages/scm/git.rb
84
+ - examples/packages/scm/subversion.rb
85
+ - examples/packages/servers/apache.rb
76
86
  - examples/rails/README
77
87
  - examples/rails/deploy.rb
78
88
  - examples/rails/packages/database.rb
79
89
  - examples/rails/packages/essential.rb
80
90
  - examples/rails/packages/rails.rb
91
+ - examples/rails/packages/scm.rb
81
92
  - examples/rails/packages/search.rb
82
93
  - examples/rails/packages/server.rb
83
94
  - examples/rails/rails.rb
@@ -85,6 +96,8 @@ files:
85
96
  - lib/sprinkle.rb
86
97
  - lib/sprinkle/actors/actors.rb
87
98
  - lib/sprinkle/actors/capistrano.rb
99
+ - lib/sprinkle/actors/local.rb
100
+ - lib/sprinkle/actors/ssh.rb
88
101
  - lib/sprinkle/actors/vlad.rb
89
102
  - lib/sprinkle/configurable.rb
90
103
  - lib/sprinkle/deployment.rb
@@ -95,11 +108,13 @@ files:
95
108
  - lib/sprinkle/extensions/string.rb
96
109
  - lib/sprinkle/extensions/symbol.rb
97
110
  - lib/sprinkle/installers/apt.rb
111
+ - lib/sprinkle/installers/deb.rb
98
112
  - lib/sprinkle/installers/gem.rb
99
113
  - lib/sprinkle/installers/installer.rb
100
114
  - lib/sprinkle/installers/rake.rb
101
115
  - lib/sprinkle/installers/rpm.rb
102
116
  - lib/sprinkle/installers/source.rb
117
+ - lib/sprinkle/installers/yum.rb
103
118
  - lib/sprinkle/package.rb
104
119
  - lib/sprinkle/policy.rb
105
120
  - lib/sprinkle/script.rb
@@ -116,6 +131,8 @@ files:
116
131
  - spec/spec.opts
117
132
  - spec/spec_helper.rb
118
133
  - spec/sprinkle/actors/capistrano_spec.rb
134
+ - spec/sprinkle/actors/local_spec.rb
135
+ - spec/sprinkle/configurable_spec.rb
119
136
  - spec/sprinkle/deployment_spec.rb
120
137
  - spec/sprinkle/extensions/array_spec.rb
121
138
  - spec/sprinkle/extensions/string_spec.rb
@@ -123,6 +140,7 @@ files:
123
140
  - spec/sprinkle/installers/gem_spec.rb
124
141
  - spec/sprinkle/installers/installer_spec.rb
125
142
  - spec/sprinkle/installers/rpm_spec.rb
143
+ - spec/sprinkle/installers/yum_spec.rb
126
144
  - spec/sprinkle/installers/source_spec.rb
127
145
  - spec/sprinkle/package_spec.rb
128
146
  - spec/sprinkle/policy_spec.rb