If Locations and/or Organizations are enabled, Foreman assigns Organization and Location to discovered hosts according to the following rules from top to bottom:
According to the discovery_organization or discovery_location , if present. These can be set under Administer > Settings > Discovered .
If foreman_organization or foreman_location fact is present, set accordingly. Fact names which are looked up can be configured in Administer > Settings > Puppet section as Organization/Location fact setting.
If Subnet was determined for particular discovered host, use the first Organization and Location associated with the Subnet.
Select the first Organization / Location ordered by title (name the org/loc was created with). This is a workaround until we fix provisioning of discovered hosts without taxonomy.
Organization or Location can be changed via the “bulk actions” menu which appears once once or more discovered hosts are selected.
This is what’s currently implemented. It’s not ideal, but it is what it is.
I found the issue. It seems the foreman_location fact is set to Default Location. That’s why the subnet setting is not working.
But where does Foreman get this value from? The default is “not set”.
If Locations and/or Organizations are enabled, Foreman assigns Organization and Location to discovered hosts according to the following rules from top to bottom:
According to the discovery_organization or discovery_location , if present. These can be set under Administer > Settings > Discovered .
If Subnet was determined for particular discovered host, use the first Organization and Location associated with the Subnet.
Select the first Organization / Location ordered by title (name the org/loc was created with). This is a workaround until we fix provisioning of discovered hosts without taxonomy.
Here is the relevant code:
Very likely you have this location set to the subnet which is detected, therefore it pick it. Also note that it picks “first” location. This is lame, if you have multiple locations it will pick “random” location (!). I know, this is terrible. Proper solution requires UI/CLI/API changes, I’d probably delay this until we merge discovery into core which we are considering.