Refactor #14035 - Redesign for discovered host

Idea: Remove STI from discovered host, creating a DiscoveryFacet ActiveRecord that is disconnected from host.
When provisioning the discovered host, all details are copied to a new Host::Managed object.


  • host is discovered
  • subnet is detected
  • organization/location is assigned
  • DiscoveryFacet record is created
  • user clicks on Provision
  • New Host form is rendered
  • user can use custom facts from PXE-less provisioning in both templates and puppet classes
  • once submitted, discovery orchestration hooks reboots/kexec
Steps to achieve this:
  • Remove the inheritance of discovered host from Host::Base.
    • The new object will inherit from Facets::Base.
    • Before provisioning, this facet will behave as a standalone entity. It will be connected to a host only after provisioning.
    • It should contain:
      • name
      • model
      • taxonomy
      • subnet (subnet_id itself, connection to interface will be created when provisioning)
      • facts (details below)
  • Migration to change existing Host::Discovered into DiscoveryFacet
    • Facts connected to the hosts will move into the new discovered facts format
  • Changes in Facts:
    • discovered host will have a connection to DiscoveryFactValue
      • DiscoveryFactValue will be the connection between fact_value and discovery facet, it contains:
        • fact_value_id
        • discovery_facet_id
      • Using DiscoveryFactValue we can reuse FactName/FactValue from Host.
  • When provisioning:
    1. A new Host::Managed instance is created by import_from_facts.
    2. Ip will be assigned (since the network setup is moved to provision stage).
    3. The discovery facet will be connected to a host (this allows us to keep some parts alive after provisioning - discovery facts, connection to discovery rule).

We also need to change the Foreman Facts API to fetch discovered facts (puppet facts have priority but when not found, we should return custom fact).