New Foreman 3.7 + Katello 4.9 installtion errors

I am doing new test installation ( not upgrade ) following instructions at Installing Foreman 3.7 Server with Katello 4.9 Plugin on RHEL/CentOS
I am running it on Rocky 8.8. Everything went well and installation was a success. Need to add some plugins. Ansible plugins were installed, no problems. Tried to install foreman-plugin-templates and got an error:
2023-07-07 11:45:49 [ERROR ] [configure] ‘/usr/sbin/foreman-rake db:migrate’ returned 1 instead of one of [0]
2023-07-07 11:45:49 [ERROR ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: change from ‘notrun’ to [‘0’] failed: ‘/usr/sbin/foreman-rake db:migrate’ returned 1 instead of one of [0]

Now I see this error no matter what I do with foreman-installer, including running it without any parameters.
I see this error reported in the older versions but not on this one.

Did I do something wrong? How bad this is? This a new installation, not in production.

Have you looked in the installer log? The exact command output should be in /var/log/foreman-installer/katello.log, though perhaps it’s been rotated to other files if you ran the installer again.

I will check it out in a few days once I get back to this project. Thanks!

Back to this project. Started again with freshly provisioned system. Got to the same point with the same error. Looking at the logs as suggested and I see these lines that seems to be relevant:

2023-07-21 11:53:36 [DEBUG ] [configure] Foreman::Rake[db:migrate]: Starting to evaluate the resource (1323 of 1575)
2023-07-21 11:53:36 [DEBUG ] [configure] Foreman::Rake[db:migrate]: Evaluated in 0.00 seconds
2023-07-21 11:53:36 [DEBUG ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]: Starting to evaluate the resource (1324 of 1575)
2023-07-21 11:53:36 [DEBUG ] [configure] Execforeman-rake-db:migrate: Executing check ‘/usr/sbin/foreman-rake db:abort_if_pending_migrations’
2023-07-21 11:53:36 [DEBUG ] [configure] Executing with uid=foreman: ‘/usr/sbin/foreman-rake db:abort_if_pending_migrations’
2023-07-21 11:54:05 [DEBUG ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/unless: Run bin/rails db:migrate to update your database then try again.
2023-07-21 11:54:05 [DEBUG ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/unless: You have 2 pending migrations:
2023-07-21 11:54:05 [DEBUG ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/unless: 20180627134929 ChangeLockSetting
2023-07-21 11:54:05 [DEBUG ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/unless: 20211122154929 TemplatesSettingsCategoryToDsl
2023-07-21 11:54:05 [DEBUG ] [configure] Execforeman-rake-db:migrate: Executing ‘/usr/sbin/foreman-rake db:migrate’
2023-07-21 11:54:05 [DEBUG ] [configure] Executing with uid=foreman: ‘/usr/sbin/foreman-rake db:migrate’
2023-07-21 11:54:26 [INFO ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: rake aborted!
2023-07-21 11:54:26 [INFO ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: StandardError: An error has occurred, this and all later migrations canceled:
2023-07-21 11:54:26 [INFO ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns:
2023-07-21 11:54:26 [INFO ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: PG::UndefinedColumn: ERROR: column settings.category does not exist
2023-07-21 11:54:26 [INFO ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: LINE 1: … IN (SELECT “settings”.“id” FROM “settings” WHERE “settings”…

There is lots of more lines in logs but they are somewhat similar.

I think it’s easier if you post the complete information: you wrote you want to add a plugin. Is this still the case? You is it a fresh installation and you are installing everything including the plugin?

What is the exact foreman-installer command causing the error?

What are the exact errors?

And from the foreman-installer katello.log post the related lines. The error shown by foreman-installer should be included. Your last log extract only contained DEBUG and INFO messages but not the actual error… It’s much easier if everything is in context…

Answering to @gvde:
I did yet another fresh install - provisioned new system with Rocky 8. Followed instructions at Installing Foreman 3.7 Server with Katello 4.9 Plugin on RHEL/CentOS, Did all the DNF commands, then ran this command first:
foreman-installer --scenario katello --foreman-initial-organization “My ORG” --foreman-initial-location “My Location” --foreman-initial-admin-username admin --foreman-initial-admin-password “password”
That was a success. Next:
foreman-installer --enable-foreman-plugin-ansible --enable-foreman-proxy-plugin-ansible
That was a success also. After that:
foreman-installer --scenario katello --foreman-proxy-tftp true
No problem there. Next was this one:
foreman-installer -v --scenario katello --enable-foreman-compute-vmware
Was OK also.
This one got me in trouble:
foreman-installer --scenario katello --enable-foreman-plugin-templates
That command failed as I reported in original post.
I included the relevant output from katello.log. The actual erros is close to the end of the post. I’ll repeat just these 2 lines from above here:
2023-07-21 11:54:26 [INFO ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: PG::UndefinedColumn: ERROR: column settings.category does not exist
2023-07-21 11:54:26 [INFO ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: LINE 1: … IN (SELECT “settings”.“id” FROM “settings” WHERE “settings”…

The “…” is not me deleting anything. This is direct cut-n-paste from the log.
My interpretaion - DB got out of order - undefined column. My question - is there a way to fix DB?
Frankly, not even sure if I need this plugin in the first place.

Thanks, for looking into it,

It’s really so much easier to read and recognize if you put code, logs and commands in preformatted blocks…

gets you this:

which has been fix here:

which isn’t in 9.3.0 but only 9.3.1 or 9.4.0. Neither version did make it into the release, yet.

I suppose @ekohl can help to clarify why there isn’t a newer version available…

OK. Thank you for the explanation. Is there a way to fix DB? I tried to remove the plugin in question, that did not work. I can only re-provision the system and stay away from this plugin till the fix is released.
Are there any other alternatives, or this would be the easiest solution?

The DB is O.K. It’s just the plugin trying to apply a database migration which has been applied before.

The fastest workaround would be to manually apply the commit. Look for the file db/migrate/20211122154929_templates_settings_category_to_dsl.rb which should be in /usr/share/gem/gems/ in the directory for the plugin, i.e. foreman_template-9.3.0.

Edit the file and apply the change from the commit. Then run foreman-installer again.

That worked! Thanks.
Just a minor correction in case others are running into this also - the path is /usr/share/gems/gems/foreman_templates-9.3.0/db/migrate

Thank you for you help!

It should be in 9.3.1: Fixes #36016 - Migration error 'column settings.category does not exist' · theforeman/foreman_templates@e4b7427 · GitHub

I see there’s 9.3.3 in Foreman 3.6 but 9.3.0 in 3.7.0. Probably an oversight in cherry picking:

cc @ofedoren @lstejskal