Katello on existing foreman


I would like to know how i could “migrate” an existing foreman to a Katello server.
I read the docs and know it isn’t supported but still i would like to try to see if it’s possible on my sandbox environment.

I didn’t find so much resources so i don’t know if anyone ever tried. So what could be the best lead so far to begin to dig?

Any insight is welcome.
Thank you :slight_smile:

The easiest way is to simply install a new Katello, import the database and then run foreman-rake db:seed and foreman-rake db:migrate. Make sure that orgs and locations are already enabled in your pure Foreman instance.

But isn’t the foreman database different from Katello database? If i import the foreman existing database into Katello it would overwrite all the Katello specified tables or am i wrong?
Is it a special way of importing?

Rails will detect that your schema does not contain the katello tables and add them when you run foreman-rake db:migrate.

There is an import/export plugin which creates *.csv files. It seems to run rather without issues even in big environments.

This way you avoid database issues but sometimes you face new required fields or something like that. Depends on the size of your jump from version to version.

Seems to be hammer-cli-csv but this tool needs katello dependencies. I don’t think it can work on a standalone foreman? does it?

Afaik it works with foreman standalone because hammer does but I’ve never tested it without Katello

So far:
DB method : I got plenty of errors as i would have expected from the dump here is the log if you are curious
Nevertheless, if i continue the db:seed detect correctly that the database need some migration and prompt this list
But then, the migrate fail because of constraints on existing tables.
I tried tot drop the database before but with no success since the import_dump task need the ‘foreman’ named database to be existing.

Hammer method : i only manage to export settings from foreman. i’m still trying to get a grasp of how to use the tool to generate a full dump of the database objects.

Can you restore the database on an instance without Katello?
What I did was to use a foreman instance and a katello instance. Both were connected to the same database. First I got the foreman instance running, then I shut down the foreman instance, started the katello one and ran db:migrate and db:seed.
I believe you might have issues because your database is already migrated and you try to restore a dump that does not match your schema. But that’s just a wild guess to be honest.

Little update : I found a way to continue with the database dump solution.
I just drop the foreman database and then recreate it using db:create (it didn’t work before because i didn’t ALTER USER foreman CREATEDB; prior to the db:create command)
The migrate do stuff but stuck once on the 20141209103005 DisownForemanTemplates step wich i debugged using a fix found in an old IRC conversation log (https://botbot.me/freenode/theforeman-dev/2018-06-21/?page=2)
Now i’m stuck in another migration step but i don’t find any ressource on it.

== 20160404132250 RemoveKatelloFromNotificationName: migrating ================
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

Invalid single-table inheritance type: ConfigManagementError is not a subclass of RemoveKatelloFromNotificationName::FakeMailNotification

full log here : https://pastebin.com/JdbyXRS7

I bet i need to modifiy some stuff in db/migrate/20160404132250_remove_katello_from_notification_name.rb in order for this step to pass but i’m not fluent enough in ruby to decipher what.

Do you have any idea?

Time for another update.

So i’ve found a workaround to make it work more properly just by adding

self.inheritance_column = nil

in the class definition header of

@devs Is it a clean enough workaround? Or does it break stuff?

The interface is working properly and after copying the encryption key located in /etc/foreman/encryption_key.rb i’m able to connect using LDAP.

I can see my hosts and stuff, but they are all out of sync.
Next step is to correct that.

The content panel didn’t work, it redirect me to a foreman error page.

A simple
foreman-installer --scenario katello --upgrade
correct it all.

New trouble : I can now acess to the Content panel, wich is good, so i’m trying to add a new product but when i input a name and label i get this error.

The dynflowd daemon is running but i got strange outputs in the /var/log/foreman/dynflow_executor.log

["/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/monitor.rb:55:in sleep'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/monitor.rb:55:inblock in watch’", “/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/monitor.rb:42:in loop'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/monitor.rb:42:inwatch’”, “/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/monitor.rb:66:in block in start_with_pidfile'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/monitor.rb:61:infork’”, “/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/monitor.rb:61:in start_with_pidfile'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/monitor.rb:92:instart’”, “/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/application_group.rb:141:in create_monitor'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/application.rb:283:instart’”, “/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/controller.rb:56:in run'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons.rb:193:inblock in run_proc’”, “/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/cmdline.rb:88:in catch_exceptions'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons.rb:192:inrun_proc’”, “/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.0.5/lib/dynflow/rails/daemon.rb:72:in block in run_background'", "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.0.5/lib/dynflow/rails/daemon.rb:71:intimes’”, “/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.0.5/lib/dynflow/rails/daemon.rb:71:in run_background'", "/usr/sbin/dynflowd:71:inblock in '”, “/usr/sbin/dynflowd:67:in chdir'", "/usr/sbin/dynflowd:67:in'”]

Moreover, when i try to force the foreman-tasks to run i get this :
~]# RAILS_ENV=production runuser -u foreman /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.13.2/bin/foreman-tasks run
/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in ``require': cannot load such file -- apipie/middleware/checksum_in_headers (LoadError)
from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:inrequire’
from /usr/share/foreman/config/application.rb:5:in<top (required)>’
from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:inrequire’
from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:inrequire’
from /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-0.13.2/bin/foreman-tasks:5:in

Do you have any clues?

The last error was irrelevant, it was because i was running on an old machine and my envs were not clean.

On a fresh install it works, except when i try to add a repo where it throw an error :

Could not find a smart proxy with pulp feature

I’m beginning to dig now about how to deal with this issue.
Any insight welcome :slight_smile: