Need to Migrate all foreman Hosts to another OS

Ansible to the rescue! Just set the new OS and content source in a loop and rebuild them when you are ready:

https://docs.ansible.com/ansible/latest/collections/theforeman/foreman/host_module.html