Bug #37602
Updated by Bernhard Suttner 7 months ago
If you register a host using the new Host Registration approach, approach AND a selected HostGroup which uses an Operatingsystem + Installation Medium, a host is generated using the subscription-manager. This will create a OS in foreman but this new OS doesn’t have the installation media assigned (because its a new OS). If you do this Thefore next steps during host registration fail and you selected a HostGroup which uses an Operatingsystem + Installation Medium, it will exit with: <pre> The system has been registered with ID: 21312a8f-1b6e-4302-ae9e-1a64b643c6f8 The registered system name is: myra-bergh.master.dev.atix ERROR: Validation failed: Medium must belong to host's operating system </pre> It fails because of this validation during during the Host Init Config template rendering started because of the register_katello_host POST request: <pre> validates :medium_id, :presence => true, :if => proc { |host| host.validate_media? } validates :medium_id, :inclusion => {:in => proc { |host| host.operatingsystem.medium_ids }, :message => "must belong to host\'s operating system"}, :if => proc { |host| host.operatingsystem && host.medium } </pre> Analyzed the issue: During registration # A host group is set in the HostReg formular * This host group has an assigned OS * This host group has an assigned Installation Media * A OS is set in the formular (Alma 8.X) (not really related to this issue) # subscription-manager registers and * the OS is created on foreman (Alma 8.10) based on the sent facts * this OS (Alma 8.10) doesn’t have a installation media The OS, which is set in the formular is NOT send in the POST to foreman (maybe an issue - but maybe correct) (1) The Host group is now used and same options are tried to be used in the Host Init POST request. The issue does now occur, because the assigned OS (Alma 8.10) for the host does NOT include the installation media, which is part of the Host Group. (1) if the OS is pushed in the POST in the global registration template (register_katello_host method) than everything works BUT it will create a OS “Alma 8.10” and later assign Alma 8.X to this host - means, a OS is generated which will then not be used. Notice: - if the Hostgroup doesn't have a Operatingsystem OR Installation Media -> everything works - If the Operatingsystem of the Host, is already configured on foreman, including valid Installatin Media -> everything works