Client keeps getting created with wrong domain

Hello,

I provisioned a new host with the domain set to “foo.com” in the hostgroup. This host is visible in the Hosts view in Foreman, but does not report to foreman after installation.
Instead a second host appeared with the same hostname, but a different domain (bar.com). Thios domain is not configured in Foreman. Whenever I delete this host, it keeps getting recreated on every puppet run. The domain on the host is correct, checked with hostname and hostnamectl.

Where does this additional host/domain come from? How can I get rid of it? How can I make the correct host to report to foreman?

The name of the host comes from the report of the puppet run and is based on the certificate. This is created based on the certname in the puppet.conf. Can you check this, probably remove or correct the setting, recreate and sign the certificate? Afterwards it should run fine.

The domain name in certname in puppet.conf is correct (hostname.foo.com). Also the Subject in the certificate holds the right domain. So I don’t think it comes from there.
Any other clues?

This is from the foreman log. the certificate name is correct(newhost.foo.com). Where does that name parameter come from (newhost.bar.com)?

 2019-07-05T12:07:30 [I|app|1ba6a]   Parameters: {"facts"=>"[FILTERED]", "name"=>"newhost.bar.com", "certname"=>"newhost.foo.com", "apiv"=>"v2", "host"=>{"certname"=>"newhost.foo.com", "name"=>"newhost.bar.com"}}
2019-07-05T12:07:30 [I|app|1ba6a] Import facts for 'newhost.bar.com' completed. Added: 106, Updated: 0, Deleted 0 facts
2019-07-05T12:07:31 [I|aud|1ba6a] Nic::Managed (170) create event on name newhost.bar.com

The name attribute should come from the facts, so from hostname -f. Was the name changed and the service not restarted? Does /etc/hosts include a matching entry?

Thank you. This put me in the right direction.

hostname
newhost.foo.com
vs.
hostname -f 
newhost.bar.com