Class: ForemanAnsible::FactImporter

Inherits:
FactImporter
  • Object
show all
Defined in:
app/services/foreman_ansible/fact_importer.rb

Overview

Override methods from Foreman app/services/fact_importer so that Ansible facts are recognized in Foreman as ForemanAnsible facts. It supports nested facts.

Only relevant for 1.12 and lower versions

Instance Method Summary collapse

Constructor Details

#initialize(host, facts = {}) ⇒ FactImporter

Returns a new instance of FactImporter.



14
15
16
17
18
19
20
21
22
23
# File 'app/services/foreman_ansible/fact_importer.rb', line 14

def initialize(host, facts = {})
  # Try to assign these facts to the correct host as per the facts say
  # If that host isn't created yet, the host parameter will contain it
  @host = Host.find_by(:name => facts[:ansible_facts][:ansible_fqdn] ||
                                facts[:ansible_facts][:fqdn]) ||
          host
  @facts = normalize(facts[:ansible_facts])
  @original_facts = FactSparser.unsparse(facts[:ansible_facts])
  @counters = {}
end

Instance Method Details

#fact_name_classObject



10
11
12
# File 'app/services/foreman_ansible/fact_importer.rb', line 10

def fact_name_class
  ForemanAnsible::FactName
end