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

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- postgresql_connection’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord- new_connection' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord- checkout_new_connection’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord- try_to_checkout_new_connection' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord- acquire_connection’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord- checkout' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord- connection’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord- retrieve_connection' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord- retrieve_connection’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord- connection' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord- migrate’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord- block (3 levels) in <top (required)>' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord- each’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord- 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!


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:…)



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.