Error while building a host via VMWare

When attempting to build a host, this fails. I also notice I don’t have any options for content source and I do not know why. I’m running Foreman v.2.3.1. The error I get (from production.log) is:

2021-01-12T21:22:02 [I|app|d94df497] Started POST "/hosts" for 192.35.179.122 at 2021-01-12 21:22:02 +0000
2021-01-12T21:22:02 [I|app|d94df497] Processing by HostsController#create as */*
2021-01-12T21:22:02 [I|app|d94df497]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"M5om2lNoQgZYtahoZMWj2pOZpGDf13l5Rzuk+IR+6cePu+I770aeMS/C/0q5t9n33vZlcmRQoGHNxQKKRerEcw==", "host"=>{"salt_module_ids"=>[""], "name"=>"irene-masgalas", "organization_id"=>"1", "location_id"=>"2", "hostgroup_id"=>"", "compute_resource_id"=>"1", "compute_profile_id"=>"2", "content_facet_attributes"=>{"lifecycle_environment_id"=>"2", "content_view_id"=>"5", "content_source_id"=>""}, "environment_id"=>"", "puppet_proxy_id"=>"", "puppet_ca_proxy_id"=>"", "salt_environment_id"=>"1", "salt_proxy_id"=>"", "ansible_role_ids"=>[""], "managed"=>"true", "progress_report_id"=>"[FILTERED]", "type"=>"Host::Managed", "interfaces_attributes"=>{"0"=>{"_destroy"=>"0", "type"=>"Nic::Managed", "identifier"=>"", "name"=>"irene-masgalas", "domain_id"=>"1", "subnet_id"=>"1", "ip"=>"10.3.1.224", "ip6"=>"", "managed"=>"1", "primary"=>"1", "provision"=>"1", "execution"=>"1", "virtual"=>"0", "tag"=>"", "attached_to"=>"", "compute_attributes"=>{"type"=>"VirtualVmxnet3", "network"=>"network-309"}}}, "compute_attributes"=>{"cpus"=>"2", "corespersocket"=>"1", "memory_mb"=>"4096", "firmware"=>"bios", "cluster"=>"u1SUP_01", "resource_pool"=>"Resources", "path"=>"/Datacenters/u1dc01/vm", "guest_id"=>"rhel8_64Guest", "hardware_version"=>"Default", "memoryHotAddEnabled"=>"1", "cpuHotAddEnabled"=>"1", "add_cdrom"=>"0", "boot_order"=>["disk"], "start"=>"1", "annotation"=>"", "scsi_controllers"=>"{\"scsiControllers\":[{\"type\":\"ParaVirtualSCSIController\",\"key\":1000}],\"volumes\":[{\"thin\":false,\"name\":\"Hard disk\",\"mode\":\"persistent\",\"controllerKey\":1000,\"sizeGb\":20,\"storagePod\":\"u1DEVcst01s\",\"datastore\":null,\"eagerZero\":true}]}"}, "architecture_id"=>"1", "operatingsystem_id"=>"1", "provision_method"=>"image", "build"=>"1", "medium_id"=>"", "ptable_id"=>"", "pxe_loader"=>"PXELinux BIOS", "disk"=>"", "root_pass"=>"[FILTERED]", "is_owned_by"=>"5-Users", "enabled"=>"1", "expired_on(1i)"=>"", "expired_on(2i)"=>"", "expired_on(3i)"=>"", "comment"=>"", "overwrite"=>"false"}}
2021-01-12T21:22:02 [W|app|d94df497] Not queueing Discovery reboot:
2021-01-12T21:22:02 [I|app|d94df497] Adding Compute instance for irene-masgalas.example.com
2021-01-12T21:22:02 [W|app|d94df497] Failed to create a compute u1dc01 (VMware) instance irene-masgalas.example.com: undefined method `include?' for nil:NilClass
 d94df497 |
2021-01-12T21:22:02 [I|app|d94df497] Backtrace for 'Failed to create a compute u1dc01 (VMware) instance irene-masgalas.example.com: undefined method `include?' for nil:NilClass
 d94df497 |  ' error (NoMethodError): undefined method `include?' for nil:NilClass
 d94df497 | /usr/share/gems/gems/fog-vsphere-3.4.0/lib/fog/vsphere/requests/compute/get_virtual_machine.rb:40:in `get_vm_by_name'
 d94df497 | /usr/share/gems/gems/fog-vsphere-3.4.0/lib/fog/vsphere/requests/compute/get_virtual_machine.rb:23:in `get_vm_ref'
 d94df497 | /usr/share/gems/gems/fog-vsphere-3.4.0/lib/fog/vsphere/requests/compute/get_virtual_machine.rb:7:in `get_virtual_machine'
 d94df497 | /usr/share/gems/gems/fog-vsphere-3.4.0/lib/fog/vsphere/requests/compute/vm_clone.rb:24:in `vm_clone_check_options'
 d94df497 | /usr/share/gems/gems/fog-vsphere-3.4.0/lib/fog/vsphere/requests/compute/vm_clone.rb:105:in `vm_clone'
 d94df497 | /usr/share/foreman/app/models/compute_resources/foreman/model/vmware.rb:567:in `clone_vm'
 d94df497 | /usr/share/foreman/app/models/compute_resources/foreman/model/vmware.rb:485:in `create_vm'
 d94df497 | /usr/share/foreman/app/models/concerns/orchestration/compute.rb:91:in `setCompute'
 d94df497 | /usr/share/foreman/app/models/concerns/orchestration.rb:227:in `execute'
 d94df497 | /usr/share/foreman/app/models/concerns/orchestration.rb:152:in `block in process'
 d94df497 | /usr/share/foreman/app/models/concerns/orchestration.rb:144:in `each'
 d94df497 | /usr/share/foreman/app/models/concerns/orchestration.rb:144:in `process'
 d94df497 | /usr/share/foreman/app/models/concerns/orchestration.rb:44:in `around_save_orchestration'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:139:in `run_callbacks'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:825:in `_run_save_callbacks'
 d94df497 | /usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/callbacks.rb:327:in `create_or_update'
 d94df497 | /usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/timestamp.rb:128:in `create_or_update'
 d94df497 | /usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/persistence.rb:470:in `save'
 d94df497 | /usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/validations.rb:47:in `save'
 d94df497 | /usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/transactions.rb:314:in `block in save'
 d94df497 | /usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/transactions.rb:375:in `block in with_transaction_returning_status'
 d94df497 | /usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in transaction'
 d94df497 | /usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_transaction'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
 d94df497 | /usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transaction'
 d94df497 | /usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'
 d94df497 | /usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/transactions.rb:212:in `transaction'
 d94df497 | /usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/transactions.rb:366:in `with_transaction_returning_status'
 d94df497 | /usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/transactions.rb:314:in `save'
 d94df497 | /usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/suppressor.rb:44:in `save'
 d94df497 | /usr/share/foreman/app/models/concerns/foreman/sti.rb:26:in `save'
 d94df497 | /usr/share/foreman/app/controllers/hosts_controller.rb:98:in `create'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/abstract_controller/base.rb:195:in `process_action'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_controller/metal/rendering.rb:30:in `process_action'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:112:in `block in run_callbacks'
 d94df497 | /usr/share/foreman/app/controllers/concerns/foreman/controller/timezone.rb:10:in `set_timezone'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 d94df497 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 d94df497 | /usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 d94df497 | /usr/share/gems/gems/audited-4.9.0/lib/audited/sweeper.rb:14:in `around'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 d94df497 | /usr/share/gems/gems/audited-4.9.0/lib/audited/sweeper.rb:14:in `around'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:139:in `run_callbacks'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/abstract_controller/callbacks.rb:41:in `process_action'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_controller/metal/rescue.rb:22:in `process_action'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/notifications.rb:180:in `block in instrument'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/notifications.rb:180:in `instrument'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_controller/metal/instrumentation.rb:32:in `process_action'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
 d94df497 | /usr/share/gems/gems/activerecord-6.0.3.4/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/abstract_controller/base.rb:136:in `process'
 d94df497 | /usr/share/gems/gems/actionview-6.0.3.4/lib/action_view/rendering.rb:39:in `process'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_controller/metal.rb:190:in `dispatch'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_controller/metal.rb:254:in `dispatch'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/routing/route_set.rb:33:in `serve'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/journey/router.rb:49:in `block in serve'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/journey/router.rb:32:in `each'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/journey/router.rb:32:in `serve'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/routing/route_set.rb:834:in `call'
 d94df497 | /usr/share/gems/gems/katello-3.18.1/lib/katello/middleware/event_daemon.rb:10:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/static.rb:126:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/static.rb:126:in `call'
 d94df497 | /usr/share/gems/gems/apipie-dsl-2.3.0/lib/apipie_dsl/static_dispatcher.rb:67:in `call'
 d94df497 | /usr/share/gems/gems/apipie-rails-0.5.17/lib/apipie/static_dispatcher.rb:66:in `call'
 d94df497 | /usr/share/gems/gems/apipie-rails-0.5.17/lib/apipie/extractor/recorder.rb:137:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/static.rb:126:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/static.rb:126:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/static.rb:126:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/static.rb:126:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/static.rb:126:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/static.rb:126:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/static.rb:126:in `call'
 d94df497 | /usr/share/foreman/lib/foreman/middleware/telemetry.rb:10:in `call'
 d94df497 | /usr/share/gems/gems/apipie-rails-0.5.17/lib/apipie/middleware/checksum_in_headers.rb:27:in `call'
 d94df497 | /usr/share/foreman/lib/foreman/middleware/catch_json_parse_errors.rb:9:in `call'
 d94df497 | /usr/share/gems/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb:15:in `call'
 d94df497 | /usr/share/gems/gems/rack-2.2.3/lib/rack/etag.rb:27:in `call'
 d94df497 | /usr/share/gems/gems/rack-2.2.3/lib/rack/conditional_get.rb:40:in `call'
 d94df497 | /usr/share/gems/gems/rack-2.2.3/lib/rack/head.rb:12:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/http/content_security_policy.rb:18:in `call'
 d94df497 | /usr/share/foreman/lib/foreman/middleware/logging_context_session.rb:22:in `call'
 d94df497 | /usr/share/gems/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:266:in `context'
 d94df497 | /usr/share/gems/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:260:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/cookies.rb:648:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:101:in `run_callbacks'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
 d94df497 | /usr/share/gems/gems/railties-6.0.3.4/lib/rails/rack/logger.rb:37:in `call_app'
 d94df497 | /usr/share/gems/gems/railties-6.0.3.4/lib/rails/rack/logger.rb:28:in `call'
 d94df497 | /usr/share/gems/gems/sprockets-rails-3.2.1/lib/sprockets/rails/quiet_assets.rb:13:in `call'
 d94df497 | /usr/share/foreman/lib/foreman/middleware/logging_context_request.rb:11:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/request_id.rb:27:in `call'
 d94df497 | /usr/share/gems/gems/katello-3.18.1/lib/katello/prevent_json_parsing.rb:12:in `call'
 d94df497 | /usr/share/gems/gems/rack-2.2.3/lib/rack/method_override.rb:24:in `call'
 d94df497 | /usr/share/gems/gems/rack-2.2.3/lib/rack/runtime.rb:22:in `call'
 d94df497 | /usr/share/gems/gems/activesupport-6.0.3.4/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/executor.rb:14:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/static.rb:126:in `call'
 d94df497 | /usr/share/gems/gems/rack-2.2.3/lib/rack/sendfile.rb:110:in `call'
 d94df497 | /usr/share/gems/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/host_authorization.rb:76:in `call'
 d94df497 | /usr/share/gems/gems/secure_headers-6.3.0/lib/secure_headers/middleware.rb:11:in `call'
 d94df497 | /usr/share/gems/gems/railties-6.0.3.4/lib/rails/engine.rb:527:in `call'
 d94df497 | /usr/share/gems/gems/railties-6.0.3.4/lib/rails/railtie.rb:190:in `public_send'
 d94df497 | /usr/share/gems/gems/railties-6.0.3.4/lib/rails/railtie.rb:190:in `method_missing'
 d94df497 | /usr/share/gems/gems/rack-2.2.3/lib/rack/urlmap.rb:74:in `block in call'
 d94df497 | /usr/share/gems/gems/rack-2.2.3/lib/rack/urlmap.rb:58:in `each'
 d94df497 | /usr/share/gems/gems/rack-2.2.3/lib/rack/urlmap.rb:58:in `call'
 d94df497 | /usr/share/gems/gems/puma-4.3.6/lib/puma/configuration.rb:228:in `call'
 d94df497 | /usr/share/gems/gems/puma-4.3.6/lib/puma/server.rb:713:in `handle_request'
 d94df497 | /usr/share/gems/gems/puma-4.3.6/lib/puma/server.rb:472:in `process_client'
 d94df497 | /usr/share/gems/gems/puma-4.3.6/lib/puma/server.rb:328:in `block in run'
 d94df497 | /usr/share/gems/gems/puma-4.3.6/lib/puma/thread_pool.rb:134:in `block in spawn_thread'
 d94df497 | /usr/share/gems/gems/logging-2.3.0/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2021-01-12T21:22:02 [W|app|d94df497] Rolling back due to a problem: [#<Orchestration::Task:0x0000560bba714aa0 @name="Set up compute instance irene-masgalas.example.com", @id="Set up compute instance irene-masgalas.example.com", @status="failed", @priority=3, @action=[#<Host::Managed id: nil, name: "irene-masgalas.example.com", last_compile: nil, last_report: nil, updated_at: nil, created_at: nil, root_pass: [FILTERED], architecture_id: 1, operatingsystem_id: 1, environment_id: nil, ptable_id: nil, medium_id: nil, build: true, comment: "", disk: "", installed_at: nil, model_id: nil, hostgroup_id: nil, owner_id: 5, owner_type: "User", enabled: true, puppet_ca_proxy_id: nil, managed: true, use_image: nil, image_file: nil, uuid: nil, compute_resource_id: 1, puppet_proxy_id: nil, certname: nil, image_id: nil, organization_id: 1, location_id: 2, type: "Host::Managed", otp: nil, realm_id: nil, compute_profile_id: 2, provision_method: "image", salt_proxy_id: nil, grub_pass: "$6$iZdaw3jeucKD5Nq6$NlmLD6cfwdw4gsTPjFNjaRMdsk/nsG...", salt_environment_id: 1, discovery_rule_id: nil, expired_on: nil, global_status: 0, lookup_value_matcher: [FILTERED], pxe_loader: "PXELinux BIOS", initiated_at: nil, build_errors: nil>, :setCompute], @created=1610486522.2642434, @timestamp=2021-01-12 21:22:02 UTC>]

Any ideas what my issue might be?

Fixed the title and formatting for ya.

1 Like

At a first glance, this looks like Foreman can’t access the template. Either because of missing permissions or something similar.

Here are some docs that might help:

https://docs.theforeman.org/master/Provisioning_Guide/index-foreman.html#Provisioning_Virtual_Machines_in_VMware_vSphere-Creating_a_VMware_vSphere_User

Template? This looks like something in the VMWare/Fog integration to me. @ezr-ondrej have you seen this one?

The :image_id is for some reason empty. There was no image selected, or it got lost along the lines, but I’d guess it’s about it not being selected properly.

This looks to have been the case - I needed to create an image to associate the VMWare template. As a result, there was no way to populate the image as @erz-ondrej observed

This error is pretty cryptic… My experience has been that the “nil:NilClass” errors are generally unhelpful. Should I create an issue in the issue tracker to generate a more helpful error? For errors like this it would be far better to splash something like “No image_id defined!”