Errors running foreman-rake db:migrate during Foreman 2.1 upgrade

Problem:
I am following the Foreman 2.1 upgrade guide at Foreman :: Manual

Packages update just fine, but when I do a “foreman-rake db:migrate”, here’s what happens:

[root@foreman2 ~]# foreman-rake db:migrate
API controllers newer than Apipie cache! Run apipie:cache rake task to regenerate cache.
rake aborted!
PG::ConnectionBad: fe_sendauth: no password supplied
/opt/theforeman/tfm/root/usr/share/gems/gems/pg-1.1.4/lib/pg.rb:56:in initialize' /opt/theforeman/tfm/root/usr/share/gems/gems/pg-1.1.4/lib/pg.rb:56:in new’
/opt/theforeman/tfm/root/usr/share/gems/gems/pg-1.1.4/lib/pg.rb:56:in connect' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/postgresql_adapter.rb:46:in postgresql_connection’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:887:in new_connection' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:931:in checkout_new_connection’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:910:in try_to_checkout_new_connection' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:871:in acquire_connection’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:593:in checkout' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:437:in connection’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:1119:in retrieve_connection' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_handling.rb:221:in retrieve_connection’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/connection_handling.rb:189:in connection' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/tasks/database_tasks.rb:238:in migrate’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:86:in block (3 levels) in <top (required)>' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:84:in each’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.1/lib/active_record/railties/databases.rake:84:in block (2 levels) in <top (required)>' /opt/rh/rh-ruby25/root/usr/share/gems/gems/rake-12.3.0/exe/rake:27:in <top (required)>’
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Expected outcome:

No errors

Foreman and Proxy versions:

Foreman 2.0

Foreman and Proxy plugin versions:

Distribution and version:

CentOS 7.8

Other relevant data:

I am running the upgrade as “root.” Which pgsql credentials are missing? I checked file /etc/foreman/database.yml and no user/password is specified there. Is that normal?

No database.yml should have credentials in it. Did you set user/pass outside of foreman installer so it “overwrote” it back to empty? I’d manually fix up database.yml or rerum foreman installer to get it “right” so it can connect to your database properly and retry if foreman installer doesn’t do it automatically!

Good luck!

Jason,

I did not set pgsql outside of the foreman-installer. Nor have I made any changes to file /etc/foreman/database.yml.

When I run “foreman-installer --noop --dont-save-answers --verbose”, I get a similar warning, regarding missing pgsql credentials:

[ WARN 2020-12-21T18:53:53 verbose] /etc/foreman-installer/custom-hiera.yaml: file does not contain a valid yaml hash
[ WARN 2020-12-21T18:53:56 verbose] This method is deprecated, please use postgresql::postgresql_password instead.

See attached for complete output.

My question remains: What is the correct way to specify the Postgresql username and password when running foreman-installer (or foreman-rake db:…)

Thanks.

-jm

I discovered the problem:

Files “database.yml” and “settings.yml” in directory “/etc/foreman/” had been replaced with the rpm default versions during the package update portion of the Foreman 2.1 upgrade. Once I restored them from backup, “foreman-rake db:migrate” and “foreman-installer” run and complete normally.

I am now running Foreman v2.1.