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.
- data/.tm_properties +7 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +46 -4
- data/Rakefile +38 -1
- data/examples/rails/packages/database.rb +7 -0
- data/examples/rails/templates/mysql.cnf.erb +3 -0
- data/lib/sprinkle.rb +8 -13
- data/lib/sprinkle/actors/actor.rb +17 -17
- data/lib/sprinkle/actors/capistrano.rb +3 -3
- data/lib/sprinkle/actors/local.rb +10 -6
- data/lib/sprinkle/actors/ssh.rb +8 -8
- data/lib/sprinkle/actors/vlad.rb +7 -7
- data/lib/sprinkle/core.rb +16 -0
- data/lib/sprinkle/deployment.rb +8 -6
- data/lib/sprinkle/errors/pretty_failure.rb +1 -1
- data/lib/sprinkle/errors/template_error.rb +1 -1
- data/lib/sprinkle/installers/brew.rb +0 -2
- data/lib/sprinkle/installers/deb.rb +6 -2
- data/lib/sprinkle/installers/file.rb +38 -39
- data/lib/sprinkle/installers/freebsd_pkg.rb +4 -0
- data/lib/sprinkle/installers/group.rb +11 -12
- data/lib/sprinkle/installers/install_package.rb +5 -5
- data/lib/sprinkle/installers/openbsd_pkg.rb +5 -1
- data/lib/sprinkle/installers/opensolaris_pkg.rb +5 -1
- data/lib/sprinkle/installers/package_installer.rb +7 -3
- data/lib/sprinkle/installers/pacman.rb +4 -0
- data/lib/sprinkle/installers/push_text.rb +1 -1
- data/lib/sprinkle/installers/rake.rb +14 -6
- data/lib/sprinkle/installers/rpm.rb +5 -0
- data/lib/sprinkle/installers/runner.rb +3 -2
- data/lib/sprinkle/installers/thor.rb +14 -15
- data/lib/sprinkle/installers/transfer.rb +0 -1
- data/lib/sprinkle/installers/user.rb +2 -2
- data/lib/sprinkle/installers/yum.rb +9 -8
- data/lib/sprinkle/installers/zypper.rb +5 -1
- data/lib/sprinkle/package.rb +31 -8
- data/lib/sprinkle/package/chooser.rb +1 -1
- data/lib/sprinkle/package/package_repository.rb +1 -1
- data/lib/sprinkle/package/rendering.rb +13 -10
- data/lib/sprinkle/policy.rb +71 -74
- data/lib/sprinkle/script.rb +2 -2
- data/lib/sprinkle/utility/log_recorder.rb +1 -1
- data/lib/sprinkle/verifiers/file.rb +17 -1
- data/lib/sprinkle/verifiers/package.rb +2 -2
- data/lib/sprinkle/verify.rb +2 -2
- data/lib/sprinkle/version.rb +1 -1
- data/spec/sprinkle/deployment_spec.rb +5 -3
- data/spec/sprinkle/extensions/rendering_spec.rb +29 -14
- data/spec/sprinkle/installers/file_spec.rb +1 -1
- data/spec/sprinkle/installers/installer_spec.rb +1 -1
- data/spec/sprinkle/installers/opensolaris_pkg_spec.rb +0 -4
- data/spec/sprinkle/installers/transfer_spec.rb +1 -1
- data/spec/sprinkle/package_spec.rb +31 -0
- data/spec/sprinkle/policy_spec.rb +5 -5
- data/spec/sprinkle/verify_spec.rb +0 -7
- data/spec/templates/locals.erb +1 -0
- data/spec/templates/test.erb +1 -0
- data/templates/test.erb +1 -0
- metadata +10 -4
- data/lib/sprinkle/verifiers/directory.rb +0 -16
- data/lib/sprinkle/verifiers/symlink.rb +0 -30
@@ -0,0 +1,16 @@
|
|
1
|
+
module Sprinkle
|
2
|
+
# stores the global list of policies as they are defined
|
3
|
+
POLICIES = []
|
4
|
+
|
5
|
+
module Core
|
6
|
+
# Defines a single policy. Currently the only option, which is also
|
7
|
+
# required, is :roles, which defines which servers a policy is
|
8
|
+
# used on.
|
9
|
+
def policy(name, options = {}, &block)
|
10
|
+
p = Sprinkle::Policy.new(name, options, &block)
|
11
|
+
POLICIES << p
|
12
|
+
p
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
data/lib/sprinkle/deployment.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
module Sprinkle
|
2
|
+
# = Deployments
|
3
|
+
#
|
2
4
|
# Deployment blocks specify deployment specific information about a
|
3
5
|
# sprinkle script. An example:
|
4
6
|
#
|
@@ -62,14 +64,14 @@ module Sprinkle
|
|
62
64
|
end
|
63
65
|
|
64
66
|
def method_missing(sym, *args, &block) #:nodoc:
|
65
|
-
|
67
|
+
if Sprinkle::Package::Package.installer_methods.include?(sym)
|
68
|
+
@defaults[sym] = block
|
69
|
+
else
|
70
|
+
super sym, *args, &block
|
71
|
+
end
|
66
72
|
end
|
67
73
|
|
68
|
-
def
|
69
|
-
!!@defaults[sym]
|
70
|
-
end
|
71
|
-
|
72
|
-
def active_policies
|
74
|
+
def active_policies #:nodoc:
|
73
75
|
if role=Sprinkle::OPTIONS[:only_role]
|
74
76
|
role=role.to_sym
|
75
77
|
POLICIES.select {|x| [x.roles].flatten.include?(role) }
|
@@ -2,47 +2,44 @@ require 'tempfile'
|
|
2
2
|
|
3
3
|
module Sprinkle
|
4
4
|
module Installers
|
5
|
+
# = File installer
|
6
|
+
#
|
7
|
+
# This installer creates a file on the remote server.
|
8
|
+
#
|
9
|
+
# == Example Usage
|
10
|
+
#
|
11
|
+
# Installing a nginx.conf onto remote servers
|
12
|
+
#
|
13
|
+
# package :nginx_conf do
|
14
|
+
# file '/etc/nginx.conf', :content => File.read('files/nginx.conf'),
|
15
|
+
# :sudo => true
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# Sudo is only necessary when the user your sprinkle is running as does
|
19
|
+
# not have necessarily permissions to create the file on its own.
|
20
|
+
# Such as when the file is in /etc.
|
21
|
+
#
|
22
|
+
# Should you need to run commands before or after the file transfer (making
|
23
|
+
# directories or changing permissions), you can use the pre/post :install directives.
|
24
|
+
#
|
25
|
+
# == Rendering templates
|
26
|
+
#
|
27
|
+
# Use the template render helper to render an ERB template to a remote file (you
|
28
|
+
# can use variables in your templates by setting them as instance variables inside
|
29
|
+
# your package. Templates have access to package methods such as opts, args, etc.
|
30
|
+
#
|
31
|
+
# package :nginx_conf do
|
32
|
+
# @nginx_port = 8080
|
33
|
+
# file '/etc/nginx.conf',
|
34
|
+
# :contents => render("nginx.conf")
|
35
|
+
# # ./templates/nginx.conf.erb or
|
36
|
+
# # ./templates/nginx.conf should contain the erb template
|
37
|
+
# end
|
5
38
|
class FileInstaller < Installer
|
6
|
-
|
7
|
-
#
|
8
|
-
# This installer creates a file on the remote server.
|
9
|
-
#
|
10
|
-
# == Example Usage
|
11
|
-
#
|
12
|
-
# Installing a nginx.conf onto remote servers
|
13
|
-
#
|
14
|
-
# package :nginx_conf do
|
15
|
-
# file '/etc/nginx.conf', :content => File.read('files/nginx.conf')
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
# If you user has access to 'sudo' and theres a file that requires
|
19
|
-
# priveledges to install, you can pass :sudo => true
|
20
|
-
#
|
21
|
-
# package :nginx_conf do
|
22
|
-
# file '/etc/nginx.conf', :sudo => true,
|
23
|
-
# :content => File.read('files/nginx.conf')
|
24
|
-
# end
|
25
|
-
#
|
26
|
-
# Should you need to run commands before or after the file transfer (making
|
27
|
-
# directories or changing permissions), you can use the pre/post :install directives.
|
28
|
-
#
|
29
|
-
# == Rendering templates
|
30
|
-
#
|
31
|
-
# Use the template render helper to render an ERB template to a remote file (you
|
32
|
-
# can use variables in your templates by setting them as instance variables inside
|
33
|
-
# your package. Templates have access to package methods such as opts, args, etc.
|
34
|
-
#
|
35
|
-
# package :nginx_conf do
|
36
|
-
# @nginx_port = 8080
|
37
|
-
# file '/etc/nginx.conf',
|
38
|
-
# :contents => render("nginx.conf")
|
39
|
-
# # ./templates/nginx.conf.erb or
|
40
|
-
# # ./templates/nginx.conf should contain the erb template
|
41
|
-
# end
|
42
|
-
attr_reader :sourcepath, :destination, :contents
|
39
|
+
attr_reader :sourcepath, :destination, :contents #:nodoc:
|
43
40
|
|
44
41
|
api do
|
45
|
-
def file(destination, options = {}, &block)
|
42
|
+
def file(destination, options = {}, &block) #:nodoc:
|
46
43
|
# options.merge!(:binding => binding())
|
47
44
|
install FileInstaller.new(self, destination, options, &block)
|
48
45
|
end
|
@@ -61,15 +58,17 @@ module Sprinkle
|
|
61
58
|
mode options[:mode] if options[:mode]
|
62
59
|
end
|
63
60
|
|
64
|
-
def install_commands
|
61
|
+
def install_commands #:nodoc:
|
65
62
|
:TRANSFER
|
66
63
|
end
|
67
64
|
|
65
|
+
# calls chown own to set the file ownership
|
68
66
|
def owner(owner)
|
69
67
|
@owner = owner
|
70
68
|
post :install, "#{sudo_cmd}chown #{owner} #{@destination}"
|
71
69
|
end
|
72
70
|
|
71
|
+
# calls chmod to set the files permissions
|
73
72
|
def mode(mode)
|
74
73
|
@mode = mode
|
75
74
|
post :install, "#{sudo_cmd}chmod #{mode} #{@destination}"
|
@@ -1,18 +1,17 @@
|
|
1
1
|
module Sprinkle
|
2
2
|
module Installers
|
3
|
+
# The user installer helps add groups. You may pass flags as an option.
|
4
|
+
#
|
5
|
+
# == Example Usage
|
6
|
+
#
|
7
|
+
# package :users do
|
8
|
+
# add_group 'webguys', :flags => "--shell /usr/bin/zsh"
|
9
|
+
#
|
10
|
+
# verify do
|
11
|
+
# has_group 'webguys'
|
12
|
+
# end
|
13
|
+
# end
|
3
14
|
class Group < Installer
|
4
|
-
# The user installer helps add groups. You may pass flags as an option.
|
5
|
-
#
|
6
|
-
# == Example Usage
|
7
|
-
#
|
8
|
-
# package :users do
|
9
|
-
# add_group 'webguys', :flags => "--shell /usr/bin/zsh"
|
10
|
-
#
|
11
|
-
# verify do
|
12
|
-
# has_group 'webguys'
|
13
|
-
# end
|
14
|
-
# end
|
15
|
-
|
16
15
|
api do
|
17
16
|
def add_group(group, options={}, &block)
|
18
17
|
install Group.new(self, group, options, &block)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Sprinkle
|
2
2
|
module Installers
|
3
|
-
class InstallPackage < Installer
|
3
|
+
class InstallPackage < Installer #:nodoc:
|
4
4
|
cattr_accessor :installer
|
5
5
|
attr_accessor :packages #:nodoc:
|
6
6
|
|
@@ -62,18 +62,18 @@ end
|
|
62
62
|
module Sprinkle
|
63
63
|
module Package
|
64
64
|
class Package
|
65
|
-
def install_package(*names, &block)
|
65
|
+
def install_package(*names, &block) #:nodoc:
|
66
66
|
ActiveSupport::Deprecation.warn("install_package will be removed from sprinkle 0.8, please use yum or smart installers instead.")
|
67
67
|
@installers << Sprinkle::Installers::InstallPackage.new(self, names, &block)
|
68
68
|
end
|
69
69
|
|
70
|
-
def uninstall_package(*names, &block)
|
70
|
+
def uninstall_package(*names, &block) #:nodoc:
|
71
71
|
ActiveSupport::Deprecation.warn("uninstall_package will be removed from sprinkle 0.8, please use yum or smart installers instead.")
|
72
72
|
@installers << Sprinkle::Installers::UninstallPackage.new(self, names, &block)
|
73
73
|
end
|
74
74
|
|
75
|
-
alias_method :install_packages, :install_package
|
76
|
-
alias_method :uninstall_packages, :uninstall_package
|
75
|
+
alias_method :install_packages, :install_package #:nodoc:
|
76
|
+
alias_method :uninstall_packages, :uninstall_package #:nodoc:
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
@@ -26,7 +26,11 @@ module Sprinkle
|
|
26
26
|
# For help on PKG_PATH see section 15.2.2 of the OpenBSD FAQ
|
27
27
|
# (http://www.openbsd.org/faq/faq15.html)
|
28
28
|
class OpenbsdPkg < PackageInstaller
|
29
|
-
|
29
|
+
|
30
|
+
##
|
31
|
+
# installs the OpenBSD packages passed
|
32
|
+
# :method: openbsd_pkg
|
33
|
+
# :call-seq: openbsd_pkg(*packages)
|
30
34
|
auto_api
|
31
35
|
|
32
36
|
protected
|
@@ -13,7 +13,7 @@ module Sprinkle
|
|
13
13
|
# You may also specify multiple packages as an array:
|
14
14
|
#
|
15
15
|
# package :magic_beans do
|
16
|
-
# opensolaris_pkg
|
16
|
+
# opensolaris_pkg 'magic_beans', 'magic_sauce'
|
17
17
|
# end
|
18
18
|
#
|
19
19
|
# == Note
|
@@ -24,6 +24,10 @@ module Sprinkle
|
|
24
24
|
# set :sudo_prompt, ''
|
25
25
|
class OpensolarisPkg < PackageInstaller
|
26
26
|
|
27
|
+
##
|
28
|
+
# installs the OpenSolaris packages passed
|
29
|
+
# :method: opensolaris_pkg
|
30
|
+
# :call-seq: opensolaris_pkg(*packages)
|
27
31
|
auto_api
|
28
32
|
|
29
33
|
protected
|
@@ -4,7 +4,8 @@ module Sprinkle
|
|
4
4
|
# inherit from (deb, *BSD pkg, rpm, etc)
|
5
5
|
class PackageInstaller < Installer
|
6
6
|
|
7
|
-
|
7
|
+
# holds the list of packages to be installed
|
8
|
+
attr_accessor :packages
|
8
9
|
|
9
10
|
def initialize(parent, *packages, &block) #:nodoc:
|
10
11
|
options = packages.extract_options!
|
@@ -12,8 +13,11 @@ module Sprinkle
|
|
12
13
|
@packages = [*packages].flatten
|
13
14
|
end
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
# automatically sets up the api for package installation based on the class name
|
17
|
+
#
|
18
|
+
# Apt becomes the method `apt`, etc
|
19
|
+
def self.auto_api(*args)
|
20
|
+
method_name = args.first || self.to_s.underscore.split("/").last
|
17
21
|
class_name = self.to_s
|
18
22
|
api do
|
19
23
|
method="def #{method_name}(*names, &block)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Sprinkle
|
2
2
|
module Installers
|
3
|
-
# This installer runs a rake
|
3
|
+
# This installer runs a rake task.
|
4
4
|
#
|
5
5
|
# == Example Usage
|
6
6
|
#
|
@@ -9,13 +9,13 @@ module Sprinkle
|
|
9
9
|
# the :rakefile option.
|
10
10
|
#
|
11
11
|
# package :spec do
|
12
|
-
# rake 'spec', :
|
12
|
+
# rake 'spec', :file => "/var/setup/Rakefile"
|
13
13
|
# end
|
14
14
|
class Rake < Installer
|
15
15
|
|
16
16
|
api do
|
17
|
-
def rake(
|
18
|
-
install Rake.new(self,
|
17
|
+
def rake(task, options = {}, &block)
|
18
|
+
install Rake.new(self, task, options, &block)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -27,8 +27,16 @@ module Sprinkle
|
|
27
27
|
protected
|
28
28
|
|
29
29
|
def install_commands #:nodoc:
|
30
|
-
|
31
|
-
|
30
|
+
"#{executable} #{taskfile}#{@commands}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def executable #:nodoc:
|
34
|
+
"rake"
|
35
|
+
end
|
36
|
+
|
37
|
+
def taskfile #:nodoc:
|
38
|
+
file = @options[:rakefile] || @options[:file]
|
39
|
+
file ? "-f #{file} " : ""
|
32
40
|
end
|
33
41
|
|
34
42
|
end
|
@@ -23,8 +23,9 @@ module Sprinkle
|
|
23
23
|
install Runner.new(self, cmds, options, &block)
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
# runs 'echo noop' on the remote host
|
27
|
+
def noop
|
28
|
+
install Runner.new(self, "echo noop")
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
@@ -2,7 +2,7 @@ module Sprinkle
|
|
2
2
|
module Installers
|
3
3
|
# = Thor Installer
|
4
4
|
#
|
5
|
-
# This installer runs a thor
|
5
|
+
# This installer runs a thor task.
|
6
6
|
#
|
7
7
|
# == Example Usage
|
8
8
|
#
|
@@ -15,29 +15,28 @@ module Sprinkle
|
|
15
15
|
#
|
16
16
|
# Specify a Thorfile with the :thorfile option.
|
17
17
|
#
|
18
|
-
# package :spec
|
19
|
-
# thor 'spec'
|
18
|
+
# package :spec do
|
19
|
+
# thor 'spec', :file => "/var/setup/Thorfile"
|
20
20
|
# end
|
21
21
|
|
22
|
-
class Thor <
|
22
|
+
class Thor < Rake
|
23
23
|
|
24
24
|
api do
|
25
|
-
def thor(
|
26
|
-
install Thor.new(self,
|
25
|
+
def thor(task, options = {}, &block)
|
26
|
+
install Thor.new(self, task, options, &block)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
def initialize(parent, commands, options = {}, &block) #:nodoc:
|
31
|
-
super parent, options, &block
|
32
|
-
@commands = commands
|
33
|
-
end
|
34
|
-
|
35
30
|
protected
|
36
31
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
32
|
+
def executable #:nodoc:
|
33
|
+
"thor"
|
34
|
+
end
|
35
|
+
|
36
|
+
def taskfile #:nodoc:
|
37
|
+
file = @options[:thorfile] || @options[:file]
|
38
|
+
file ? "-f #{file} " : ""
|
39
|
+
end
|
41
40
|
|
42
41
|
end
|
43
42
|
end
|