class Kondate::HostPlugin::File

YAML format

host1: [role1, role2] host2: [role1, role2]

Public Class Methods

new(config) click to toggle source

@param [HashWithIndifferentAccess] config

Calls superclass method Kondate::HostPlugin::Base::new
# File lib/kondate/host_plugin/file.rb, line 11
def initialize(config)
  super
  raise ConfigError.new('file: path is not configured') unless config.path
  @path = config.path

  @roles_of_host = YAML.load_file(@path)
  @hosts_of_role = {}
  @roles_of_host.each do |host, roles|
    roles.each do |role|
      @hosts_of_role[role] ||= []
      @hosts_of_role[role] << host
    end
  end
end

Public Instance Methods

get_environment(host) click to toggle source

@param [String] host hostname @return [String] environment name

# File lib/kondate/host_plugin/file.rb, line 28
def get_environment(host)
  ENV['ENVIRONMENT'] || 'development'
end
get_hosts(role) click to toggle source

@param [String] role role @return [Array] array of hosts

Available from kondate >= 0.3.0

# File lib/kondate/host_plugin/file.rb, line 42
def get_hosts(role)
  @hosts_of_role[role]
end
get_roles(host) click to toggle source

@param [String] host hostname @return [Array] array of roles

# File lib/kondate/host_plugin/file.rb, line 34
def get_roles(host)
  @roles_of_host[host]
end