Class: Sprinkle::Actors::Dummy

Inherits:
Actor show all
Defined in:
lib/sprinkle/actors/dummy.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Actor

#sudo_command

Constructor Details

#initialize(&block) ⇒ Dummy

:nodoc:


10
11
12
13
14
# File 'lib/sprinkle/actors/dummy.rb', line 10

def initialize(&block) #:nodoc:
  # @config.set(:_sprinkle_actor, self)
  @roles={}
  self.instance_eval(&block)
end

Instance Attribute Details

#per_hostObject

Returns the value of attribute per_host


8
9
10
# File 'lib/sprinkle/actors/dummy.rb', line 8

def per_host
  @per_host
end

Instance Method Details

#install(installer, roles, opts = {}) ⇒ Object


27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/sprinkle/actors/dummy.rb', line 27

def install(installer, roles, opts={})
  @installer = installer
  if self.per_host=opts.delete(:per_host)
    servers_per_role(roles).each do |server|
      installer.reconfigure_for(server)
      installer.announce
      process(installer.package.name, installer.install_sequence, server, opts)
    end
  else
    process(installer.package, installer.install_sequence, roles, opts)
  end
end

52
53
54
# File 'lib/sprinkle/actors/dummy.rb', line 52

def print_command(cmd)
  puts cmd.inspect
end

#process(name, commands, roles, opts = {}) ⇒ Object

:nodoc:


56
57
58
59
60
61
62
63
# File 'lib/sprinkle/actors/dummy.rb', line 56

def process(name, commands, roles, opts = {}) #:nodoc:
  # puts "PROCESS: #{name} on #{roles}"
  commands.each do |cmd|
    print_command(cmd)
  end
  # return false if suppress_and_return_failures
  true
end

#role(role, server, opts = {}) ⇒ Object


16
17
18
19
# File 'lib/sprinkle/actors/dummy.rb', line 16

def role(role, server, opts={})
  @roles[role]||=[]
  @roles[role] << [ server, opts ]
end

#servers_for_role?(roles) ⇒ Boolean

Determines if there are any servers for the given roles

Returns:

  • (Boolean)

22
23
24
25
# File 'lib/sprinkle/actors/dummy.rb', line 22

def servers_for_role?(roles)
  roles=Array(roles)
  roles.any? { |r| @roles.keys.include?(r) }
end

#servers_per_role(role) ⇒ Object


48
49
50
# File 'lib/sprinkle/actors/dummy.rb', line 48

def servers_per_role(role)
  @roles[role]
end

#sudo?Boolean

Returns:

  • (Boolean)

40
41
42
# File 'lib/sprinkle/actors/dummy.rb', line 40

def sudo?
  false
end

#verify(verifier, roles, opts = {}) ⇒ Object


44
45
46
# File 'lib/sprinkle/actors/dummy.rb', line 44

def verify(verifier, roles, opts = {})
  process(verifier.package.name, verifier.commands, roles, opts = {})
end