Override inherited Compute-Resource with Bare Metal

Problem:
Since >99% of our managed hosts are VMWare VMs, we have set our hostgroups up to default to deploying on VMWare VCenter.
Now and then, we have the requirement to install directly to Bare Metal, though.
The hosts basically work when explicitly selecting “Deploy On: Bare Metal”, but there are still some probems. For example, Foreman will report the host as beeing deployed on VMWare, all VM related fields in the UI are still there but just error out. When trying to clone such a host, Foreman will error out with “undefined method inlude? for nil:NilClass”. Thos are just the examples I stumpled upon today.

Expected outcome:
Being able to set a host to be deployed on Bare Metal even if the hostgroup defaults to a compute resource.

Foreman and Proxy versions:
1.22.2

Foreman and Proxy plugin versions:
Katello 3.12.3
foreman-hooks 0.3.15
foreman_scc_manager 1.6.3
foreman_snapshot_management 1.6.0

Distribution and version:
RHEL 7.8

Other relevant data:
I have not found anything related to this topic in the Release Notes of newer Foreman versions than ours. If I missed it, please point me to that :wink:
From what I remember, this problem has been there for quite some time. I also fiddled around with it a little bit, and from what I discovered, it looks like the root of this is the fact that “Bare Metal” is basically treated as compute_resource → nil/undef/whatever. When trying to override an inherited value with nil, Foreman will just “pull” the inheritance since the host’s own value is undefined.

Is there any way around this problem? TBH, I don’t feel like duplication our comple hostgroup setup for physical machines just to work around this.

Regards

We had to implement the “inherit” button for hostgroup flags that needs to be “reset” (set to nil) by user. So if you find those commits, you should be able to implement the same for this one as well.

Thanks for your reply.
I’m not sure though if I understand correctly what you are suggesting.
The “Deploy On” field already has the “inherit” button. Without using that, I can not select another option than the one predefined in the hostgroup.
When selecting Bare Metal there, I seam to encounter some sort of undefined behaviour though (just tested around with that a little).
Outcomes I got:

  1. Foreman still created a VM in the hostgroup defined compute resource
  2. The creation aborted with an error about the VMWare VirtBridge beeing nil
  3. The host was created and a VM was not, but Foreman still “assumed” it was a VMWare host and brought up the mentioned error from above when trying to interact with the non-existant VM

So from what I figured, your suggested solution is already there, but broken? Are was there additional logic implemented on other fields to explicitly allow for an override with nil?
Or, did I understand your suggestion wrong?

I believe this issue is a long time bug, though i haven’t been able to find it. Looks like this concern was even raised when compute resources were added to host groups initially:

Thanks for the Input.
From how I understand the PR discussion, it should have worked to override the compute resource on a per-host level, just not in a nested hostgroup scenario for the child hostgroups.
Since I could not find an issue about this, I opened a redmine ticket laying out the input from this thread: Bug #29701: Overriding inherrited Compute Resource from Hostgroup with nil (Bare Metal) does not work properly - Foreman

1 Like