Class: CapUtil::ServerRoles

Inherits:
Object
  • Object
show all
Includes:
CapUtil
Defined in:
lib/cap-util/server_roles.rb

Defined Under Namespace

Classes: RoleDef, RoleSet, ServerDef

Constant Summary

Constants included from CapUtil

VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CapUtil

color, #get, halt, #hostname, included, run_locally, run_locally_with_stdin, say, say_bulleted, say_error, say_raw, say_warning, time

Constructor Details

#initialize(cap, roles_yaml) ⇒ ServerRoles

Returns a new instance of ServerRoles.



10
11
12
13
# File 'lib/cap-util/server_roles.rb', line 10

def initialize(cap, roles_yaml)
  @cap = cap
  @roles = RoleSet.new(YAML.load(roles_yaml))
end

Instance Attribute Details

#rolesObject (readonly)

Returns the value of attribute roles.



8
9
10
# File 'lib/cap-util/server_roles.rb', line 8

def roles
  @roles
end

Instance Method Details

#applyObject

Since this is a CapUtil, we can call cap cmds using the ‘cap` accessor. For each role, call cap’s ‘role` method, passing the relevant values.



18
19
20
21
22
23
# File 'lib/cap-util/server_roles.rb', line 18

def apply
  @roles.each do |name, host, opts|
    cap.role name, host, opts
  end

end