Foreman Clone/Merge/Sync to a new host?

I tried using the foreman-rake db:dump command and then on another host doing the foreman-rake db:import_dump file=/your/db/dump/location. The problem with that is it drops everything and replaces everything. I am looking for more of a merge that would leave everything and just add the new stuff.
Or at least that would work the first time. If you did it again later I wouldn’t want to duplicate things.

I am not sure if the database level is the best place to do this or if there is a better way to export everything and import/merge/sync to a new host?

I think I am looking for something like the Templates plugin only for the entire Foreman metadata.

I would like to be able to export Domains, Subnets, Operating Systems, etc. and import then into another host.

I would like to basically keep 2 foreman servers mostly identical that can be used for failover for each other.

I am trying to do that so that I can get from 1.16 to the current version and not lose anything.

I am wondering if doing a different kind of database export/import might work of if I should look at the hammer command or something else?

Thanks for any suggestions!


My suggestion here would be indeed hammer. Import / Export on the database level would produce a lot of problems to speak from my own experience.

Regarding failover I see two different points. Traditional failover would be kind of loadbalancing or something like that. If you just want to spin up a second foreman in case of failure then a simple backup or rsync would be my solution.

Would it be an option to manage the Foreman instance configuration using
Ansible playbook or similar tool? If there is no need to sync the live data
such as hosts and reports I can imagine some cases where this could be

I wish there was a hammer domain export and a hammer domain import and hammer subnet export and hammer subnet import or even something like hammer configuration export and hammer configuration import that would do most/all of the settings. The problem is kind of the same. You have a source and target servers and you don’t really want to step on the target server. I pretty much have the foreman install scripted, my struggle is all of this metadata or configuration data like domains and subnets and os, etc. The export would need to go to some kind of ascii file that you could edit if needed. It is easy enough to run hammer domain list.

hammer --csv domain list|grep -v ^Id|awk -F, ‘{print $2}’ >domain.txt
It would be nice to have a --noheader for the hammer command.
while read domain
hammer domain create --name $domain
done <domain.txt

Ansible was also something that someone suggested. I am pretty new to Ansible as well, so I would need to learn it.

Any other ideas?

Thanks again for everyone’s help!

Yeah, that’s exactly how I configure Foreman.
I would recommend this repo:

It’s not perfectly up to date with the latest Foreman API, however, it’s fairly close and it’s pretty easy to add in the missing stuff.