class Hocho::InventoryProviders::File
Attributes
path[R]
Public Class Methods
new(path:)
click to toggle source
# File lib/hocho/inventory_providers/file.rb, line 9 def initialize(path:) @path = path end
Public Instance Methods
files()
click to toggle source
# File lib/hocho/inventory_providers/file.rb, line 15 def files @files ||= case when ::File.directory?(path) Dir[::File.join(path, "*.yml")] else [path] end end
hosts()
click to toggle source
# File lib/hocho/inventory_providers/file.rb, line 24 def hosts @hosts ||= files.flat_map do |file| content = Hocho::Utils::Symbolize.keys_of(YAML.load_file(file)) content.map do |name, value| Host.new( name.to_s, providers: self.class, properties: value[:properties] || {}, tags: value[:tags] || {}, ssh_options: value[:ssh_options], ) end end end