Register Host is giving errors

Problem:
When I try to fill out the form, I get an error: “alert:Invalid field: Activation Keys”. If I go to the Advanced tab and select an Activation Key, then fill out some other fields (hostgroup), I get a different error: " alert:There was an error while loading the data, see the logs for more information"

I’m 101% sure it’s something I’m doing wrong. Like I don’t have a correct environment or something setup. But I’m not sure how to proceed. Mainly, I want a registration link I can use that assigns a host to the correct Hostgroup when not using the native PXE build. It used to work, but I haven’t tried it in a while (probably pre-3.0 release).

Expected outcome:
Be able to create a registration link

Foreman and Proxy versions:
3.2.0 with Katello

Foreman and Proxy plugin versions:

Distribution and version:
CentOS 8 Stream

@lstejska any thoughts?

Hi, can you upload the application log?

Which log would you need? /var/log/foreman/production.log? It doesn’t appear to produce anything when viewing the register host page.

Which log would you need? /var/log/foreman/production.log?

Yes this one

It doesn’t appear to produce anything when viewing the register host page.

There should be something when the form shows " alert:There was an error while loading the data, see the logs for more information".

So in the moment you got the error in the form you should see something in the application log.

There is nothing showing up in the production log when I navigate that page. But watching the chrome devtools, I am getting some 404 errors.

When I select the Organization, I see a successful request to:

/hosts/register/data?organization_id=1

When I then select the Location, I see a successful request to:

/hosts/register/data?organization_id=1&location_id=2

When I then select a Host group, I get 404 errors to two URLs:

/hosts/register/data?organization_id=1&location_id=2&hostgroup_id=11
/hosts/register/data?organization_id=1&location_id=2&hostgroup_id=11&operatingsystem_id=

That’s when the “There was an error while loading the data, see the logs for more information” error shows up.

Does that help at all?

Hmm, interesting,
for some reason the form is sending an empty operatingsystem_id
parameter. I’ll take a look at it.

I don’t think that’s the problem. The operating system field is blank at that point. If I select Organization, then Location, then operating system, there is a successful query to:

/hosts/register/data?organization_id=1&location_id=2&operatingsystem_id=16

Then when I select a Host Group, I again get two 404 queries:

/hosts/register/data?organization_id=1&location_id=2&hostgroup_id=11&operatingsystem_id=16
/hosts/register/data?organization_id=1&location_id=2&hostgroup_id=11&operatingsystem_id=

So it tries it once with the operatingsystem_id and then again with it blank. To me, it’s linked to something with the hostgroup_id rather than the operatingsystem_id.

Any ideas on this? I just updated to 3.2.1 as the release notes included something about registering hosts. But it has the same behavior. Is there possible something I’m missing in the Host Groups that’s required for this to work?

@lstejska is out this week. Can you double check that the hostgroup and all resources it’s linked to are actually assigned to such organization and location?

That was definitely the problem. None of my hostgroups had Location or Organization set. I’m surprised they showed up in the dropdown after selecting Location and Organization. I’m good to go now. I knew it was something I was doing wrong!

That’s a bug there, form should display host groups based on selected organization / location. However I am not able to reproduce the issue, both vanilla Foreman and Foreman+Katello don’t show host group if it’s not in the scope of selected org/loc.

Something fishy is happening there, can I ask you few questions?

  • Foreman user is admin or basic user?
  • What browser (and version) do you use?
  • What is user’s context - selected org/loc in the top menu?

My user account was not assigned a default location or organization, so it wasn’t using either. In my attempt to recreate the issue (created a new hostgroup with no location or organization), it’s not behaving the same way. When I select a location and organization, my ‘test’ hostgroup does not show up. So at least point, it’s behaving the way it’s supposed to.

I am using an admin user with Chrome browser.

This install has been upgraded several times (a later version of 2.x), so maybe those old hostgroups had some remnant confusing things?