Centos7 Openscap plugin

Problem:
2022-04-11 21:30:34 [ERROR ] [configure] ‘/usr/sbin/foreman-rake db:migrate’ returned 1 instead of one of [0]
2022-04-11 21:30:34 [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]

Expected outcome:
Error free install

Foreman: 3.2.0
Katello 4.4
Distribution and version:
CentOS Linux release 7.9.2009 (Core)

Other relevant data:

2022-04-11 20:55:06 [NOTICE] [root] Loading installer configuration. This will take some time.
2022-04-11 20:55:10 [NOTICE] [root] Running installer with log based terminal output at level NOTICE.
2022-04-11 20:55:10 [NOTICE] [root] Use -l to set the terminal output log level to ERROR, WARN, NOTICE, INFO, or DEBUG. See --full-help for definitions.
2022-04-11 20:58:52 [NOTICE] [configure] Starting system configuration.
2022-04-11 21:01:19 [NOTICE] [configure] 250 configuration steps out of 1711 steps complete.
2022-04-11 21:02:17 [NOTICE] [configure] 500 configuration steps out of 1711 steps complete.
2022-04-11 21:02:20 [NOTICE] [configure] 750 configuration steps out of 1715 steps complete.
2022-04-11 21:04:18 [NOTICE] [configure] 1000 configuration steps out of 1722 steps complete.
2022-04-11 21:04:25 [NOTICE] [configure] 1250 configuration steps out of 1737 steps complete.
2022-04-11 21:06:21 [ERROR ] [configure] ‘/usr/sbin/foreman-rake db:migrate’ returned 1 instead of one of [0]
2022-04-11 21:06:21 [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]
2022-04-11 21:06:38 [ERROR ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]: Failed to call refresh: ‘/usr/sbin/foreman-rake db:migrate’ returned 1 instead of one of [0]
2022-04-11 21:06:38 [ERROR ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]: ‘/usr/sbin/foreman-rake db:migrate’ returned 1 instead of one of [0]
2022-04-11 21:06:46 [NOTICE] [configure] 1500 configuration steps out of 1737 steps complete.
2022-04-11 21:08:07 [NOTICE] [configure] System configuration has finished.

ok check it:
[root@test1 ~]# /usr/sbin/foreman-rake db:migrate
Apipie cache enabled but not present yet. Run apipie:cache rake task to speed up API calls.
== 20200803065041 MigratePortOverridesForAnsible: migrating ===================
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

uninitialized constant MigratePortOverridesForAnsible::AnsibleRole
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_openscap-5.2.1/db/migrate/20200803065041_migrate_port_overrides_for_ansible.rb:14:in transform_lookup_values' /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_openscap-5.2.1/db/migrate/20200803065041_migrate_port_overrides_for_ansible.rb:3:in up’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:831:in exec_migration' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:812:in block (2 levels) in migrate’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:811:in block in migrate' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:471:in with_connection’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:810:in migrate' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1002:in migrate’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1310:in block in execute_migration_in_transaction' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1361:in block in ddl_transaction’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in block in transaction' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/transaction.rb:280:in block in within_new_transaction’
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in block (2 levels) in synchronize' /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in handle_interrupt’
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in block in synchronize' /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in handle_interrupt’
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in synchronize' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/transaction.rb:278:in within_new_transaction’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in transaction' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:212:in transaction’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1361:in ddl_transaction' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1309:in execute_migration_in_transaction’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1281:in block in migrate_without_lock' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1280:in each’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1280:in migrate_without_lock' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1229:in block in migrate’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1382:in with_advisory_lock' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1229:in migrate’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1061:in up' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1036:in migrate’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/tasks/database_tasks.rb:238:in migrate' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/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.7/lib/active_record/railties/databases.rake:84:in each' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/railties/databases.rake:84:in block (2 levels) in <top (required)>’
/opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/exe/rake:27:in `<top (required)>’

Caused by:
NameError: uninitialized constant MigratePortOverridesForAnsible::AnsibleRole
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_openscap-5.2.1/db/migrate/20200803065041_migrate_port_overrides_for_ansible.rb:14:in transform_lookup_values' /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_openscap-5.2.1/db/migrate/20200803065041_migrate_port_overrides_for_ansible.rb:3:in up’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:831:in exec_migration' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:812:in block (2 levels) in migrate’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:811:in block in migrate' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:471:in with_connection’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:810:in migrate' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1002:in migrate’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1310:in block in execute_migration_in_transaction' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1361:in block in ddl_transaction’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in block in transaction' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/transaction.rb:280:in block in within_new_transaction’
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in block (2 levels) in synchronize' /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in handle_interrupt’
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in block in synchronize' /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in handle_interrupt’
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in synchronize' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/transaction.rb:278:in within_new_transaction’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in transaction' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:212:in transaction’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1361:in ddl_transaction' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1309:in execute_migration_in_transaction’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1281:in block in migrate_without_lock' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1280:in each’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1280:in migrate_without_lock' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1229:in block in migrate’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1382:in with_advisory_lock' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1229:in migrate’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1061:in up' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1036:in migrate’
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/tasks/database_tasks.rb:238:in migrate' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/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.7/lib/active_record/railties/databases.rake:84:in each' /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/railties/databases.rake:84:in block (2 levels) in <top (required)>’
/opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/exe/rake:27:in `<top (required)>’
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Any help appreciated :slight_smile:

Thanks
gyokiss

First update for myself

I had reinstalled clean and default (again) the OS.
Only change: till now: I have added
yum install centos-release-ansible-29.noarch

The default foreman install (without openscap ) goes well

foreman-installer --scenario katello
2022-04-11 22:41:02 [NOTICE] [root] Loading installer configuration. This will take some time.
2022-04-11 22:41:06 [NOTICE] [root] Running installer with log based terminal output at level NOTICE.
2022-04-11 22:41:06 [NOTICE] [root] Use -l to set the terminal output log level to ERROR, WARN, NOTICE, INFO, or DEBUG. See --full-help for definitions.
2022-04-11 22:45:13 [NOTICE] [configure] Starting system configuration.
2022-04-11 22:47:43 [NOTICE] [configure] 250 configuration steps out of 1691 steps complete.
2022-04-11 22:48:41 [NOTICE] [configure] 500 configuration steps out of 1691 steps complete.
2022-04-11 22:48:43 [NOTICE] [configure] 750 configuration steps out of 1695 steps complete.
2022-04-11 22:50:24 [NOTICE] [configure] 1000 configuration steps out of 1702 steps complete.
2022-04-11 22:50:30 [NOTICE] [configure] 1250 configuration steps out of 1717 steps complete.
2022-04-11 22:54:31 [NOTICE] [configure] 1500 configuration steps out of 1717 steps complete.
2022-04-11 22:57:45 [NOTICE] [configure] System configuration has finished.

now try to add ansible plugin with:
foreman-installer --enable-foreman-plugin-ansible --enable-foreman-proxy-plugin-ansible

After some some small issues ( why installer does not creates the neccessary keypair’s? Or at least why not documented? - for anybody who gets this error message:
2022-04-11 23:11:27 [ERROR ] [configure] Error making PUT request to https://test1.kc.local/api/v2/smart_proxies/1/refresh: Response: 500 Internal Server Error: Check /var/log/foreman/production.log on test1.kc.local for detailed information
2022-04-11 23:11:27 [ERROR ] [configure] /Stage[main]/Foreman_proxy::Register/Foreman_smartproxy[test1.kc.local]/features: change from [“Logs”, “Pulpcore”] to [“Ansible”, “Dynflow”, “Logs”, “Pulpcore”] failed: Error making PUT request to https://test1.kc.local/api/v2/smart_proxies/1/refresh: Response: 500 Internal Server Error: Check /var/log/foreman/production.log on test1.kc.local for detailed information
2022-04-11 23:11:27 [ERROR ] [configure] /Stage[main]/Foreman_proxy::Register/Foreman_smartproxy[test1.kc.local]: Failed to call refresh: Error making PUT request to https://test1.kc.local/api/v2/smart_proxies/1/refresh: Response: 500 Internal Server Error: Check /var/log/foreman/production.log on test1.kc.local for detailed information
2022-04-11 23:11:27 [ERROR ] [configure] /Stage[main]/Foreman_proxy::Register/Foreman_smartproxy[test1.kc.local]: Error making PUT request to https://test1.kc.local/api/v2/smart_proxies/1/refresh: Response: 500 Internal Server Error: Check /var/log/foreman/production.log on test1.kc.local for detailed information
2022-04-11 23:11:27 [NOTICE] [configure] 1750 configuration steps out of 1759 steps complete.
2022-04-11 23:11:30 [NOTICE] [configure] System configuration has finished.

don’t panic, just create the keys :
as written in logs.
ssh-keygen -t rsa -b 4096 -f /usr/share/foreman-proxy/.ssh/id_rsa_foreman_proxy -N ‘’`

and rerun the command:
foreman-installer --enable-foreman-plugin-ansible --enable-foreman-proxy-plugin-ansible

My next move:
foreman-installer --enable-foreman-plugin-openscap

2022-04-11 23:22:45 [NOTICE] [root] Loading installer configuration. This will take some time.
2022-04-11 23:22:50 [NOTICE] [root] Running installer with log based terminal output at level NOTICE.
2022-04-11 23:22:50 [NOTICE] [root] Use -l to set the terminal output log level to ERROR, WARN, NOTICE, INFO, or DEBUG. See --full-help for definitions.
2022-04-11 23:23:00 [NOTICE] [configure] Starting system configuration.
2022-04-11 23:23:08 [NOTICE] [configure] 250 configuration steps out of 1752 steps complete.
2022-04-11 23:23:11 [NOTICE] [configure] 500 configuration steps out of 1752 steps complete.
2022-04-11 23:23:11 [NOTICE] [configure] 750 configuration steps out of 1756 steps complete.
2022-04-11 23:23:37 [NOTICE] [configure] 1000 configuration steps out of 1762 steps complete.
2022-04-11 23:23:38 [NOTICE] [configure] 1250 configuration steps out of 1764 steps complete.
2022-04-11 23:26:28 [NOTICE] [configure] 1500 configuration steps out of 1764 steps complete.
2022-04-11 23:28:45 [NOTICE] [configure] 1750 configuration steps out of 1764 steps complete.
2022-04-11 23:28:50 [NOTICE] [configure] System configuration has finished.
Executing: foreman-rake upgrade:run

Upgrade Step 1/2: katello:correct_repositories. This may take a long while.

Upgrade Step 2/2: katello:clean_backend_objects. This may take a long while.
0 orphaned consumer id(s) found in candlepin.
Candlepin orphaned consumers:
Success!

Cool,
so step forward:
foreman-installer --enable-foreman-proxy-plugin-openscap
2022-04-11 23:29:22 [NOTICE] [root] Loading installer configuration. This will take some time.
2022-04-11 23:29:27 [NOTICE] [root] Running installer with log based terminal output at level NOTICE.
2022-04-11 23:29:27 [NOTICE] [root] Use -l to set the terminal output log level to ERROR, WARN, NOTICE, INFO, or DEBUG. See --full-help for definitions.
2022-04-11 23:29:37 [NOTICE] [configure] Starting system configuration.
2022-04-11 23:29:45 [NOTICE] [configure] 250 configuration steps out of 1767 steps complete.
2022-04-11 23:29:48 [NOTICE] [configure] 500 configuration steps out of 1767 steps complete.
2022-04-11 23:29:48 [NOTICE] [configure] 750 configuration steps out of 1770 steps complete.
2022-04-11 23:29:51 [NOTICE] [configure] 1000 configuration steps out of 1777 steps complete.
2022-04-11 23:29:51 [NOTICE] [configure] 1250 configuration steps out of 1779 steps complete.
2022-04-11 23:30:16 [NOTICE] [configure] 1500 configuration steps out of 1779 steps complete.
2022-04-11 23:30:28 [NOTICE] [configure] 1750 configuration steps out of 1779 steps complete.
2022-04-11 23:30:31 [NOTICE] [configure] System configuration has finished.
Executing: foreman-rake upgrade:run

Upgrade Step 1/2: katello:correct_repositories. This may take a long while.

Upgrade Step 2/2: katello:clean_backend_objects. This may take a long while.
0 orphaned consumer id(s) found in candlepin.
Candlepin orphaned consumers:
Success!

Long story short, or summary:
There is a dependency issue, for successful openscap plugin do I need first ansible plugin.

I have to test it, but it seems promising.
gyokiss

This openscap plugin should not depend on ansible plugin, it only adds few things if it finds the ansible plugin installed. However the detection seems to be broken and cause a failure in case the ansible plugin is not installed.

1 Like

could be caused by this patch Fixes #34385 - more reliable way of detecting Ansible plugin · theforeman/foreman_openscap@1301cd2 · GitHub perhaps it does not work reliably in the migration