Installation error with salt plugin

Attempting a clean install of foreman with the salt plugins and a remote salt master. Base install performed using “sudo foreman-installer” completes without issue. Next I run “sudo foreman-installer --enable-foreman-plugin-salt --enable-foreman-proxy-plugin-salt” as per the documentation and the installer’s standard out fails with the following errors:

[ERROR ] [configure] '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
[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]

Digging into /var/log/foreman-installer/foreman.log I see this problem:

2023-03-03 06:09:01 [DEBUG ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]: Starting to evaluate the resource (932 of 1389)
2023-03-03 06:09:01 [DEBUG ] [configure] Exec[foreman-rake-db:migrate](provider=posix): Executing check '/usr/sbin/foreman-rake db:abort_if_pending_migrations'
2023-03-03 06:09:01 [DEBUG ] [configure] Executing with uid=foreman: '/usr/sbin/foreman-rake db:abort_if_pending_migrations'
2023-03-03 06:09:07 [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-03-03 06:09:07 [DEBUG ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/unless: You have 7 pending migrations:
2023-03-03 06:09:07 [DEBUG ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/unless:   20211108211312 AddMissingPermissions
2023-03-03 06:09:07 [DEBUG ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/unless:   20211123170430 TasksSettingsToDslCategory
2023-03-03 06:09:07 [DEBUG ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/unless:   20220118160349 DropSaltHideRunSaltButtonSetting
2023-03-03 06:09:07 [DEBUG ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/unless:   20220321101835 RenameSshProviderToScript
2023-03-03 06:09:07 [DEBUG ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/unless:   20220331112719 AddSshUserToJobInvocation
2023-03-03 06:09:07 [DEBUG ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/unless:   20220406185204 FixSaltSettingCategoryToDsl
2023-03-03 06:09:07 [DEBUG ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/unless:   2021051713291621250977 AddHostProxyInvocations
2023-03-03 06:09:07 [DEBUG ] [configure] Exec[foreman-rake-db:migrate](provider=posix): Executing '/usr/sbin/foreman-rake db:migrate'
2023-03-03 06:09:07 [DEBUG ] [configure] Executing with uid=foreman: '/usr/sbin/foreman-rake db:migrate'
2023-03-03 06:09:14 [INFO  ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: rake aborted!
2023-03-03 06:09:14 [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-03-03 06:09:14 [INFO  ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns:
2023-03-03 06:09:14 [INFO  ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: Validation failed: Name has already been taken
2023-03-03 06:09:14 [INFO  ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: /usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord- `raise_validation_error'
2023-03-03 06:09:14 [INFO  ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: /usr/share/foreman/vendor/ruby/2.7.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
2023-03-03 06:09:14 [INFO  ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns:
2023-03-03 06:09:14 [INFO  ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: Caused by:
2023-03-03 06:09:14 [INFO  ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: ActiveRecord::RecordInvalid: Validation failed: Name has already been taken
2023-03-03 06:09:14 [INFO  ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: /usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord- `raise_validation_error'
2023-03-03 06:09:14 [INFO  ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: /usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord- `save!'

I’ve retried this multiple times with version 3.5, my most recent attempt I dropped down to 3.4 in hopes this behavior was specific to 3.5. I can run a clean install with --enable-foreman-proxy-plugin-salt with no errors, the errors appear specifically when adding --enable-foreman-plugin-salt.

Expected outcome:
Visible salt modules in web gui

Foreman and Proxy versions:
Foreman 3.4, Foreman-proxy 3.4

Foreman and Proxy plugin versions:

Distribution and version:
Ubuntu 20.04 LTS
Other relevant data:

If I manually re-run foreman-rake db:migrate as suggested by multiple older threads there is no positive effect. Restarting foreman or rebooting the server results in error banner:

ERF64-6496 [Foreman::MaintenanceException]: There are migrations pending in the system. ==== 

Again, I’ve only run those two foreman-installer commands so the only host visible under Hosts is the foreman server itself, same for the Operating Systems section. Previous runs I tried deleting the entry under Hosts dna Operating System but that didn’ help, I simply have no idea what “Name” its complaining about.

Manually running “foreman-rake db:migrate --trace” results in the following snippet

** Invoke db:migrate (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Invoke plugin:refresh_migrations (first_time)
** Invoke environment
** Execute plugin:refresh_migrations
** Execute db:migrate
== 20211108211312 AddMissingPermissions: migrating ============================
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

Validation failed: Name has already been taken
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord- `raise_validation_error'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord- `save!'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord- `block in save!'
/usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord- `block in with_transaction_returning_status'

I have the same issue on Debian 11.6 with Foreman 3.6.1.

Before Salt plugins I tried to install another plugins (sudo foreman-installer --enable-foreman-plugin-discovery, sudo foreman-installer --enable-foreman-proxy-plugin-discovery, sudo foreman-installer --enable-foreman-plugin-google) and all ended successfully.

Can someone explain to me why this is happening or where I am making a mistake during Salt plugins installation?

Same issue on CentOS 8 Stream and Foreman 3.7.0

I have the same error messages.

OS : AlmaLinux 8.8
Foreman : 3.6 and 3.7

I did things below, but still have the same error messages.

Any other ideas please?



I had the same issue on
Centos8 Stream
Foreman 3.7

Context : Server was installed wit 2 registered servers on it

It was a POC so I reinstalled it from scratch.

The issue disapeared with
same OS
Foreman Nightly
No server were registered

I may be wrong but :
It’s either related to the foreman version
migration can’t be done if some server are already registered.

Hi everyone,
a quick fix is to remove the permissions file. It is not critical for the Salt plugin to work. I think it should be enough to delete db/migrate/20211108211312_add_missing_permissions.rb until it is fixed.

Edit: I think it should actually be fixed. Try install a new foreman_salt version. The fixing commit is part of 15.2.1. It is only available in the nightly repos (this is why it works for @AlexD) though, so you need to install it from here:

1 Like

I opened packaging PRs for Salt 15.2.1 for Foreman 3.6 and 3.7 that just got merged. So this package will be available also on those systems, eventually.


Thanks @nadjaheitmann for the help!
It works fine after reinstalling the foreman salt plugin as follows. :slight_smile:

  • yum remove rubygem-foreman_salt.noarch
  • yum install /software/installers/Linux/foreman/rubygem-foreman_salt-15.2.1-1.fm3_8.el8.noarch.rpm
  • /usr/sbin/foreman-rake db:migrate
  • systemctl restart foreman