Class: Chef::Failover

Inherits:
Object
  • Object
show all
Defined in:
lib/chef-failover.rb,
lib/chef-failover/version.rb,
lib/chef-failover/strategy/base.rb,
lib/chef-failover/strategy/round_robin.rb

Defined Under Namespace

Modules: Strategy

Constant Summary collapse

VERSION =
"0.0.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Failover

Returns a new instance of Failover.



11
12
13
14
15
16
17
18
19
20
# File 'lib/chef-failover.rb', line 11

def initialize(args = {})
  @config = {}
  @config[:config_directory] ||= '/etc/chef/client.d'
  @config[:chef_client_log]  ||= '/var/log/chef/chef.log'
  @config[:configurations]     = []
  @config[:strategy]           = args[:strategy] || Chef::Failover::Strategy::RoundRobin

  @status = {}
  @status[:last_run_success] = true
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



8
9
10
# File 'lib/chef-failover.rb', line 8

def config
  @config
end

#statusObject

Returns the value of attribute status.



9
10
11
# File 'lib/chef-failover.rb', line 9

def status
  @status
end

Instance Method Details

#add_config(args) ⇒ Object



22
23
24
# File 'lib/chef-failover.rb', line 22

def add_config(args)
  @config[:configurations] << args[:config_name]
end

#config_directoryObject



35
36
37
# File 'lib/chef-failover.rb', line 35

def config_directory
  @config[:config_directory]
end

#config_filename(name) ⇒ Object



31
32
33
# File 'lib/chef-failover.rb', line 31

def config_filename(name)
  self.config_directory + '/' + name.to_s
end

#dispatchObject



26
27
28
29
# File 'lib/chef-failover.rb', line 26

def dispatch
  strategy = @config[:strategy].new(self)
  strategy.dispatch
end