Bug #22645
openCannot render template Kickstart default PXELinux in Foreman 1.17 if interface does not have subnet assigned
Description
When i try to build a host i recieve the following error (disabling safemode does nothing):
2018-02-21T15:26:32 160e80f2 [app] [W] Review template error | Safemode::NoMethodError: undefined method '#dhcp_boot_mode?' for NilClass::Jail (NilClass) | /usr/share/foreman/vendor/ruby/2.3.0/gems/safemode-1.3.2/lib/safemode/jail.rb:22:in `method_missing' | Kickstart default PXELinux:64:in `bind' | /usr/share/foreman/vendor/ruby/2.3.0/gems/safemode-1.3.2/lib/safemode.rb:51:in `eval' | /usr/share/foreman/vendor/ruby/2.3.0/gems/safemode-1.3.2/lib/safemode.rb:51:in `eval' | /usr/share/foreman/lib/foreman/renderer.rb:84:in `render_safe' | /usr/share/foreman/lib/foreman/renderer.rb:202:in `unattended_render' | /usr/share/foreman/app/models/host/managed.rb:696:in `render_template' | /usr/share/foreman/app/services/host_build_status.rb:36:in `block in templates_status' | /usr/share/foreman/app/services/host_build_status.rb:33:in `each' | /usr/share/foreman/app/services/host_build_status.rb:33:in `templates_status' | /usr/share/foreman/app/services/host_build_status.rb:15:in `check_all_statuses' | /usr/share/foreman/app/models/host/managed.rb:701:in `build_status_checker' | /usr/share/foreman/app/controllers/hosts_controller.rb:228:in `review_before_build' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/abstract_controller/base.rb:186:in `process_action' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_controller/metal/rendering.rb:30:in `process_action' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/abstract_controller/callbacks.rb:20:in `block in process_action' | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:108:in `block in run_callbacks' | /usr/share/foreman/app/controllers/concerns/application_shared.rb:15:in `set_timezone' | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:117:in `block in run_callbacks' | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread' | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:117:in `block in run_callbacks' | /usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller' | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:117:in `block in run_callbacks' | /usr/share/foreman/vendor/ruby/2.3.0/gems/audited-4.5.0/lib/audited/sweeper.rb:14:in `around' | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:117:in `block in run_callbacks' | /usr/share/foreman/vendor/ruby/2.3.0/gems/audited-4.5.0/lib/audited/sweeper.rb:14:in `around' | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:117:in `block in run_callbacks' | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:135:in `run_callbacks' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/abstract_controller/callbacks.rb:19:in `process_action' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_controller/metal/rescue.rb:20:in `process_action' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action' | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/notifications.rb:166:in `block in instrument' | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/notifications/instrumenter.rb:21:in `instrument' | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/notifications.rb:166:in `instrument' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_controller/metal/instrumentation.rb:30:in `process_action' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_controller/metal/params_wrapper.rb:252:in `process_action' | /usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.1.4/lib/active_record/railties/controller_runtime.rb:22:in `process_action' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/abstract_controller/base.rb:124:in `process' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionview-5.1.4/lib/action_view/rendering.rb:30:in `process' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_controller/metal.rb:189:in `dispatch' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_controller/metal.rb:253:in `dispatch' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/routing/route_set.rb:49:in `dispatch' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/routing/route_set.rb:31:in `serve' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/journey/router.rb:50:in `block in serve' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/journey/router.rb:33:in `each' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/journey/router.rb:33:in `serve' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/routing/route_set.rb:834:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/apipie-rails-0.5.6/lib/apipie/static_dispatcher.rb:65:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/apipie-rails-0.5.6/lib/apipie/extractor/recorder.rb:136:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/apipie-rails-0.5.6/lib/apipie/middleware/checksum_in_headers.rb:27:in `call' | /usr/share/foreman/lib/middleware/catch_json_parse_errors.rb:8:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.4/lib/rack/etag.rb:25:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.4/lib/rack/conditional_get.rb:25:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.4/lib/rack/head.rb:12:in `call' | /usr/share/foreman/lib/middleware/session_safe_logging.rb:17:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.4/lib/rack/session/abstract/id.rb:232:in `context' | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.4/lib/rack/session/abstract/id.rb:226:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/cookies.rb:613:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/callbacks.rb:26:in `block in call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/callbacks.rb:97:in `run_callbacks' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/callbacks.rb:24:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/rack/logger.rb:36:in `call_app' | /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/rack/logger.rb:26:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/quiet_assets.rb:13:in `call' | /usr/share/foreman/lib/middleware/tagged_logging.rb:18:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/remote_ip.rb:79:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/request_id.rb:25:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.4/lib/rack/method_override.rb:22:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.4/lib/rack/runtime.rb:22:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/executor.rb:12:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.1.4/lib/action_dispatch/middleware/static.rb:125:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.4/lib/rack/sendfile.rb:111:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/secure_headers-3.7.3/lib/secure_headers/middleware.rb:12:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/engine.rb:522:in `call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/railtie.rb:185:in `public_send' | /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/railtie.rb:185:in `method_missing' | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.4/lib/rack/urlmap.rb:68:in `block in call' | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.4/lib/rack/urlmap.rb:53:in `each' | /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.4/lib/rack/urlmap.rb:53:in `call' | /usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:97:in `process_request' | /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:152:in `accept_and_process_next_request' | /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:113:in `main_loop' | /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:416:in `block (3 levels) in start_threads' | /usr/lib/ruby/vendor_ruby/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception' | /usr/share/foreman/vendor/ruby/2.3.0/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
For now i just commented out that section of code, but this should be fixed i think....
Updated by Damon Maria almost 7 years ago
I struck the same problem and the fix for me was to create an IPv4 subnet on the interface of the host I was creating. It's not a required field and when using DHCP I couldn't see why it was needed (since a subnet requires specifying network info that the DHCP server should provide).
Updated by Marek Hulán almost 7 years ago
Looks like it was already reported as #16060, could you please take a look at what I suggested at https://projects.theforeman.org/issues/16060#note-4 ? Though there were some changes in templates rendering recently. It might be related/fixed by #22615 but from the error I guess it's rather empty subnet issue.
Updated by Damon Maria almost 7 years ago
It failed for me as admin as well. It was definitely that there was no subnet defined, adding a subnet to the interface fixed it.
But I gather that a subnet shouldn't been needed? (I'm super new to Foreman). In the "Kickstart default PXELinux" template there's this line:
unless subnet.dhcp_boot_mode?
Which to me would always fail without a subnet on the interface.
Updated by Marek Hulán almost 7 years ago
- Subject changed from Cannot render template Kickstart default PXELinux in Foreman 1.17 to Cannot render template Kickstart default PXELinux in Foreman 1.17 if interface does not have subnet assigned
The problem with marking the field required is, that at the time of editing, we don't know, what type of provisioning will user perform. e.g. for image based provisioning, DHCP is not required. But I agree, if subnet is missing and template require it, it should not fail on template rendering, but rather tell user the subnet is missing.
Updated by Damon Maria almost 7 years ago
I am using the boot disk plugin to install via a generic ISO when the host will have a DHCP address. Even in this situation I have to specify a subnet on the interface which doesn't seem right, as all that will be coming from the DHCP server. Although I'm pretty new to Foreman and may be not understanding something.