Foreman with PuppetDB does not show any facts

Problem:
Foreman with PuppetDB installed does not show any facts of a node in Web-UI.
Report can be seen in Foreman, Facts are not shown.

Please see my problem with puppetdb-plugin before: Rubygem-puppetdb_foreman.noarch breaks foreman-rake - #5 by areyus … but this is somehow fixed, still no facts.

Expected outcome:
Foreman should show facts of a node in Web-UI.

Foreman and Proxy versions:
foreman-3.7.0-1.el8.noarch
foreman-cli-3.7.0-1.el8.noarch
foreman-debug-3.7.0-1.el8.noarch
foreman-dynflow-sidekiq-3.7.0-1.el8.noarch
foreman-installer-3.7.0-1.el8.noarch
foreman-postgresql-3.7.0-1.el8.noarch
foreman-proxy-3.7.0-1.el8.noarch
foreman-release-3.7.0-1.el8.noarch
foreman-selinux-3.7.0-1.el8.noarch
foreman-service-3.7.0-1.el8.noarch
puppet7-release-7.0.0-14.el8.noarch
puppet-agent-7.25.0-1.el8.x86_64
puppet-agent-oauth-0.5.10-1.el8.noarch
puppetdb-7.13.1-1.el8.noarch
puppetdb-termini-7.13.1-1.el8.noarch
puppetserver-7.12.0-1.el8.noarch
rubygem-foreman_puppet-6.0.0-1.fm3_7.el8.noarch
rubygem-hammer_cli_foreman-3.7.0-1.el8.noarch
rubygem-hammer_cli_foreman_puppet-0.0.6-1.fm3_4.el8.noarch
rubygem-puppetdb_foreman-6.0.2-1.fm3_7.el8.noarch

Foreman and Proxy plugin versions:
see above

Distribution and version:
AlmaLinux 8.8

Other relevant data:
I have this in my puppet.conf:

[main]
...  
  reports = foreman,puppetdb
...
[server]
...
  storeconfigs = true
  storeconfigs_backend = puppetdb
...

puppetdb.log during puppet-run of node:

2023-08-07T23:45:44.184+02:00 INFO  [p.p.command] [309-1691444744121-1691444744111] [33 ms] 'replace facts' command (57f38265) processed for <nodename-here>
2023-08-07T23:45:47.336+02:00 INFO  [p.p.command] [310-1691444747237-1691444747041] [46 ms] 'replace catalog' command (ee5faa14) processed for <nodename-here>
2023-08-07T23:46:10.310+02:00 INFO  [p.p.command] [311-1691444770171-1691444770133] [98 ms] 'store report' puppet v7.25.0 command (65d833d8) processed for <nodename-here>

So “replace facts”-command runs.

production.log during puppet-run of node:

2023-08-08T11:04:29 [I|app|f2604c4f] Started GET "/node/<nodename-here>?format=yml" for 192.168.***.*** at 2023-08-08 11:04:29 +0200
2023-08-08T11:04:29 [I|app|f2604c4f] Processing by HostsController#externalNodes as YML
2023-08-08T11:04:29 [I|app|f2604c4f]   Parameters: {"name"=>"<nodename-here>"}
2023-08-08T11:04:29 [I|app|f2604c4f]   Rendered text template (Duration: 0.0ms | Allocations: 1)
2023-08-08T11:04:29 [I|app|f2604c4f] Completed 200 OK in 38ms (Views: 0.4ms | ActiveRecord: 13.0ms | Allocations: 9578)

2023-08-08T11:04:54 [I|app|e51337d0] Started POST "/api/config_reports" for 192.168.***.*** at 2023-08-08 11:04:54 +0200
2023-08-08T11:04:54 [I|app|e51337d0] Processing by Api::V2::ConfigReportsController#create as JSON
2023-08-08T11:04:54 [I|app|e51337d0]   Parameters: {"config_report"=>"[FILTERED]", "apiv"=>"v2"}
2023-08-08T11:04:54 [I|app|e51337d0] Scanning report with: Foreman::PuppetReportScanner
2023-08-08T11:04:55 [I|app|e51337d0] Imported report for <nodename-here> in 699.6 ms, status refreshed in 7.0 ms
2023-08-08T11:04:55 [I|app|e51337d0]   Rendered api/v2/config_reports/create.json.rabl (Duration: 2.2ms | Allocations: 845)
2023-08-08T11:04:55 [I|app|e51337d0] Completed 201 Created in 737ms (Views: 3.1ms | ActiveRecord: 334.5ms | Allocations: 196816)

How do I configure foreman to show facts with puppetdb enabled ?
What am I missing ?

facts are updated into puppetdb, I can query them with curl (f.e. curl -X GET http://localhost:8080/pdb/query/v4/facts/operatingsystem)… but I don’t see them in Foreman.

I got the following things in /etc/puppetlabs/puppet/foreman.yaml:

---
:url: "https://<puppetmaster-hostname>
:ssl_ca: "/etc/puppetlabs/puppetserver/ca/ca_crt.pem"
:ssl_cert: "/etc/puppetlabs/puppet/ssl/certs/<puppetmaster-hostname>.pem"
:ssl_key: "/etc/puppetlabs/puppet/ssl/private_keys/<puppetmaster-hostname>.pem"
:puppetdir: "/opt/puppetlabs/server/data/puppetserver"
:puppetuser: "puppet"
:facts: true
:fact_extension: "json"
:timeout: 60
:report_timeout: 60
:report_retry_limit: 1
:threads: null

If I understood it right “puppetdir” there should be the same as “vardir” in puppet.conf, which is the case.
puppet.conf:

...
[server]
    autosign = /etc/puppetlabs/puppet/autosign.conf { mode = 0664 }
    ca = true
    certname = <puppetmaster-hostname>
    external_nodes = /etc/puppetlabs/puppet/node.rb
    logdir = /var/log/puppetlabs/puppetserver
    node_terminus = exec
    parser = current
    rundir = /var/run/puppetlabs/puppetserver
    ssldir = /etc/puppetlabs/puppet/ssl
    storeconfigs = true
    storeconfigs_backend = puppetdb
    strict_variables = false
    vardir = /opt/puppetlabs/server/data/puppetserver

fast_extension is json, since puppet7 json is used instead of yaml, right ?

But after installing puppetdb the facts of my agents/nodes are written to yaml in /opt/puppetlabs/server/data/puppetserver/yaml/facts/

json should be written to /opt/puppetlabs/server/data/puppetserver/server_data/facts … but no agents/nodes’ facts are there, only the puppetmaster itself.

It seems that Foreman expects facts in json, but puppet writes them in yaml.
How do I change that and will that solve my problem ?

I found the solution myself:

my routes.yaml was configured to “cache: yaml” … I had to change it to “cache: json”.
Now Foreman get the updated facts too.

##### wrong routes.yaml ##### 
---
master:
  facts:
    terminus: puppetdb
    cache: yaml

##### corrected routes.yaml ##### 
---
master:
  facts:
    terminus: puppetdb
    cache: json