Migration: How to migrate hosts between Foreman servers?

I have not added the kickstart repositories to the CentoOS 7 product I have for this host.
This host already exists and was registered on server B in this scenario, I am trying to migrate/register it on the new foreman (server A).
Could you provide the url’s of the repositories for the kickstart, I can’t find it on the internet.

After running the host registration script, the host appears as registered in the new Foreman.

The problem is that it doesn’t update the puppet configuration, which insists on fetching the old server.

See what happens when I rerun the host registration command.

#
# Running registration
#
subscription-manager is already installed!
This system is already registered. Use --force to override

sudo systemctl status puppet.service

$ sudo systemctl status puppet.service
● puppet.service - Puppet agent
   Loaded: loaded (/usr/lib/systemd/system/puppet.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2024-04-03 15:47:34 -03; 1h 7min ago
     Docs: man:puppet-agent(8)
 Main PID: 93418 (puppet)
   CGroup: /system.slice/puppet.service
           └─93418 /opt/puppetlabs/puppet/bin/ruby /opt/puppetlabs/puppet/bin/puppet agent --no-daemonize

Apr 03 16:17:36 sv-xxx-xxx.xxx.xxx puppet-agent[95754]: Server hostname 'puppet' did not match server certificate; expected sv-oldserver.xxx.xxx
Apr 03 16:17:37 sv-xxx-xxx.xxx.xxx puppet-agent[95754]: Could not retrieve catalog from remote server: Server hostname 'puppet' did not match server certificate; expected sv-oldserver.xxx.xxx
Apr 03 16:17:37 sv-xxx-xxx.xxx.xxx puppet-agent[95754]: Not using cached catalog because its environment 'Producao' does not match 'production'
Apr 03 16:17:37 sv-xxx-xxx.xxx.xxx puppet-agent[95754]: Could not retrieve catalog; skipping run
Apr 03 16:17:37 sv-xxx-xxx.xxx.xxx puppet-agent[95754]: Could not send report: Server hostname 'puppet' did not match server certificate; expected sv-oldserver.xxx.xxx
Apr 03 16:47:36 sv-xxx-xxx.xxx.xxx puppet-agent[97427]: Server hostname 'puppet' did not match server certificate; expected sv-oldserver.xxx.xxx
Apr 03 16:47:37 sv-xxx-xxx.xxx.xxx puppet-agent[97427]: Could not retrieve catalog from remote server: Server hostname 'puppet' did not match server certificate; expected sv-oldserver.xxx.xxx
Apr 03 16:47:37 sv-xxx-xxx.xxx.xxx puppet-agent[97427]: Not using cached catalog because its environment 'Producao' does not match 'production'
Apr 03 16:47:37 sv-xxx-xxx.xxx.xxx puppet-agent[97427]: Could not retrieve catalog; skipping run
Apr 03 16:47:37 sv-xxx-xxx.xxx.xxx puppet-agent[97427]: Could not send report: Server hostname 'puppet' did not match server certificate; expected sv-oldserver.xxx.xxx

When we register the host it is created in the Foreman web interface, but the fields below are empty.
After completing the host registration by filling in the information provided, the invalid media errors disappeared and the error changed, as we can see below.

Host > All Hosts > selected host > Edit
Environment
Puppet Proxy
Puppet CA Proxy
OpenSCAP Proxy

$ sudo systemctl status puppet.service
● puppet.service - Puppet agent
   Loaded: loaded (/usr/lib/systemd/system/puppet.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2024-04-03 15:47:34 -03; 1h 32min ago
     Docs: man:puppet-agent(8)
 Main PID: 93418 (puppet)
   CGroup: /system.slice/puppet.service
           └─93418 /opt/puppetlabs/puppet/bin/ruby /opt/puppetlabs/puppet/bin/puppet agent --no-daemonize

Apr 03 17:09:07 sv-xxx-xxx.xxx.xxx puppet-agent[93418]: Config file /etc/puppetlabs/puppet/puppet.conf changed; triggering re-parse of all config files.
Apr 03 17:09:37 sv-xxx-xxx.xxx.xxx puppet-agent[93418]: Config file /etc/puppetlabs/puppet/puppet.conf changed; triggering re-parse of all config files.
Apr 03 17:09:52 sv-xxx-xxx.xxx.xxx puppet-agent[93418]: Config file /etc/puppetlabs/puppet/puppet.conf changed; triggering re-parse of all config files.
Apr 03 17:17:22 sv-xxx-xxx.xxx.xxx puppet-agent[93418]: Config file /etc/puppetlabs/puppet/puppet.conf changed; triggering re-parse of all config files.
Apr 03 17:17:36 sv-xxx-xxx.xxx.xxx puppet-agent[100198]: certificate verify failed [self signed certificate in certificate chain for CN=Puppet Root CA: 5569ceac82999f]
Apr 03 17:17:37 sv-xxx-xxx.xxx.xxx puppet-agent[100198]: Could not retrieve catalog from remote server: certificate verify failed [self signed certificate in certificate chain for CN=Puppet Root CA: 5569ceac82999f]
Apr 03 17:17:37 sv-xxx-xxx.xxx.xxx puppet-agent[100198]: Not using cached catalog because its environment 'Producao' does not match 'production'
Apr 03 17:17:37 sv-xxx-xxx.xxx.xxx puppet-agent[100198]: Could not retrieve catalog; skipping run
Apr 03 17:17:37 sv-xxx-xxx.xxx.xxx puppet-agent[100198]: Could not send report: certificate verify failed [self signed certificate in certificate chain for CN=Puppet Root CA: 5569ceac82999f]
Apr 03 17:17:37 sv-xxx-xxx.xxx.xxx puppet-agent[93418]: Config file /etc/puppetlabs/puppet/puppet.conf changed; triggering re-parse of all config files.
[eduardo.cortez@sv-xxx-xxx ~]$
[eduardo.cortez@sv-xxx-xxx ~]$
[eduardo.cortez@sv-xxx-xxx ~]$ sudo puppet agent -t
Info: Using environment 'production'
Error: certificate verify failed [self signed certificate in certificate chain for CN=Puppet Root CA: 5569ceac82999f]
Info: Loading facts
Error: Could not retrieve catalog from remote server: certificate verify failed [self signed certificate in certificate chain for CN=Puppet Root CA: 5569ceac82999f]
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
Error: Could not send report: certificate verify failed [self signed certificate in certificate chain for CN=Puppet Root CA: 5569ceac82999f]

To resolve these certificate errors, I changed puppet.conf on the Foreman server by including the lines below:

[main]
ssldir = /etc/puppetlabs/puppet/ssl
certname = sv-xxx-xxx.xxx.xxx

[agent]
server = sv-xxx-xxx.xxx.xxx
report = true
certname = sv-xxx-xxx.xxx.xxx
environment = production

[master]
dns_alt_names = puppet,sv-xxx-xxx.xxx.xxx

Additionally, I re-generated the CA and all host certificates.