Class: CapUtil::ServerRoles
- Inherits:
-
Object
- Object
- CapUtil::ServerRoles
- Includes:
- CapUtil
- Defined in:
- lib/cap-util/server_roles.rb
Defined Under Namespace
Classes: RoleDef, RoleSet, ServerDef
Constant Summary
Constants included from CapUtil
Instance Attribute Summary collapse
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
Instance Method Summary collapse
-
#apply ⇒ Object
Since this is a CapUtil, we can call cap cmds using the ‘cap` accessor.
-
#initialize(cap, roles_yaml) ⇒ ServerRoles
constructor
A new instance of ServerRoles.
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
#roles ⇒ Object (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
#apply ⇒ Object
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 |