sprinkle 0.7.1.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/.tm_properties +7 -0
  2. data/CHANGELOG.md +8 -0
  3. data/Gemfile +3 -0
  4. data/Gemfile.lock +46 -4
  5. data/Rakefile +38 -1
  6. data/examples/rails/packages/database.rb +7 -0
  7. data/examples/rails/templates/mysql.cnf.erb +3 -0
  8. data/lib/sprinkle.rb +8 -13
  9. data/lib/sprinkle/actors/actor.rb +17 -17
  10. data/lib/sprinkle/actors/capistrano.rb +3 -3
  11. data/lib/sprinkle/actors/local.rb +10 -6
  12. data/lib/sprinkle/actors/ssh.rb +8 -8
  13. data/lib/sprinkle/actors/vlad.rb +7 -7
  14. data/lib/sprinkle/core.rb +16 -0
  15. data/lib/sprinkle/deployment.rb +8 -6
  16. data/lib/sprinkle/errors/pretty_failure.rb +1 -1
  17. data/lib/sprinkle/errors/template_error.rb +1 -1
  18. data/lib/sprinkle/installers/brew.rb +0 -2
  19. data/lib/sprinkle/installers/deb.rb +6 -2
  20. data/lib/sprinkle/installers/file.rb +38 -39
  21. data/lib/sprinkle/installers/freebsd_pkg.rb +4 -0
  22. data/lib/sprinkle/installers/group.rb +11 -12
  23. data/lib/sprinkle/installers/install_package.rb +5 -5
  24. data/lib/sprinkle/installers/openbsd_pkg.rb +5 -1
  25. data/lib/sprinkle/installers/opensolaris_pkg.rb +5 -1
  26. data/lib/sprinkle/installers/package_installer.rb +7 -3
  27. data/lib/sprinkle/installers/pacman.rb +4 -0
  28. data/lib/sprinkle/installers/push_text.rb +1 -1
  29. data/lib/sprinkle/installers/rake.rb +14 -6
  30. data/lib/sprinkle/installers/rpm.rb +5 -0
  31. data/lib/sprinkle/installers/runner.rb +3 -2
  32. data/lib/sprinkle/installers/thor.rb +14 -15
  33. data/lib/sprinkle/installers/transfer.rb +0 -1
  34. data/lib/sprinkle/installers/user.rb +2 -2
  35. data/lib/sprinkle/installers/yum.rb +9 -8
  36. data/lib/sprinkle/installers/zypper.rb +5 -1
  37. data/lib/sprinkle/package.rb +31 -8
  38. data/lib/sprinkle/package/chooser.rb +1 -1
  39. data/lib/sprinkle/package/package_repository.rb +1 -1
  40. data/lib/sprinkle/package/rendering.rb +13 -10
  41. data/lib/sprinkle/policy.rb +71 -74
  42. data/lib/sprinkle/script.rb +2 -2
  43. data/lib/sprinkle/utility/log_recorder.rb +1 -1
  44. data/lib/sprinkle/verifiers/file.rb +17 -1
  45. data/lib/sprinkle/verifiers/package.rb +2 -2
  46. data/lib/sprinkle/verify.rb +2 -2
  47. data/lib/sprinkle/version.rb +1 -1
  48. data/spec/sprinkle/deployment_spec.rb +5 -3
  49. data/spec/sprinkle/extensions/rendering_spec.rb +29 -14
  50. data/spec/sprinkle/installers/file_spec.rb +1 -1
  51. data/spec/sprinkle/installers/installer_spec.rb +1 -1
  52. data/spec/sprinkle/installers/opensolaris_pkg_spec.rb +0 -4
  53. data/spec/sprinkle/installers/transfer_spec.rb +1 -1
  54. data/spec/sprinkle/package_spec.rb +31 -0
  55. data/spec/sprinkle/policy_spec.rb +5 -5
  56. data/spec/sprinkle/verify_spec.rb +0 -7
  57. data/spec/templates/locals.erb +1 -0
  58. data/spec/templates/test.erb +1 -0
  59. data/templates/test.erb +1 -0
  60. metadata +10 -4
  61. data/lib/sprinkle/verifiers/directory.rb +0 -16
  62. data/lib/sprinkle/verifiers/symlink.rb +0 -30
data/.tm_properties ADDED
@@ -0,0 +1,7 @@
1
+ projectDirectory = "$CWD"
2
+
3
+ stockFiles = "{Gemfile.lock,test.rb}"
4
+
5
+ excludeDirectories = "{rdoc,work}"
6
+ # excludeInFolderSearch = "${excludeDirectories}"
7
+ excludeFiles = "{*.gem,$stockFiles}"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ * Default package options (see Package docs)
2
+
3
+ *Koen Punt*
4
+
5
+ * Add the file installer so we can stop doing templates with `transfer`
6
+
7
+ *Josh Goebel*
8
+
1
9
  * Officially depreciate transfer :render and the ability to render just by passing
2
10
  a multi-line string as the transfer source. If you want to render templates see the
3
11
  new `render()` and `template()` (rendering.rb) helpers and the `file` installer.
data/Gemfile CHANGED
@@ -5,6 +5,9 @@ source "https://rubygems.org"
5
5
  gemspec
6
6
 
7
7
  group :development do
8
+ gem 'railties'
9
+ gem 'rdoc', "3.10"
10
+ gem 'sdoc'
8
11
  gem 'pry'
9
12
  gem 'pry_debug'
10
13
  gem 'pry-rescue'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sprinkle (0.7)
4
+ sprinkle (0.7.1.1)
5
5
  activesupport (>= 2.0.2)
6
6
  capistrano (>= 2.5.5)
7
7
  erubis (>= 2.7.0)
@@ -11,9 +11,23 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
+ actionpack (3.2.13)
15
+ activemodel (= 3.2.13)
16
+ activesupport (= 3.2.13)
17
+ builder (~> 3.0.0)
18
+ erubis (~> 2.7.0)
19
+ journey (~> 1.0.4)
20
+ rack (~> 1.4.5)
21
+ rack-cache (~> 1.2)
22
+ rack-test (~> 0.6.1)
23
+ sprockets (~> 2.2.1)
24
+ activemodel (3.2.13)
25
+ activesupport (= 3.2.13)
26
+ builder (~> 3.0.0)
14
27
  activesupport (3.2.13)
15
28
  i18n (= 0.6.1)
16
29
  multi_json (~> 1.0)
30
+ builder (3.0.4)
17
31
  capistrano (2.15.4)
18
32
  highline
19
33
  net-scp (>= 1.0.0)
@@ -24,8 +38,10 @@ GEM
24
38
  diff-lcs (1.2.4)
25
39
  erubis (2.7.0)
26
40
  highline (1.6.19)
41
+ hike (1.2.3)
27
42
  i18n (0.6.1)
28
43
  interception (0.3)
44
+ journey (1.0.4)
29
45
  json (1.8.0)
30
46
  method_source (0.8.1)
31
47
  multi_json (1.7.7)
@@ -46,8 +62,22 @@ GEM
46
62
  pry
47
63
  pry_debug (0.1.0)
48
64
  pry (~> 0.9.0)
49
- rake (10.0.4)
50
- rdoc (4.0.1)
65
+ rack (1.4.5)
66
+ rack-cache (1.2)
67
+ rack (>= 0.4)
68
+ rack-ssl (1.3.3)
69
+ rack
70
+ rack-test (0.6.2)
71
+ rack (>= 1.0)
72
+ railties (3.2.13)
73
+ actionpack (= 3.2.13)
74
+ activesupport (= 3.2.13)
75
+ rack-ssl (~> 1.3.2)
76
+ rake (>= 0.8.7)
77
+ rdoc (~> 3.4)
78
+ thor (>= 0.14.6, < 2.0)
79
+ rake (10.1.0)
80
+ rdoc (3.10)
51
81
  json (~> 1.4)
52
82
  rspec (2.13.0)
53
83
  rspec-core (~> 2.13.0)
@@ -57,7 +87,17 @@ GEM
57
87
  rspec-expectations (2.13.0)
58
88
  diff-lcs (>= 1.1.3, < 2.0)
59
89
  rspec-mocks (2.13.1)
90
+ sdoc (0.3.20)
91
+ json (>= 1.1.3)
92
+ rdoc (~> 3.10)
60
93
  slop (3.4.5)
94
+ sprockets (2.2.2)
95
+ hike (~> 1.2)
96
+ multi_json (~> 1.0)
97
+ rack (~> 1.0)
98
+ tilt (~> 1.1, != 1.3.0)
99
+ thor (0.18.1)
100
+ tilt (1.4.1)
61
101
 
62
102
  PLATFORMS
63
103
  ruby
@@ -66,7 +106,9 @@ DEPENDENCIES
66
106
  pry
67
107
  pry-rescue
68
108
  pry_debug
109
+ railties
69
110
  rake (>= 0.8.7)
70
- rdoc (>= 3.12)
111
+ rdoc (= 3.10)
71
112
  rspec (>= 2.5)
113
+ sdoc
72
114
  sprinkle!
data/Rakefile CHANGED
@@ -1,6 +1,9 @@
1
1
  require 'rubygems'
2
+ require 'bundler/setup'
3
+
2
4
  require 'rake'
3
5
  require 'rspec/core/rake_task'
6
+ require 'sdoc'
4
7
  require 'rdoc/task'
5
8
  require './lib/sprinkle/version'
6
9
 
@@ -24,11 +27,45 @@ RSpec::Core::RakeTask.new(:coverage) do |t|
24
27
  t.rcov_opts = ['--exclude', 'spec']
25
28
  end
26
29
 
30
+ class RDoc::Comment
31
+ def gsub(*args)
32
+ @text.gsub(*args)
33
+ end
34
+ end
35
+
27
36
  RDoc::Task.new do |rdoc|
28
37
  version = Sprinkle::Version
29
-
38
+
39
+ rdoc.options << '-e' << 'UTF-8'
40
+ rdoc.options << '-f' << 'sdoc'
41
+ # rdoc.options << "-T" << "rails"
42
+
30
43
  rdoc.rdoc_dir = 'rdoc'
31
44
  rdoc.title = "sprinkle #{version}"
32
45
  rdoc.rdoc_files.include('README*')
33
46
  rdoc.rdoc_files.include('lib/**/*.rb')
34
47
  end
48
+
49
+ STATS_DIRECTORIES = [
50
+ %w(Library lib/sprinkle/),
51
+ %w(Specs spec),
52
+ ].collect { |name, dir| [ name, "./#{dir}" ] }.select { |name, dir| File.directory?(dir) }
53
+ BROKEN = [
54
+ %w(Actors lib/sprinkle/actors),
55
+ # %w(Errors lib/sprinkle/errors),
56
+ # %w(Extensions lib/sprinkle/extensions),
57
+ %w(Installers lib/sprinkle/installers),
58
+ # %w(Utility lib/sprinkle/utility),
59
+ %w(Package lib/sprinkle/package),
60
+ %w(Verifiers lib/sprinkle/verifiers),
61
+ ].collect { |name, dir| [ name, "./#{dir}" ] }.select { |name, dir| File.directory?(dir) }
62
+
63
+ desc "Report code statistics (KLOCs, etc) from the application"
64
+ task :stats do
65
+ require 'rails/code_statistics'
66
+ CodeStatistics::TEST_TYPES << "Specs"
67
+ cs=CodeStatistics.new(*BROKEN)
68
+ cs.instance_variable_set("@total",nil)
69
+ cs.to_s
70
+ CodeStatistics.new(*STATS_DIRECTORIES).to_s
71
+ end
@@ -1,6 +1,13 @@
1
1
  package :mysql, :provides => :database do
2
2
  description 'MySQL Database'
3
3
 
4
+ defaults :innodb_file_per_table => true,
5
+ :innodb_buffer_pool_size => "512MB"
6
+
7
+ file "/etc/my.cnf",
8
+ :contents => render("mysql.cnf"),
9
+ :sudo => true
10
+
4
11
  apt %w( mysql-server mysql-client )
5
12
  end
6
13
 
@@ -0,0 +1,3 @@
1
+ [mysqld]
2
+ <%= "innodb_file_per_table" if opts[:innodb_file_per_table] %>
3
+ innodb_buffer_pool_size = <%= opts[:innodb_buffer_pool_size] %>
data/lib/sprinkle.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'active_support/all'
3
3
 
4
- # Use active supports auto load mechanism
5
- require 'active_support/version'
6
4
  if ActiveSupport::VERSION::MAJOR > 2
7
5
  require 'active_support/dependencies'
8
6
  ActiveSupport::Dependencies.autoload_paths << File.dirname(__FILE__)
@@ -14,27 +12,24 @@ end
14
12
  #ActiveSupport::Dependencies::RAILS_DEFAULT_LOGGER = Logger.new($stdout)
15
13
  #ActiveSupport::Dependencies.log_activity = true
16
14
 
17
- require File.dirname(__FILE__) + "/sprinkle/version.rb"
15
+ def require_all(*args) # :nodoc:
16
+ args.each { |f|
17
+ Dir[File.dirname(__FILE__) + "/sprinkle/#{f}"].each { |e| require e } }
18
+ end
18
19
 
19
- # Load up extensions to existing classes
20
- Dir[File.dirname(__FILE__) + '/sprinkle/extensions/*.rb'].each { |e| require e }
21
- # Load up the verifiers so they can register themselves
22
- Dir[File.dirname(__FILE__) + '/sprinkle/verifiers/*.rb'].each { |e| require e }
23
- # Load up the installers so they can register themselves
24
- Dir[File.dirname(__FILE__) + '/sprinkle/installers/*.rb'].each { |e| require e }
20
+ require_all "version.rb", "extensions/*.rb", "verifiers/*.rb", "installers/*.rb"
25
21
 
26
- # Configuration options
27
22
  module Sprinkle
23
+ # Configuration options
28
24
  OPTIONS = { :testing => false, :verbose => false, :force => false }
29
25
  end
30
26
 
31
- # Object is extended to Add the package and policy methods. To read about
32
- # each method, see the corresponding module which is included.
27
+ # Object is extended with a few helper methods. Please see Sprinkle::Core.
33
28
  #--
34
29
  # Define a logging target and understand packages, policies and deployment DSL
35
30
  #++
36
31
  class Object
37
- include Sprinkle::Package, Sprinkle::Policy
32
+ include Sprinkle::Package, Sprinkle::Core
38
33
 
39
34
  def logger # :nodoc:
40
35
  # ActiveSupport::BufferedLogger was deprecated and replaced by ActiveSupport::Logger in Rails 4.
@@ -1,22 +1,22 @@
1
1
  module Sprinkle
2
+ # = Actors
3
+ #
4
+ # An actor is a method of command delivery to a remote machine. Actors are the
5
+ # layer setting between Sprinkle and the systems you and wanting to apply
6
+ # policies to.
7
+ #
8
+ # Sprinkle ships with actors for Capistrano, Vlad, localhost and pure SSH.
2
9
  module Actors
3
- # An actor is a method of command delivery to a remote machine. Actors are the
4
- # layer setting between Sprinkle and the systems you and wanting to apply
5
- # policies to. All actors should inherit from Sprinkle::Actors::Actor.
6
- #
7
- # Sprinkle ships with actors for Capistrano, Vlad, localhost and pure SSH.
8
- # 99% of the time these should be sufficient but you can always write your
9
- # own actor otherwise.
10
- #
11
10
  # == Writing an actor
12
11
  #
13
- # Actors must provide only 3 methods:
12
+ # All actors should inherit from Sprinkle::Actors::Actor. Actors must provide the
13
+ # following methods:
14
14
  #
15
- # * install (installer, roles, options)
16
- # * verify (verifier, roles, options)
17
- # * servers_for_role? (roles)
18
- # * sudo?
19
- # * sudo_command
15
+ # * #install (installer, roles, options)
16
+ # * #verify (verifier, roles, options)
17
+ # * #servers_for_role? (roles)
18
+ # * #sudo?
19
+ # * #sudo_command
20
20
  #
21
21
  # Hopefully these methods are kind of fairly obvious. They should return true
22
22
  # to indicate success and false to indicate failure.
@@ -29,11 +29,11 @@ module Sprinkle
29
29
  # whether it should execute or not
30
30
  #
31
31
  # input: a single role or array of roles
32
- def servers_for_role?(r)
32
+ def servers_for_role?(role)
33
33
  raise "please define servers_for_role?"
34
34
  end
35
35
 
36
- def install(*args)
36
+ def install(installer, roles, options)
37
37
  raise "you must define install"
38
38
  end
39
39
 
@@ -50,7 +50,7 @@ module Sprinkle
50
50
  raise "you must define sudo_command"
51
51
  end
52
52
 
53
- def verify(*args)
53
+ def verify(verifier, roles, options)
54
54
  raise "you must define verify"
55
55
  end
56
56
 
@@ -38,16 +38,16 @@ module Sprinkle
38
38
  end
39
39
  end
40
40
 
41
- def sudo?
41
+ def sudo? #:nodoc:
42
42
  @config.fetch(:run_method, :run) == :sudo
43
43
  end
44
44
 
45
- def sudo_command
45
+ def sudo_command #:nodoc:
46
46
  @config.sudo
47
47
  end
48
48
 
49
49
  # Determines if there are any servers for the given roles
50
- def servers_for_role?(roles)
50
+ def servers_for_role?(roles) #:nodoc:
51
51
  roles=Array(roles)
52
52
  roles.any? { |r| @config.roles.keys.include?(r) }
53
53
  end
@@ -18,14 +18,18 @@ module Sprinkle
18
18
  # local system was a member of all roles defined.
19
19
  class Local < Actor
20
20
 
21
- class LocalCommandError < StandardError; end
22
21
 
23
- def servers_for_role?(role)
22
+ class LocalCommandError < StandardError #:nodoc:
23
+ end
24
+
25
+ def servers_for_role?(role) #:nodoc:
24
26
  true
25
27
  end
26
28
 
27
- def sudo?; false; end
28
- def sudo_command; nil; end
29
+ def sudo? #:nodoc:;
30
+ false; end
31
+ def sudo_command #:nodoc:;
32
+ nil; end
29
33
 
30
34
  def install(installer, roles, opts = {}) #:nodoc:
31
35
  # all local installer cares about is the commands
@@ -62,7 +66,7 @@ module Sprinkle
62
66
  return true
63
67
  end
64
68
 
65
- def run_command(cmd)
69
+ def run_command(cmd) #:nodoc:
66
70
  @log_recorder.reset cmd
67
71
  pid, stdin, out, err = Open4.popen4(cmd)
68
72
  ignored, status = Process::waitpid2 pid
@@ -71,7 +75,7 @@ module Sprinkle
71
75
  @log_recorder.code = status.to_i
72
76
  end
73
77
 
74
- def raise_error(e)
78
+ def raise_error(e) #:nodoc:
75
79
  raise Sprinkle::Errors::RemoteCommandFailure.new(@installer, @log_recorder.hash, e)
76
80
  end
77
81
 
@@ -44,7 +44,7 @@ module Sprinkle
44
44
  attr_accessor :details
45
45
  end
46
46
 
47
- class SSHConnectionCache
47
+ class SSHConnectionCache #:nodoc:
48
48
  def initialize; @cache={}; end
49
49
  def start(host, user, opts={})
50
50
  key="#{host}#{user}#{opts.to_s}"
@@ -64,12 +64,12 @@ module Sprinkle
64
64
  # Define a whole host of roles at once
65
65
  #
66
66
  # This is depreciated - you should be using role instead.
67
- def roles(roles)
67
+ def roles(roles) #:nodoc:
68
68
  @roles = roles
69
69
  end
70
70
 
71
71
  # Determines if there are any servers for the given roles
72
- def servers_for_role?(roles)
72
+ def servers_for_role?(roles) #:nodoc:
73
73
  roles=Array(roles)
74
74
  roles.any? { |r| @roles.keys.include? (r) }
75
75
  end
@@ -108,11 +108,11 @@ module Sprinkle
108
108
  @options[:use_sudo] = value
109
109
  end
110
110
 
111
- def sudo?
111
+ def sudo? #:nodoc:
112
112
  @options[:use_sudo]
113
113
  end
114
114
 
115
- def sudo_command
115
+ def sudo_command #:nodoc:
116
116
  "sudo"
117
117
  end
118
118
 
@@ -146,7 +146,7 @@ module Sprinkle
146
146
 
147
147
  protected
148
148
 
149
- def raise_error(e)
149
+ def raise_error(e) #:nodoc:
150
150
  raise Sprinkle::Errors::RemoteCommandFailure.new(@installer, e.details, e)
151
151
  end
152
152
 
@@ -165,7 +165,7 @@ module Sprinkle
165
165
  end
166
166
  end
167
167
 
168
- def prepare_commands(commands)
168
+ def prepare_commands(commands) #:nodoc:
169
169
  return commands unless sudo?
170
170
  commands.map do |command|
171
171
  next command if command.is_a?(Symbol)
@@ -255,7 +255,7 @@ module Sprinkle
255
255
  end
256
256
  end
257
257
 
258
- def ssh_session(host)
258
+ def ssh_session(host) #:nodoc:
259
259
  if @gateway
260
260
  gateway.ssh(host, @options[:user])
261
261
  else
@@ -23,17 +23,17 @@ module Sprinkle
23
23
  self.instance_eval &block if block
24
24
  end
25
25
 
26
- def servers_for_role?
26
+ def servers_for_role? #:nodoc:
27
27
  raise "The vlad actor needs a maintainer. "+
28
28
  "Please file an issue on github.com/sprinkle-tool/sprinkle if you can help."
29
29
  end
30
30
 
31
- def sudo?
31
+ def sudo? #:nodoc:
32
32
  # TODO
33
33
  raise
34
34
  end
35
35
 
36
- def sudo_command
36
+ def sudo_command #:nodoc:
37
37
  "sudo"
38
38
  end
39
39
 
@@ -53,7 +53,7 @@ module Sprinkle
53
53
  @loaded_recipes << name
54
54
  end
55
55
 
56
- def install(installer, roles, opts={})
56
+ def install(installer, roles, opts={}) #:nodoc:
57
57
  @installer=installer
58
58
  if installer.install_sequence.include?(:TRANSFER)
59
59
  process_with_transfer(installer.package.name, installer.install_sequence, roles, opts)
@@ -67,7 +67,7 @@ module Sprinkle
67
67
  @installer = nil
68
68
  end
69
69
 
70
- def verify(verifier, roles, opts={})
70
+ def verify(verifier, roles, opts={}) #:nodoc:
71
71
  process(verifier.package.name, commands, roles,
72
72
  :suppress_and_return_failures => true)
73
73
  end
@@ -97,7 +97,7 @@ module Sprinkle
97
97
  invoke(task)
98
98
  end
99
99
 
100
- def invoke(t)
100
+ def invoke(t) #:nodoc:
101
101
  t.invoke
102
102
  return true
103
103
  rescue ::Rake::CommandFailedError => e
@@ -108,7 +108,7 @@ module Sprinkle
108
108
 
109
109
  private
110
110
 
111
- def task_sym(name)
111
+ def task_sym(name) #:nodoc:
112
112
  "install_#{name.to_task_name}".to_sym
113
113
  end
114
114
  end