Problem to import new node into foreman

Problem:
Hi,
I have foreman 1.23.1 with pupptserver 6.7.2 installed on same host. Everything works fine except the import of new node in foreman.
I have an external host, I installed puppet and configure puppet.conf to retrieve configuration form my puppterserver/foreman node. After the first puppet run execution, in the puppterserver host I sign the certificate with puppetserver ca sign --certificate ceph-node-02.pn.pd.infn.it. I restart httpd service. I find in foreman database the new host but I can not see that host in web interface.
In foreman settings I have:

  • Foreman will create the host when new facts are received (yes)
  • Foreman will create the host when a report is received (yes)

I can run /etc/puppetlabs/puppet/node.rb ceph-node-02.pn.pd.infn.it
If I try to add new node from web interface or use hammer I have this error: Name has already been taken

In production log I have this Warning:
2020-01-13T13:39:14 [I|app|415478d6] Started POST “/api/hosts/facts” for 193.206.210.248 at 2020-01-13 13:39:14 +0100
2020-01-13T13:39:14 [I|app|415478d6] Processing by Api::V2::HostsController#facts as JSON
2020-01-13T13:39:14 [I|app|415478d6] Parameters: {“facts”=>"[FILTERED]", “name”=>“ceph-node-02.pn.pd.infn.it”, “certname”=>“ceph-node-02.pn.pd.infn.it”, “apiv”=>“v2”, “host”=>{“certname”=>“ceph-node-02.pn.pd.infn.it”, “name”=>“ceph-node-02.pn.pd.infn.it”}}
2020-01-13T13:39:14 [I|app|415478d6] Import facts for ‘ceph-node-02.pn.pd.infn.it’ completed. Added: 0, Updated: 6, Deleted 0 facts
2020-01-13T13:39:14 [W|app|415478d6] Action failed
| NoMethodError: undefined method fetch' for #<String:0x00007f01955ff7b0> | /usr/share/foreman/app/services/puppet_fact_parser.rb:137:inboot_timestamp’
| /usr/share/foreman/app/models/host/base.rb:237:in set_reported_data' | /usr/share/foreman/app/models/host/base.rb:188:inpopulate_fields_from_facts’
| /usr/share/foreman/app/models/host/managed.rb:415:in populate_fields_from_facts' | /usr/share/foreman/app/models/concerns/puppet_host_extensions.rb:3:inpopulate_fields_from_facts’
| /usr/share/foreman/app/models/host/base.rb:167:in block in parse_facts' | /usr/share/foreman/app/services/foreman/telemetry_helper.rb:27:intelemetry_duration_histogram’
| /usr/share/foreman/app/models/host/base.rb:166:in parse_facts' | /usr/share/foreman/app/models/host/base.rb:152:inimport_facts’
| /usr/share/foreman/app/models/host/managed.rb:329:in import_facts' | /usr/share/foreman/app/controllers/api/v2/hosts_controller.rb:306:infacts’
| /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/action_controller/metal/basic_implicit_render.rb:6:in send_action' | /opt/theforeman/tfm-ror52/root/usr/share/gems/gems/actionpack-5.2.1/lib/abstract_controller/base.rb:194:inprocess_action’

Expected outcome:
I expect to see the host in hosts tab

Foreman and Proxy versions:
foreman 1.23.1 foreman-proxy 1.23.1

Foreman and Proxy plugin versions:

Distribution and version:
Centos 7

Other relevant data:

Hi and welcome to the forum :slight_smile:

The host probably got created in Foreman without an organization/location associated to it.
On tho hosts page, use the drop-down menus in the to bar (on the right of the Foreman logo) and select “Any location” and “Any organization”. After that, you should be able to see the host and assign them to the correct organization and location.
Pleas try that and report back if that fixed your issue.

Regards

Hi,
yes. The problem has been fixed. The host has not the correct organization and location (default one). I change the organization and the location and now the I can see the host and manage it. I observe in the hosts page, the new host after puppet agent runs, the O.S. is blank but the column last report is correct. If I edit the new host the reports and facts button has not been updated in web interface.I have No entries found.
Thanks a lot.

Not entirely sure on this one, but I think the underlying cause is the same. When a system is imported from facts/reports, Foreman automatically generates some things like the OS entry if it does not exist yet. You could check on the OS page with any org/any loc and associate that accordingly (you might have to do that for some other things, too). I would guess the reports also got created without the right context, but new ones should come in fine.
Regards

Hi,
I try many things but no ones works.
For all my hosts in foreman Web gui if I click on and enter into the host if I try to click to Facts or Reports I have no entries but if I change Any location and any organization I see everithings (facts and reports).
I try to move facts or reports in Default location or organization but there is no way to do that. I try to put in one or more host the facters:
shell> facter | grep org
foreman_organization => Default organization
organization_fact => Default organization
shell> facter | grep loc
foreman_location => Default location
location_fact => Default location

but also that is not enough to see the reports or facts from gui.
I look in configuration but all my settings seems correct. In log files I have no warning and no errors.
I try to have a look to the files in /usr/share/foreman/app/views/config_reports or in /usr/share/foreman/app/views/fact_values/ but without success.

Any hints?