Class: Kondate::HostPlugin::File
- Defined in:
- lib/kondate/host_plugin/file.rb
Overview
YAML format
host1: [role1, role2] host2: [role1, role2]
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#get_environment(host) ⇒ String
Environment name.
-
#get_hosts(role) ⇒ Array
Available from kondate >= 0.3.0.
-
#get_roles(host) ⇒ Array
Array of roles.
-
#initialize(config) ⇒ File
constructor
A new instance of File.
Constructor Details
#initialize(config) ⇒ File
Returns a new instance of File.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# 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 |
Instance Method Details
#get_environment(host) ⇒ String
Returns environment name.
28 29 30 |
# File 'lib/kondate/host_plugin/file.rb', line 28 def get_environment(host) ENV['ENVIRONMENT'] || 'development' end |
#get_hosts(role) ⇒ Array
Available from kondate >= 0.3.0
42 43 44 |
# File 'lib/kondate/host_plugin/file.rb', line 42 def get_hosts(role) @hosts_of_role[role] end |
#get_roles(host) ⇒ Array
Returns array of roles.
34 35 36 |
# File 'lib/kondate/host_plugin/file.rb', line 34 def get_roles(host) @roles_of_host[host] end |