trevorturk-sprinkle 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. data/CREDITS +22 -0
  2. data/History.txt +4 -0
  3. data/MIT-LICENSE +20 -0
  4. data/Manifest.txt +101 -0
  5. data/README.txt +241 -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/actors/actors.rb +17 -0
  31. data/lib/sprinkle/actors/capistrano.rb +124 -0
  32. data/lib/sprinkle/actors/local.rb +30 -0
  33. data/lib/sprinkle/actors/ssh.rb +81 -0
  34. data/lib/sprinkle/actors/vlad.rb +65 -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/bsd_port.rb +33 -0
  45. data/lib/sprinkle/installers/deb.rb +38 -0
  46. data/lib/sprinkle/installers/freebsd_pkg.rb +37 -0
  47. data/lib/sprinkle/installers/gem.rb +63 -0
  48. data/lib/sprinkle/installers/installer.rb +120 -0
  49. data/lib/sprinkle/installers/mac_port.rb +38 -0
  50. data/lib/sprinkle/installers/noop.rb +20 -0
  51. data/lib/sprinkle/installers/openbsd_pkg.rb +47 -0
  52. data/lib/sprinkle/installers/opensolaris_pkg.rb +43 -0
  53. data/lib/sprinkle/installers/push_text.rb +45 -0
  54. data/lib/sprinkle/installers/rake.rb +37 -0
  55. data/lib/sprinkle/installers/rpm.rb +37 -0
  56. data/lib/sprinkle/installers/source.rb +179 -0
  57. data/lib/sprinkle/installers/yum.rb +37 -0
  58. data/lib/sprinkle/package.rb +279 -0
  59. data/lib/sprinkle/policy.rb +125 -0
  60. data/lib/sprinkle/script.rb +23 -0
  61. data/lib/sprinkle/verifiers/directory.rb +16 -0
  62. data/lib/sprinkle/verifiers/executable.rb +36 -0
  63. data/lib/sprinkle/verifiers/file.rb +26 -0
  64. data/lib/sprinkle/verifiers/process.rb +21 -0
  65. data/lib/sprinkle/verifiers/ruby.rb +25 -0
  66. data/lib/sprinkle/verifiers/symlink.rb +30 -0
  67. data/lib/sprinkle/verify.rb +114 -0
  68. data/lib/sprinkle/version.rb +9 -0
  69. data/lib/sprinkle.rb +32 -0
  70. data/script/destroy +14 -0
  71. data/script/generate +14 -0
  72. data/spec/spec.opts +1 -0
  73. data/spec/spec_helper.rb +17 -0
  74. data/spec/sprinkle/actors/capistrano_spec.rb +170 -0
  75. data/spec/sprinkle/actors/local_spec.rb +29 -0
  76. data/spec/sprinkle/configurable_spec.rb +46 -0
  77. data/spec/sprinkle/deployment_spec.rb +80 -0
  78. data/spec/sprinkle/extensions/array_spec.rb +19 -0
  79. data/spec/sprinkle/extensions/string_spec.rb +21 -0
  80. data/spec/sprinkle/installers/apt_spec.rb +70 -0
  81. data/spec/sprinkle/installers/bsd_port_spec.rb +42 -0
  82. data/spec/sprinkle/installers/freebsd_pkg_spec.rb +49 -0
  83. data/spec/sprinkle/installers/gem_spec.rb +91 -0
  84. data/spec/sprinkle/installers/installer_spec.rb +151 -0
  85. data/spec/sprinkle/installers/mac_port_spec.rb +42 -0
  86. data/spec/sprinkle/installers/noop_spec.rb +23 -0
  87. data/spec/sprinkle/installers/openbsd_pkg_spec.rb +49 -0
  88. data/spec/sprinkle/installers/opensolaris_pkg_spec.rb +49 -0
  89. data/spec/sprinkle/installers/push_text_spec.rb +55 -0
  90. data/spec/sprinkle/installers/rake_spec.rb +29 -0
  91. data/spec/sprinkle/installers/rpm_spec.rb +50 -0
  92. data/spec/sprinkle/installers/source_spec.rb +331 -0
  93. data/spec/sprinkle/installers/yum_spec.rb +49 -0
  94. data/spec/sprinkle/policy_spec.rb +126 -0
  95. data/spec/sprinkle/script_spec.rb +51 -0
  96. data/spec/sprinkle/sprinkle_spec.rb +25 -0
  97. data/spec/sprinkle/verify_spec.rb +167 -0
  98. data/sprinkle.gemspec +73 -0
  99. data/tasks/deployment.rake +34 -0
  100. data/tasks/environment.rake +7 -0
  101. data/tasks/rspec.rake +21 -0
  102. metadata +197 -0
@@ -0,0 +1,73 @@
1
+ module Sprinkle
2
+ # Deployment blocks specify deployment specific information about a
3
+ # sprinkle script. An example:
4
+ #
5
+ # deployment do
6
+ # # mechanism for deployment
7
+ # delivery :capistrano do
8
+ # recipes 'deploy'
9
+ # end
10
+ #
11
+ # # source based package installer defaults
12
+ # source do
13
+ # prefix '/usr/local'
14
+ # archives '/usr/local/sources'
15
+ # builds '/usr/local/build'
16
+ # end
17
+ # end
18
+ #
19
+ # What the above example does is tell sprinkle that we will be using
20
+ # *capistrano* (Sprinkle::Actors::Capistrano) for deployment and
21
+ # everything within the block is capistrano specific configuration.
22
+ # For more information on what options are available, check the corresponding
23
+ # Sprinkle::Actors doc page.
24
+ #
25
+ # In addition to what delivery mechanism we're using, we specify some
26
+ # configuration options for the "source" command. The only things
27
+ # configurable, at this time, in the deployment block other than
28
+ # the delivery method are installers. If installers are configurable,
29
+ # they will say so on their corresponding documentation page. See
30
+ # Sprinkle::Installers
31
+ #
32
+ # <b>Only one deployment block is on any given sprinkle script</b>
33
+ module Deployment
34
+ # The method outlined above which specifies deployment specific information
35
+ # for a sprinkle script. For more information, read the header of this module.
36
+ def deployment(&block)
37
+ @deployment = Deployment.new(&block)
38
+ end
39
+
40
+ class Deployment
41
+ attr_accessor :style, :defaults #:nodoc:
42
+
43
+ def initialize(&block) #:nodoc:
44
+ @defaults = {}
45
+ self.instance_eval(&block)
46
+ raise 'No delivery mechanism defined' unless @style
47
+ end
48
+
49
+ # Specifies which Sprinkle::Actors to use for delivery. Although all
50
+ # actors jobs are the same: to run remote commands on a server, you
51
+ # may have a personal preference. The block you pass is used to configure
52
+ # the actor. For more information on what configuration options are
53
+ # available, view the corresponding Sprinkle::Actors page.
54
+ def delivery(type, &block) #:doc:
55
+ @style = Actors.const_get(type.to_s.titleize).new &block
56
+ end
57
+
58
+ def method_missing(sym, *args, &block) #:nodoc:
59
+ @defaults[sym] = block
60
+ end
61
+
62
+ def respond_to?(sym) #:nodoc:
63
+ !!@defaults[sym]
64
+ end
65
+
66
+ def process #:nodoc:
67
+ POLICIES.each do |policy|
68
+ policy.process(self)
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,10 @@
1
+ module ArbitraryOptions #:nodoc:
2
+ def self.included(base)
3
+ base.alias_method_chain :method_missing, :arbitrary_options
4
+ end
5
+
6
+ def method_missing_with_arbitrary_options(sym, *args, &block)
7
+ self.class.dsl_accessor sym
8
+ send(sym, *args, &block)
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ class Array #:nodoc:
2
+ def to_task_name
3
+ collect(&:to_task_name).join('_')
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class BlankSlate #:nodoc:
2
+ instance_methods.each do |m|
3
+ undef_method(m) unless %w( __send__ __id__ send class inspect instance_eval instance_variables ).include?(m)
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ class Module #:nodoc:
2
+ def dsl_accessor(*symbols)
3
+ symbols.each do |sym|
4
+ class_eval %{
5
+ def #{sym}(*val)
6
+ if val.empty?
7
+ @#{sym}
8
+ else
9
+ @#{sym} = val.size == 1 ? val[0] : val
10
+ end
11
+ end
12
+ }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ class String #:nodoc:
2
+
3
+ # REVISIT: what chars shall we allow in task names?
4
+ def to_task_name
5
+ s = downcase
6
+ s.gsub!(/-/, '_') # all - to _ chars
7
+ s
8
+ end
9
+
10
+ end
@@ -0,0 +1,7 @@
1
+ class Symbol #:nodoc:
2
+
3
+ def to_task_name
4
+ to_s.to_task_name
5
+ end
6
+
7
+ end
@@ -0,0 +1,52 @@
1
+ module Sprinkle
2
+ module Installers
3
+ # = Apt Package Installer
4
+ #
5
+ # The Apt package installer uses the +apt-get+ command to install
6
+ # packages. The apt installer has only one option which can be
7
+ # modified which is the +dependencies_only+ option. When this is
8
+ # set to true, the installer uses +build-dep+ instead of +install+
9
+ # to only build the dependencies.
10
+ #
11
+ # == Example Usage
12
+ #
13
+ # First, a simple installation of the magic_beans package:
14
+ #
15
+ # package :magic_beans do
16
+ # description "Beans beans they're good for your heart..."
17
+ # apt 'magic_beans_package'
18
+ # end
19
+ #
20
+ # Second, only build the magic_beans dependencies:
21
+ #
22
+ # package :magic_beans_depends do
23
+ # apt 'magic_beans_package' { dependencies_only true }
24
+ # end
25
+ #
26
+ # As you can see, setting options is as simple as creating a
27
+ # block and calling the option as a method with the value as
28
+ # its parameter.
29
+ class Apt < Installer
30
+ attr_accessor :packages #:nodoc:
31
+
32
+ def initialize(parent, *packages, &block) #:nodoc:
33
+ packages.flatten!
34
+
35
+ options = { :dependencies_only => false }
36
+ options.update(packages.pop) if packages.last.is_a?(Hash)
37
+
38
+ super parent, options, &block
39
+
40
+ @packages = packages
41
+ end
42
+
43
+ protected
44
+
45
+ def install_commands #:nodoc:
46
+ command = @options[:dependencies_only] ? 'build-dep' : 'install'
47
+ "DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get -qyu #{command} #{@packages.join(' ')}"
48
+ end
49
+
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,33 @@
1
+ module Sprinkle
2
+ module Installers
3
+ # = OpenBSD and FreeBSD Port Installer
4
+ #
5
+ # The Port installer installs OpenBSD and FreeBSD ports.
6
+ # Before usage, the ports sytem must be installed and
7
+ # read on the target operating system.
8
+ #
9
+ # == Example Usage
10
+ #
11
+ # Installing the magic_beans port.
12
+ #
13
+ # package :magic_beans do
14
+ # bsd_port 'magic/magic_beans'
15
+ # end
16
+ #
17
+ class BsdPort < Installer
18
+ attr_accessor :port #:nodoc:
19
+
20
+ def initialize(parent, port, &block) #:nodoc:
21
+ super parent, &block
22
+ @port = port
23
+ end
24
+
25
+ protected
26
+
27
+ def install_commands #:nodoc:
28
+ "sh -c 'cd /usr/ports/#{@port} && make BATCH=yes install clean'"
29
+ end
30
+
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,38 @@
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/#{package_name(p)}"}.join(" ")}"
28
+ end
29
+
30
+ private
31
+
32
+ def package_name(url)
33
+ url.split('/').last
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,37 @@
1
+ module Sprinkle
2
+ module Installers
3
+ # = FreeBSD Package Installer
4
+ #
5
+ # The Pkg package installer installs FreeBSD packages.
6
+ #
7
+ # == Example Usage
8
+ #
9
+ # Installing the magic_beans package.
10
+ #
11
+ # package :magic_beans do
12
+ # freebsd_pkg 'magic_beans'
13
+ # end
14
+ #
15
+ # You may also specify multiple packages as an array:
16
+ #
17
+ # package :magic_beans do
18
+ # freebsd_pkg %w(magic_beans magic_sauce)
19
+ # end
20
+ class FreebsdPkg < 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
+ "pkg_add -r #{@packages.join(' ')}"
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,63 @@
1
+ module Sprinkle
2
+ module Installers
3
+ # = Ruby Gem Package Installer
4
+ #
5
+ # The gem package installer installs ruby gems.
6
+ #
7
+ # The installer has a single optional configuration: source.
8
+ # By changing source you can specify a given ruby gems
9
+ # repository from which to install.
10
+ #
11
+ # == Example Usage
12
+ #
13
+ # First, a simple installation of the magic_beans gem:
14
+ #
15
+ # package :magic_beans do
16
+ # description "Beans beans they're good for your heart..."
17
+ # gem 'magic_beans'
18
+ # end
19
+ #
20
+ # Second, install magic_beans gem from github:
21
+ #
22
+ # package :magic_beans do
23
+ # gem 'magic_beans_package' do
24
+ # source 'http://gems.github.com'
25
+ # end
26
+ # end
27
+ #
28
+ # As you can see, setting options is as simple as creating a
29
+ # block and calling the option as a method with the value as
30
+ # its parameter.
31
+ class Gem < Installer
32
+ attr_accessor :gem #:nodoc:
33
+
34
+ def initialize(parent, gem, options = {}, &block) #:nodoc:
35
+ super parent, options, &block
36
+ @gem = gem
37
+ end
38
+
39
+ def source(location = nil) #:nodoc:
40
+ # package defines an installer called source so here we specify a method directly
41
+ # rather than rely on the automatic options processing since packages' method missing
42
+ # won't be run
43
+ return @options[:source] unless location
44
+ @options[:source] = location
45
+ end
46
+
47
+ protected
48
+
49
+ # rubygems 0.9.5+ installs dependencies by default, and does platform selection
50
+
51
+ def install_commands #:nodoc:
52
+ cmd = "gem install #{gem}"
53
+ cmd << " --version '#{version}'" if version
54
+ cmd << " --source #{source}" if source
55
+ cmd << " --install-dir #{repository}" if option?(:repository)
56
+ cmd << " --no-rdoc --no-ri" unless option?(:build_docs)
57
+ cmd << " -- #{build_flags}" if option?(:build_flags)
58
+ cmd
59
+ end
60
+
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,120 @@
1
+ module Sprinkle
2
+ module Installers
3
+ # The base class which all installers must subclass, this class makes
4
+ # sure all installers share some general features, which are outlined
5
+ # below.
6
+ #
7
+ # = Pre/Post Installation Hooks
8
+ #
9
+ # With all intallation methods you have the ability to specify multiple
10
+ # pre/post installation hooks. This gives you the ability to specify
11
+ # commands to run before and after an installation takes place. All
12
+ # commands by default are sudo'd so there is no need to include "sudo"
13
+ # in the command itself. There are three ways to specify a pre/post hook.
14
+ #
15
+ # First, a single command:
16
+ #
17
+ # pre :install, 'echo "Hello, World!"'
18
+ # post :install, 'rm -rf /'
19
+ #
20
+ # Second, an array of commands:
21
+ #
22
+ # commands = ['echo "First"', 'echo "Then Another"']
23
+ # pre :install, commands
24
+ # post :install, commands
25
+ #
26
+ # Third, a block which returns either a single or multiple commands:
27
+ #
28
+ # pre :install do
29
+ # amount = 7 * 3
30
+ # "echo 'Before we install, lets plant #{amount} magic beans...'"
31
+ # end
32
+ # post :install do
33
+ # ['echo "Now... let's hope they sprout!", 'echo "Indeed they have!"']
34
+ # end
35
+ #
36
+ # = Other Pre/Post Hooks
37
+ #
38
+ # Some installation methods actually grant you more fine grained
39
+ # control of when commands are run rather than a blanket pre :install
40
+ # or post :install. If this is the case, it will be documented on
41
+ # the installation method's corresponding documentation page.
42
+ class Installer
43
+ include Sprinkle::Configurable
44
+ attr_accessor :delivery, :package, :options, :pre, :post #:nodoc:
45
+
46
+ def initialize(package, options = {}, &block) #:nodoc:
47
+ @package = package
48
+ @options = options
49
+ @pre = {}; @post = {}
50
+ self.instance_eval(&block) if block
51
+ end
52
+
53
+ def pre(stage, *commands)
54
+ @pre[stage] ||= []
55
+ @pre[stage] += commands
56
+ @pre[stage] += [yield] if block_given?
57
+ end
58
+
59
+ def post(stage, *commands)
60
+ @post[stage] ||= []
61
+ @post[stage] += commands
62
+ @post[stage] += [yield] if block_given?
63
+ end
64
+
65
+ def process(roles) #:nodoc:
66
+ assert_delivery
67
+
68
+ if logger.debug?
69
+ sequence = install_sequence; sequence = sequence.join('; ') if sequence.is_a? Array
70
+ logger.debug "#{@package.name} install sequence: #{sequence} for roles: #{roles}\n"
71
+ end
72
+
73
+ unless Sprinkle::OPTIONS[:testing]
74
+ logger.info "--> Installing #{package.name} for roles: #{roles}"
75
+ @delivery.process(@package.name, install_sequence, roles)
76
+ end
77
+ end
78
+
79
+ protected
80
+ # More complicated installers that have different stages, and require pre/post commands
81
+ # within stages can override install_sequence and take complete control of the install
82
+ # command sequence construction (eg. source based installer).
83
+ def install_sequence
84
+ commands = pre_commands(:install) + [ install_commands ] + post_commands(:install)
85
+ commands.flatten
86
+ end
87
+
88
+ # A concrete installer (subclass of this virtual class) must override this method
89
+ # and return the commands it needs to run as either a string or an array.
90
+ #
91
+ # <b>Overriding this method is required.</b>
92
+ def install_commands
93
+ raise 'Concrete installers implement this to specify commands to run to install their respective packages'
94
+ end
95
+
96
+ def pre_commands(stage) #:nodoc:
97
+ dress @pre[stage] || [], :pre
98
+ end
99
+
100
+ def post_commands(stage) #:nodoc:
101
+ dress @post[stage] || [], :post
102
+ end
103
+
104
+ # Concrete installers (subclasses of this virtual class) can override this method to
105
+ # specify stage-specific (pre-installation, post-installation, etc.) modifications
106
+ # of commands.
107
+ #
108
+ # An example usage of overriding this would be to prefix all commands for a
109
+ # certain stage to change to a certain directory. An example is given below:
110
+ #
111
+ # def dress(commands, stage)
112
+ # commands.collect { |x| "cd #{magic_beans_path} && #{x}" }
113
+ # end
114
+ #
115
+ # By default, no modifications are made to the commands.
116
+ def dress(commands, stage); commands; end
117
+
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,38 @@
1
+ module Sprinkle
2
+ module Installers
3
+ # = Mac OS X Port Installer (macports)
4
+ #
5
+ # The Port installer installs macports ports.
6
+ #
7
+ # == Example Usage
8
+ #
9
+ # Installing the magic_beans port.
10
+ #
11
+ # package :magic_beans do
12
+ # mac_port 'magic/magic_beans'
13
+ # end
14
+ #
15
+ # == Notes
16
+ # Before MacPorts packages can be installed, the PATH
17
+ # environment variable probably has to be changed so
18
+ # capistrano can find the /opt/local/bin/port executable
19
+ #
20
+ # You must set PATH in ~/.ssh/environment on the remote
21
+ # system and enable 'PermitUserEnvironment yes' in /etc/sshd_config
22
+ class MacPort < Installer
23
+ attr_accessor :port #:nodoc:
24
+
25
+ def initialize(parent, port, &block) #:nodoc:
26
+ super parent, &block
27
+ @port = port
28
+ end
29
+
30
+ protected
31
+
32
+ def install_commands #:nodoc:
33
+ "port install #{@port}"
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,20 @@
1
+ module Sprinkle
2
+ module Installers
3
+ # = Noop Installer
4
+ #
5
+ # This installer does nothing, it's simply useful for running pre / post hooks by themselves.
6
+ #
7
+ class Noop < Installer
8
+ def initialize(parent, &block) #:nodoc:
9
+ super parent, {}, &block
10
+ end
11
+
12
+ protected
13
+
14
+ def install_commands #:nodoc:
15
+ ''
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,47 @@
1
+ module Sprinkle
2
+ module Installers
3
+ # = OpenBSD Package Installer
4
+ #
5
+ # The Pkg package installer installs OpenBSD packages.
6
+ #
7
+ # == Example Usage
8
+ #
9
+ # Installing the magic_beans package.
10
+ #
11
+ # package :magic_beans do
12
+ # openbsd_pkg 'magic_beans'
13
+ # end
14
+ #
15
+ # You may also specify multiple packages as an array:
16
+ #
17
+ # package :magic_beans do
18
+ # openbsd_pkg %w(magic_beans magic_sauce)
19
+ # end
20
+ #
21
+ # == Notes
22
+ # Before OpenBSD packages can be installed, the PKG_PATH
23
+ # environment variable must be set.
24
+ #
25
+ # You must set PKG_PATH in ~/.ssh/environment on the remote
26
+ # system and enable 'PermitUserEnvironment yes' in /etc/ssh/sshd_config
27
+ #
28
+ # For help on PKG_PATH see section 15.2.2 of the OpenBSD FAQ
29
+ # (http://www.openbsd.org/faq/faq15.html)
30
+ class OpenbsdPkg < Installer
31
+ attr_accessor :packages #:nodoc:
32
+
33
+ def initialize(parent, packages, &block) #:nodoc:
34
+ super parent, &block
35
+ packages = [packages] unless packages.is_a? Array
36
+ @packages = packages
37
+ end
38
+
39
+ protected
40
+
41
+ def install_commands #:nodoc:
42
+ "pkg_add #{@packages.join(' ')}"
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,43 @@
1
+ module Sprinkle
2
+ module Installers
3
+ # = OpenSolaris Package Installer
4
+ #
5
+ # The Pkg package installer installs OpenSolaris packages.
6
+ #
7
+ # == Example Usage
8
+ #
9
+ # Installing the magic_beans package.
10
+ #
11
+ # package :magic_beans do
12
+ # opensolaris_pkg 'magic_beans'
13
+ # end
14
+ #
15
+ # You may also specify multiple packages as an array:
16
+ #
17
+ # package :magic_beans do
18
+ # opensolaris_pkg %w(magic_beans magic_sauce)
19
+ # end
20
+ #
21
+ # == Note
22
+ # If you are using capistrano as the deployment method
23
+ # you will need to add the following lines to your deploy.rb
24
+ # set :sudo, 'pfexec'
25
+ # set :sudo_prompt, ''
26
+ class OpensolarisPkg < Installer
27
+ attr_accessor :packages #:nodoc:
28
+
29
+ def initialize(parent, packages, &block) #:nodoc:
30
+ super parent, &block
31
+ packages = [packages] unless packages.is_a? Array
32
+ @packages = packages
33
+ end
34
+
35
+ protected
36
+
37
+ def install_commands #:nodoc:
38
+ "pkg install #{@packages.join(' ')}"
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,45 @@
1
+ module Sprinkle
2
+ module Installers
3
+ # Beware, strange "installer" coming your way.
4
+ #
5
+ # = Text configuration installer
6
+ #
7
+ # This installer pushes simple configuration into a file.
8
+ #
9
+ # == Example Usage
10
+ #
11
+ # Installing magic_beans into apache2.conf
12
+ #
13
+ # package :magic_beans do
14
+ # push_text 'magic_beans', '/etc/apache2/apache2.conf'
15
+ # end
16
+ #
17
+ # If you user has access to 'sudo' and theres a file that requires
18
+ # priveledges, you can pass :sudo => true
19
+ #
20
+ # package :magic_beans do
21
+ # push_text 'magic_beans', '/etc/apache2/apache2.conf', :sudo => true
22
+ # end
23
+ #
24
+ # A special verify step exists for this very installer
25
+ # its known as file_contains, it will test that a file indeed
26
+ # contains a substring that you send it.
27
+ #
28
+ class PushText < Installer
29
+ attr_accessor :text, :path #:nodoc:
30
+
31
+ def initialize(parent, text, path, options={}, &block) #:nodoc:
32
+ super parent, options, &block
33
+ @text = text
34
+ @path = path
35
+ end
36
+
37
+ protected
38
+
39
+ def install_commands #:nodoc:
40
+ "echo '#{@text}' |#{'sudo' if option?(:sudo)} tee -a #{@path}"
41
+ end
42
+
43
+ end
44
+ end
45
+ end