Project

General

Profile

Actions

Bug #33269

closed

Error in db:seed after 3.0.0rc1 upgrade

Added by Bret Wortman over 3 years ago. Updated over 3 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
DB migrations
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

After installing the RC1 for 3.0.0 and executing the follow-up steps, I snagged on running db:seed:

[root@foreman ~]# foreman-rake db:seed
User with login admin already exists, not seeding as admin.
rake aborted!
ActiveRecord::RecordInvalid: Validation failed: Operatingsystems can't assign operating system to Registration template
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/validations.rb:80:in `raise_validation_error'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/validations.rb:53:in `save!'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:318:in `block in save!'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:375:in `block in with_transaction_returning_status'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:278: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/transactions.rb:366:in `with_transaction_returning_status'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:318:in `save!'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/suppressor.rb:48:in `save!'
/usr/share/foreman/lib/seed_helper.rb:134:in `block in import_raw_template'
/usr/share/foreman/app/models/template.rb:73:in `ignore_locking'
/usr/share/foreman/lib/seed_helper.rb:134:in `import_raw_template'
/usr/share/foreman/lib/seed_helper.rb:140:in `block in import_templates'
/usr/share/foreman/lib/seed_helper.rb:139:in `each'
/usr/share/foreman/lib/seed_helper.rb:139:in `import_templates'
/usr/share/foreman/db/seeds.d/070-provisioning_templates.rb:9:in `block in <top (required)>'
/opt/theforeman/tfm/root/usr/share/gems/gems/audited-4.9.0/lib/audited/auditor.rb:376:in `without_auditing'
/usr/share/foreman/db/seeds.d/070-provisioning_templates.rb:2:in `<top (required)>'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in `load'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in `block in load'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:291:in `load_dependency'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in `load'
/usr/share/foreman/app/services/foreman_seeder.rb:51:in `block (3 levels) in execute'
/usr/share/foreman/app/models/concerns/foreman/thread_session.rb:108:in `as'
/usr/share/foreman/app/models/concerns/foreman/thread_session.rb:114:in `as_anonymous_admin'
/usr/share/foreman/app/services/foreman_seeder.rb:50:in `block (2 levels) in execute'
/usr/share/foreman/app/services/foreman_seeder.rb:44:in `each'
/usr/share/foreman/app/services/foreman_seeder.rb:44:in `block in execute'
/usr/share/foreman/lib/foreman/advisory_lock_manager.rb:20:in `block in with_transaction_lock'
/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'
/usr/share/foreman/lib/foreman/advisory_lock_manager.rb:17:in `with_transaction_lock'
/usr/share/foreman/app/services/foreman_seeder.rb:38:in `execute'
/usr/share/foreman/db/seeds.rb:14:in `<top (required)>'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in `load'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in `block in load'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:291:in `load_dependency'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in `load'
/usr/share/foreman/config/initializers/0_print_time_spent.rb:38:in `block in load'
/usr/share/foreman/config/initializers/0_print_time_spent.rb:17:in `benchmark'
/usr/share/foreman/config/initializers/0_print_time_spent.rb:38:in `load'
/opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.3.7/lib/rails/engine.rb:559:in `load_seed'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/tasks/database_tasks.rb:440:in `load_seed'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/railties/databases.rake:331: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:seed
(See full trace by running task with --trace)
[root@foreman ~]#

If this is expected behavior, no worries, but the documentation for the upgrade said that this should complete without errors so I didn't want to go any further without checking.


Related issues 1 (0 open1 closed)

Related to Foreman - Bug #32959: Registration migration - Unassign OS from registration templatesClosedLeos StejskalActions
Actions #1

Updated by Ewoud Kohl van Wijngaarden over 3 years ago

  • Project changed from Packaging to Foreman
  • Category set to DB migrations
  • Found in Releases 3.0.0 added
Actions #2

Updated by Tomer Brisker over 3 years ago

  • Related to Bug #32959: Registration migration - Unassign OS from registration templates added
Actions #3

Updated by Tomer Brisker over 3 years ago

This looks similar to #32959. Possibly due to your upgrade from nightly you had a previous version that assigned OSs to registration templates.
As a workaround, you could try manually unassigning all operating systems from all registration templates, or run

   registration_templates = ProvisioningTemplate.unscoped.where(template_kind: registration_kind)
   registration_templates.each { |rt| rt.operatingsystems = [] }

inside of the Foreman console.
After that, `db:seed` should finish successfully.

Actions #4

Updated by Bret Wortman over 3 years ago

I can't tell if this is getting me closer or not. I had to change the first command slightly (registration_templates instead of registration_kind):

[root@foreman ~]# foreman-rake console
registration_templates = ProvisioningTemplate.unscoped.where(template_kind: registration_templates)Loading production environment (Rails 6.0.3.7)
irb(main):001:0> registration_templates = ProvisioningTemplate.unscoped.where(template_kind: registration_templates)
irb(main):002:0> registration_templates.each { |rt| rt.operatingsystems = [] }
=> [#<ProvisioningTemplate id: 104, name: "schedule_reboot", template: "<%#\nkind: snippet\nname: schedule_reboot\nmodel: Pro...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 61, name: "alterator_pkglist", template: "<%#\nkind: snippet\nname: alterator_pkglist\nmodel: P...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:36", updated_at: "2021-05-11 16:43:36", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 62, name: "ansible_provisioning_callback", template: "<%#\nkind: snippet\nname: ansible_provisioning_callb...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:36", updated_at: "2021-05-11 16:43:36", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 63, name: "ansible_tower_callback_script", template: "<%#\nkind: snippet\nname: ansible_tower_callback_scr...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:36", updated_at: "2021-05-11 16:43:36", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 64, name: "ansible_tower_callback_service", template: "<%#\nkind: snippet\nname: ansible_tower_callback_ser...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:36", updated_at: "2021-05-11 16:43:36", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 65, name: "blacklist_kernel_modules", template: "<%#\nkind: snippet\nname: blacklist_kernel_modules\nm...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:36", updated_at: "2021-05-11 16:43:36", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 66, name: "bmc_nic_setup", template: "<%#\nkind: snippet\nname: bmc_nic_setup\nmodel: Provi...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:36", updated_at: "2021-05-11 16:43:36", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 67, name: "built", template: "<%#\nkind: snippet\nname: built\nmodel: ProvisioningT...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:36", updated_at: "2021-05-11 16:43:36", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 141, name: "gui_packages", template: "<%#\nkind: snippet\nname: gui_packages\nmodel: Provis...", snippet: true, template_kind_id: nil, created_at: "2021-05-27 12:11:02", updated_at: "2021-05-27 15:08:21", locked: false, default: true, vendor: nil, type: "ProvisioningTemplate", os_family: nil, description: "">, #<ProvisioningTemplate id: 68, name: "chef_client", template: "<%#\nkind: snippet\nname: chef_client\nmodel: Provisi...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:36", updated_at: "2021-05-11 16:43:36", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: "this is a single entry point for chef-client boots...">, #<ProvisioningTemplate id: 69, name: "coreos_cloudconfig", template: "#cloud-config\n<%#\nkind: snippet\nname: coreos_cloud...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:36", updated_at: "2021-05-11 16:43:36", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 70, name: "create_users", template: "<%#\nname: create_users\nmodel: ProvisioningTemplate...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:36", updated_at: "2021-05-11 16:43:36", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 71, name: "csr_attributes.yaml", template: "<%#\nkind: snippet\nname: csr_attributes.yaml\nmodel:...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:36", updated_at: "2021-05-11 16:43:36", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 72, name: "efibootmgr_netboot", template: "<%#\nkind: snippet\nname: efibootmgr_netboot\nmodel: ...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:36", updated_at: "2021-05-11 16:43:36", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: "Configure booting from network in EFI">, #<ProvisioningTemplate id: 73, name: "eject_cdrom", template: "<%#\nkind: snippet\nname: eject_cdrom\nmodel: Provisi...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:36", updated_at: "2021-05-11 16:43:36", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 74, name: "epel", template: "<%#\nkind: snippet\nname: epel\nmodel: ProvisioningTe...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:36", updated_at: "2021-05-11 16:43:36", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 75, name: "fips_packages", template: "<%#\nkind: snippet\nname: fips_packages\nmodel: Provi...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:36", updated_at: "2021-05-11 16:43:36", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 76, name: "fix_hosts", template: "<%#\nkind: snippet\nname: fix_hosts\nmodel: Provision...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:36", updated_at: "2021-05-11 16:43:36", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 77, name: "freeipa_register", template: "<%#\nkind: snippet\nname: freeipa_register\nmodel: Pr...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 78, name: "http_proxy", template: "<%#\nkind: snippet\nname: http_proxy\nmodel: Provisio...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 79, name: "insights", template: "<%#\nkind: snippet\nname: insights\nmodel: Provisioni...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 80, name: "kickstart_ifcfg_bond_interface", template: "<%#\nname: kickstart_ifcfg_bond_interface\nmodel: Pr...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 81, name: "kickstart_ifcfg_bonded_interface", template: "<%#\nname: kickstart_ifcfg_bonded_interface\nmodel: ...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 82, name: "kickstart_ifcfg_generic_interface", template: "<%#\nname: kickstart_ifcfg_generic_interface\nmodel:...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 83, name: "yum_proxy", template: "<%#\nkind: snippet\nname: yum_proxy\nmodel: Provision...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 84, name: "kickstart_ifcfg_get_identifier_names", template: "<%#\nname: kickstart_ifcfg_get_identifier_names\nmod...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 85, name: "kickstart_kernel_options", template: "<%#\nkind: snippet\nname: kickstart_kernel_options\nm...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 86, name: "kickstart_networking_setup", template: "<%#\nname: kickstart_networking_setup\nmodel: Provis...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 87, name: "ntp", template: "<%#\nkind: snippet\nname: ntp\nmodel: ProvisioningTem...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 88, name: "preseed_networking_setup", template: "<%#\nkind: snippet\nname: preseed_networking_setup\nm...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: "this will configure your h11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 90, name: "puppet_setup", template: "<%#\nkind: snippet\nname: puppet_setup\nmodel: Provis...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: "this snippet will configure the Puppet agent">, #<ProvisioningTemplate id: 91, name: "puppetlabs_repo", template: "<%#\nkind: snippet\nname: puppetlabs_repo\nmodel: Pro...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 92, name: "pxegrub2_chainload", template: "<%#\nkind: snippet\nname: pxegrub2_chainload\nmodel: ...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 93, name: "pxegrub2_discovery", template: "<%#\nkind: snippet\nname: pxegrub2_discovery\nmodel: ...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 94, name: "pxegrub2_mac", template: "<%#\nkind: snippet\nname: pxegrub2_mac\nmodel: Provis...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 95, name: "pxegrub_chainload", template: "<%#\nkind: snippet\nname: pxegrub_chainload\nmodel: P...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 96, name: "pxegrub_discovery", template: "<%#\nkind: snippet\nname: pxegrub_discovery\nmodel: P...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 97, name: "pxelinux_chainload", template: "<%#\nkind: snippet\nname: pxelinux_chainload\nmodel: ...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 98, name: "pxelinux_discovery", template: "<%#\nkind: snippet\nname: pxelinux_discovery\nmodel: ...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 99, name: "rancheros_cloudconfig", template: "<%#\nkind: snippet\nname: rancheros_cloudconfig\nmode...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 100, name: "redhat_register", template: "<%#\nkind: snippet\nname: redhat_register\nmodel: Pro...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 101, name: "remote_execution_ssh_keys", template: "<%#\nkind: snippet\nname: remote_execution_ssh_keys\n...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 102, name: "saltstack_minion", template: "<%#\nkind: snippet\nname: saltstack_minion\nmodel: Pr...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 103, name: "saltstack_setup", template: "<%#\nkind: snippet\nname: saltstack_setup\nmodel: Pro...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: "this snippet will configure the Saltstack Minion">, #<ProvisioningTemplate id: 105, name: "Windows network", template: "<%#\nname: Windows network\nmodel: ProvisioningTempl...", snippet: true, template_kind_id: nil, created_at: "2021-05-11 16:43:37", updated_at: "2021-05-11 16:43:37", locked: true, default: true, vendor: "Foreman", type: "ProvisioningTemplate", os_family: nil, description: nil>, #<ProvisioningTemplate id: 136, name: "BN puppet.conf", template: "<%#\nkind: snippet\nname: puppet.conf\nmodel: Provisi...", snippet: true, template_kind_id: nil, created_at: "2021-05-12 17:36:39", updated_at: "2021-05-12 17:44:08", locked: false, default: true, vendor: nil, type: "ProvisioningTemplate", os_family: nil, description: "Cloned puppet.conf snippet for BeardNet.">]
irb(main):003:0> exit
[root@foreman ~]# foreman-rake db:seed
User with login admin already exists, not seeding as admin.
rake aborted!
ActiveRecord::RecordInvalid: Validation failed: Operatingsystems can't assign operating system to Registration template
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/validations.rb:80:in `raise_validation_error'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/validations.rb:53:in `save!'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:318:in `block in save!'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:375:in `block in with_transaction_returning_status'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:278: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/transactions.rb:366:in `with_transaction_returning_status'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:318:in `save!'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/suppressor.rb:48:in `save!'
/usr/share/foreman/lib/seed_helper.rb:134:in `block in import_raw_template'
/usr/share/foreman/app/models/template.rb:73:in `ignore_locking'
/usr/share/foreman/lib/seed_helper.rb:134:in `import_raw_template'
/usr/share/foreman/lib/seed_helper.rb:140:in `block in import_templates'
/usr/share/foreman/lib/seed_helper.rb:139:in `each'
/usr/share/foreman/lib/seed_helper.rb:139:in `import_templates'
/usr/share/foreman/db/seeds.d/070-provisioning_templates.rb:9:in `block in <top (required)>'
/opt/theforeman/tfm/root/usr/share/gems/gems/audited-4.9.0/lib/audited/auditor.rb:376:in `without_auditing'
/usr/share/foreman/db/seeds.d/070-provisioning_templates.rb:2:in `<top (required)>'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in `load'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in `block in load'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:291:in `load_dependency'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in `load'
/usr/share/foreman/app/services/foreman_seeder.rb:51:in `block (3 levels) in execute'
/usr/share/foreman/app/models/concerns/foreman/thread_session.rb:108:in `as'
/usr/share/foreman/app/models/concerns/foreman/thread_session.rb:114:in `as_anonymous_admin'
/usr/share/foreman/app/services/foreman_seeder.rb:50:in `block (2 levels) in execute'
/usr/share/foreman/app/services/foreman_seeder.rb:44:in `each'
/usr/share/foreman/app/services/foreman_seeder.rb:44:in `block in execute'
/usr/share/foreman/lib/foreman/advisory_lock_manager.rb:20:in `block in with_transaction_lock'
/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'
/usr/share/foreman/lib/foreman/advisory_lock_manager.rb:17:in `with_transaction_lock'
/usr/share/foreman/app/services/foreman_seeder.rb:38:in `execute'
/usr/share/foreman/db/seeds.rb:14:in `<top (required)>'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in `load'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in `block in load'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:291:in `load_dependency'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies.rb:318:in `load'
/usr/share/foreman/config/initializers/0_print_time_spent.rb:38:in `block in load'
/usr/share/foreman/config/initializers/0_print_time_spent.rb:17:in `benchmark'
/usr/share/foreman/config/initializers/0_print_time_spent.rb:38:in `load'
/opt/theforeman/tfm/root/usr/share/gems/gems/railties-6.0.3.7/lib/rails/engine.rb:559:in `load_seed'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/tasks/database_tasks.rb:440:in `load_seed'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/railties/databases.rake:331: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:seed
(See full trace by running task with --trace)
[root@foreman ~]# 

Actions #5

Updated by Tomer Brisker over 3 years ago

Oh, my mistake, I missed a line in the command. It should have been:

   registration_kind = TemplateKind.unscoped.find_by(name: 'registration')
   registration_templates = ProvisioningTemplate.unscoped.where(template_kind: registration_kind)
   registration_templates.each { |rt| rt.operatingsystems = [] }
Actions #6

Updated by Bret Wortman over 3 years ago

That got me past the db:seed. Thank you for your help, Tomer.

Actions #7

Updated by Tomer Brisker over 3 years ago

  • Status changed from New to Resolved
Actions

Also available in: Atom PDF