Hostgroup reverted to previous value by puppet facts

Hi all,

I’m having an issue with Foreman:
We are using Foreman as an ENC (we have 2 Foreman instances load balanced by HAProxy). We have node.rb installed on all our puppet masters (5 in total). We have recently re-installed a big bunch of our machines (1200) and we moved them to another hostgroup. After the re-installation, some of out machines (~1/3) went back to the previous hostgroup.

We have investigated a bit and this is what we think has happened:
During the re-install, the foreman instances where quite loaded and may have drop some connections from the puppet masters asking for the ENC information (including the hostgroup). The puppet masters may have then used the cached information from /var/lib/puppet/yaml/node/ containing the old hostgroup which was then pushed back to the foreman and updated to the wrong value.

Do you think something like this could happen?

From /usr/share/foreman/app/models/host/managed.rb:

def attributes_to_import_from_facts
    attrs = [:architecture, :hostgroup]
    if !Setting[:ignore_facts_for_operatingsystem] || (Setting[:ignore_facts_for_operatingsystem] && operatingsystem.blank?)
      attrs << :operatingsystem
    if !Setting[:ignore_facts_for_domain] || (Setting[:ignore_facts_for_domain] && domain.blank?)
      attrs << :domain

    super + attrs

Would it make sense to have a setting parameter like :ignore_facts_for_domain for the hostgroup?
Should I open a bug report or something?



it is possible that cached values were used instead of the updated ones. Right now, you can enable/disable updating domain from facts in Settings, under Provisioning tab. However, these settings are global and will apply to all your hosts. If restricting these settings to hostgroups is something you would like to see in Foreman, I would recommend opening a feature request in Redmine.