Module: Sprinkle::Policy
- Included in:
- Object
- Defined in:
- lib/sprinkle/policy.rb
Overview
Policies
A policy defines a set of packages which are required for a certain role (app, database, etc.). All policies defined will be run and all packages required by the policy will be installed. So whereas defining a Sprinkle::Package merely defines it, defining a Sprinkle::Policy actually causes those packages to install.
A Basic Example
policy :blog, :roles => :app do
require :webserver
require :database
require :rails
end
This says that for the blog on the app role, it requires certain packages. The :roles option is exactly the same as a capistrano or vlad role. A role merely defines what server the commands are run on. This way, a single Sprinkle script can provision an entire group of servers.
To define a role, put in your actor specific configuration file (recipe or script file):
role :app, "208.28.38.44"
The capistrano and vlad syntax is the same for that. If you’re using a custom actor, you may have to do it differently.
Multiple Policies
You may specify as many policies as you’d like. If the packages you’re requiring are properly defined with verification blocks, then no software will be installed twice, so you may require a webserver on multiple packages within the same role without having to wait for that package to install repeatedly.
Defined Under Namespace
Classes: Policy
Constant Summary collapse
- POLICIES =
:nodoc:
[]
Instance Method Summary collapse
-
#policy(name, options = {}, &block) ⇒ Object
Defines a single policy.
Instance Method Details
#policy(name, options = {}, &block) ⇒ Object
Defines a single policy. Currently the only option, which is also required, is :roles, which defines which servers a policy is used on.
47 48 49 50 51 |
# File 'lib/sprinkle/policy.rb', line 47 def policy(name, = {}, &block) p = Policy.new(name, , &block) POLICIES << p p end |