Class: LoomExt::CoreFacts::FacterProvider

Inherits:
Loom::Facts::Provider show all
Defined in:
lib/loomext/corefacts/facter_provider.rb

Instance Attribute Summary

Attributes inherited from Loom::Facts::Provider

#fact_map, #namespace

Instance Method Summary collapse

Methods inherited from Loom::Facts::Provider

create_fact_providers, #disable, disable_for_host, disabled_for_host?, register_factory

Constructor Details

#initialize(host_spec, shell) ⇒ FacterProvider

Returns a new instance of FacterProvider.



8
9
10
11
12
13
# File 'lib/loomext/corefacts/facter_provider.rb', line 8

def initialize(host_spec, shell)
  @has_facter = shell.test :which, "facter"
  disable(host_spec) unless @has_facter
  @shell = shell
  @namespace = :facter
end

Instance Method Details

#collect_factsObject



15
16
17
18
19
20
21
22
23
# File 'lib/loomext/corefacts/facter_provider.rb', line 15

def collect_facts
  unless @has_facter
    Loom.log.error "facter not installed"
    return {}
  end

  yaml_facts = @shell.capture :facter, "--yaml"
  yaml_facts.nil? ? {} : YAML.load(yaml_facts)
end