Project

General

Profile

Actions

Bug #25569

closed

Windows templates: undefined method `medium_uri' for nil:NilClass

Added by John D. over 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Templates
Target version:
-
Difficulty:
Triaged:
Yes
Fixed in Releases:
Found in Releases:

Description

Error while rendering Windows templates

Foreman Version 1.20

Warning! There was an error rendering the Windows Provision template: undefined method `medium_uri' for nil:NilClass

Related issues 3 (0 open3 closed)

Related to Foreman - Feature #19389: Change TFTP filename pattern to include unique installation media IDClosedShimon ShteinActions
Related to Foreman - Bug #25621: NoMethodError: undefined method `tr' for #<URI::Generic boot/windows-x86_64-w2k12-X4w09nh2RI/>ClosedShimon ShteinActions
Related to Foreman - Support #26036: Windows templates are still not working with v1.21ResolvedActions
Actions #1

Updated by Tomer Brisker over 5 years ago

  • Category set to Templates

We do not ship windows templates by default, can you share the template you are using please (or even better - contribute it to https://github.com/theforeman/community-templates/)? also, can you include the full stack trace of the error from production.log?

Actions #2

Updated by John D. over 5 years ago

Tomer Brisker wrote:

We do not ship windows templates by default, can you share the template you are using please (or even better - contribute it to https://github.com/theforeman/community-templates/)? also, can you include the full stack trace of the error from production.log?

I am using the templates from https://github.com/kireevco/wimaging

2018-11-28T15:52:00 [I|app|] Started POST "/templates/provisioning_templates/140-Windows%20PXE/preview" for 10.208.1.159 at 2018-11-28 15:52:00 +0100
2018-11-28T15:52:00 [I|app|c91e3] Processing by ProvisioningTemplatesController#preview as */*
2018-11-28T15:52:00 [I|app|c91e3]   Parameters: {"template"=>"<%#\nkind: PXELinux\nname: Wimaging default PXELinux\noses:\n- Windows Server 2008\n- Windows Server 2008 R2\n- Windows Server 2012\n- Windows Server 2012 R2\n- Windows\n%>\nDEFAULT menu    \nLABEL menu         \n     COM32 linux.c32 boot/wimboot\n     APPEND initrdfile=<%= @host.operatingsystem.bootfile(@host.arch,:bcd) %>,<%= @host.operatingsystem.bootfile(@host.arch,:bootsdi) %>,<%= @host.operatingsystem.bootfile(@host.arch,:bootwim) %>\n", "preview_host_id"=>"", "id"=>"140-Windows PXE"}
2018-11-28T15:52:00 [I|app|c91e3] Current user set to admin (admin)
2018-11-28T15:52:00 [E|app|c91e3] Could not find a provider for foreman-node1.foreman-netz213.domain.de. Providers returned {"MediumProviders::Default"=>["Invalid medium 'Debian mirror' for 'Debian 9.5'"]}
2018-11-28T15:52:00 [W|app|c91e3] Error rendering the Windows PXE template
NoMethodError: undefined method `medium_uri' for nil:NilClass
/usr/share/foreman/app/models/operatingsystems/debian.rb:13:in `preseed_path'
/usr/share/foreman/lib/foreman/renderer/scope/variables/base.rb:14:in `preseed_path'
/usr/share/foreman/lib/foreman/renderer/scope/variables/base.rb:82:in `preseed_attributes'
/usr/share/foreman/lib/foreman/renderer/scope/variables/base.rb:30:in `load_variables_base'
/usr/share/foreman/lib/foreman/renderer/scope/variables.rb:20:in `block in load_variables'
/usr/share/foreman/lib/foreman/renderer/scope/variables.rb:18:in `each'
/usr/share/foreman/lib/foreman/renderer/scope/variables.rb:18:in `load_variables'
/usr/share/foreman/lib/foreman/renderer/scope/base.rb:27:in `initialize'
/usr/share/foreman/lib/foreman/renderer/scope/template.rb:9:in `initialize'
/usr/share/foreman/lib/foreman/renderer.rb:39:in `new'
/usr/share/foreman/lib/foreman/renderer.rb:39:in `get_scope'
/usr/share/foreman/app/models/template.rb:172:in `render'
/usr/share/foreman/app/controllers/templates_controller.rb:113:in `safe_render'
/usr/share/foreman/app/controllers/templates_controller.rb:95:in `preview'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/abstract_controller/base.rb:194:in `process_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_controller/metal/rendering.rb:30:in `process_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:109: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.2.1/lib/active_support/callbacks.rb:118: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.2.1/lib/active_support/callbacks.rb:118: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.2.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/usr/share/foreman/vendor/ruby/2.3.0/gems/audited-4.8.0/lib/audited/sweeper.rb:14:in `around'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/usr/share/foreman/vendor/ruby/2.3.0/gems/audited-4.8.0/lib/audited/sweeper.rb:14:in `around'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:136:in `run_callbacks'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/abstract_controller/callbacks.rb:41:in `process_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_controller/metal/rescue.rb:22:in `process_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/notifications.rb:168:in `block in instrument'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/notifications.rb:168:in `instrument'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_controller/metal/instrumentation.rb:32:in `process_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.2.1/lib/active_record/railties/controller_runtime.rb:24:in `process_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/abstract_controller/base.rb:134:in `process'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionview-5.2.1/lib/action_view/rendering.rb:32:in `process'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_controller/metal.rb:191:in `dispatch'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_controller/metal.rb:252:in `dispatch'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/routing/route_set.rb:34:in `serve'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/journey/router.rb:52:in `block in serve'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/journey/router.rb:35:in `each'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/journey/router.rb:35:in `serve'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/routing/route_set.rb:840:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/apipie-rails-0.5.14/lib/apipie/static_dispatcher.rb:65:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/apipie-rails-0.5.14/lib/apipie/extractor/recorder.rb:137:in `call'
/usr/share/foreman/lib/middleware/telemetry.rb:9:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/apipie-rails-0.5.14/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.6/lib/rack/tempfile_reaper.rb:15:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/etag.rb:25:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/conditional_get.rb:38:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/head.rb:12:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/http/content_security_policy.rb:18:in `call'
/usr/share/foreman/lib/middleware/logging_context.rb:23:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/session/abstract/id.rb:232:in `context'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/session/abstract/id.rb:226:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/cookies.rb:670:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:98:in `run_callbacks'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.2.1/lib/rails/rack/logger.rb:38:in `call_app'
/usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.2.1/lib/rails/rack/logger.rb:28: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/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/request_id.rb:27:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/method_override.rb:22:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/runtime.rb:22:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/executor.rb:14:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/static.rb:127:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/sendfile.rb:111:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/secure_headers-6.0.0/lib/secure_headers/middleware.rb:13:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.2.1/lib/rails/engine.rb:524:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.2.1/lib/rails/railtie.rb:190:in `public_send'
/usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.2.1/lib/rails/railtie.rb:190:in `method_missing'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/urlmap.rb:68:in `block in call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/urlmap.rb:53:in `each'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/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:160: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'
2018-11-28T15:52:00 [I|app|c91e3]   Rendering text template
2018-11-28T15:52:00 [I|app|c91e3]   Rendered text template (0.0ms)
2018-11-28T15:52:00 [I|app|c91e3] Completed 500 Internal Server Error in 64ms (Views: 0.9ms | ActiveRecord: 11.8ms)

Btw. why is there no bash/shell highlighting?

Actions #3

Updated by John D. over 5 years ago

When i choose a host where a other os is already installed, i get the following error:

Warning! There was an error rendering the Windows PXE template: undefined method '#arch' for Host::Managed::Jail (Host::Managed)

2018-11-28T16:07:36 [I|app|] Started POST "/templates/provisioning_templates/140-Windows%20PXE/preview" for 10.208.1.159 at 2018-11-28 16:07:36 +0100
2018-11-28T16:07:36 [I|app|a21a7] Processing by ProvisioningTemplatesController#preview as */*
2018-11-28T16:07:36 [I|app|a21a7]   Parameters: {"template"=>"<%#\nkind: PXELinux\nname: Wimaging default PXELinux\noses:\n- Windows Server 2008\n- Windows Server 2008 R2\n- Windows Server 2012\n- Windows Server 2012 R2\n- Windows\n%>\nDEFAULT menu    \nLABEL menu         \n     COM32 linux.c32 boot/wimboot\n     APPEND initrdfile=<%= @host.operatingsystem.bootfile(@host.arch,:bcd) %>,<%= @host.operatingsystem.bootfile(@host.arch,:bootsdi) %>,<%= @host.operatingsystem.bootfile(@host.arch,:bootwim) %>\n", "preview_host_id"=>"37", "id"=>"140-Windows PXE"}
2018-11-28T16:07:36 [I|app|a21a7] Current user set to admin (admin)
2018-11-28T16:07:36 [W|app|a21a7] Error rendering the Windows PXE template
Safemode::NoMethodError: undefined method '#arch' for Host::Managed::Jail (Host::Managed)
/usr/share/foreman/vendor/ruby/2.3.0/gems/safemode-1.3.5/lib/safemode/jail.rb:22:in `method_missing'
Windows PXE:53:in `bind'
/usr/share/foreman/vendor/ruby/2.3.0/gems/safemode-1.3.5/lib/safemode.rb:51:in `eval'
/usr/share/foreman/vendor/ruby/2.3.0/gems/safemode-1.3.5/lib/safemode.rb:51:in `eval'
/usr/share/foreman/lib/foreman/renderer/safe_mode_renderer.rb:7:in `render'
/usr/share/foreman/lib/foreman/renderer/base_renderer.rb:16:in `render'
/usr/share/foreman/lib/foreman/renderer.rb:47:in `render'
/usr/share/foreman/app/models/template.rb:173:in `render'
/usr/share/foreman/app/controllers/templates_controller.rb:113:in `safe_render'
/usr/share/foreman/app/controllers/templates_controller.rb:95:in `preview'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/abstract_controller/base.rb:194:in `process_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_controller/metal/rendering.rb:30:in `process_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:109: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.2.1/lib/active_support/callbacks.rb:118: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.2.1/lib/active_support/callbacks.rb:118: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.2.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/usr/share/foreman/vendor/ruby/2.3.0/gems/audited-4.8.0/lib/audited/sweeper.rb:14:in `around'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/usr/share/foreman/vendor/ruby/2.3.0/gems/audited-4.8.0/lib/audited/sweeper.rb:14:in `around'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:136:in `run_callbacks'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/abstract_controller/callbacks.rb:41:in `process_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_controller/metal/rescue.rb:22:in `process_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/notifications.rb:168:in `block in instrument'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/notifications.rb:168:in `instrument'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_controller/metal/instrumentation.rb:32:in `process_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activerecord-5.2.1/lib/active_record/railties/controller_runtime.rb:24:in `process_action'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/abstract_controller/base.rb:134:in `process'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionview-5.2.1/lib/action_view/rendering.rb:32:in `process'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_controller/metal.rb:191:in `dispatch'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_controller/metal.rb:252:in `dispatch'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/routing/route_set.rb:34:in `serve'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/journey/router.rb:52:in `block in serve'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/journey/router.rb:35:in `each'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/journey/router.rb:35:in `serve'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/routing/route_set.rb:840:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/apipie-rails-0.5.14/lib/apipie/static_dispatcher.rb:65:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/apipie-rails-0.5.14/lib/apipie/extractor/recorder.rb:137:in `call'
/usr/share/foreman/lib/middleware/telemetry.rb:9:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/apipie-rails-0.5.14/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.6/lib/rack/tempfile_reaper.rb:15:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/etag.rb:25:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/conditional_get.rb:38:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/head.rb:12:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/http/content_security_policy.rb:18:in `call'
/usr/share/foreman/lib/middleware/logging_context.rb:23:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/session/abstract/id.rb:232:in `context'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/session/abstract/id.rb:226:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/cookies.rb:670:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/callbacks.rb:98:in `run_callbacks'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.2.1/lib/rails/rack/logger.rb:38:in `call_app'
/usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.2.1/lib/rails/rack/logger.rb:28: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/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/request_id.rb:27:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/method_override.rb:22:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/runtime.rb:22:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.2.1/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/executor.rb:14:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/actionpack-5.2.1/lib/action_dispatch/middleware/static.rb:127:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/sendfile.rb:111:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/secure_headers-6.0.0/lib/secure_headers/middleware.rb:13:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.2.1/lib/rails/engine.rb:524:in `call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.2.1/lib/rails/railtie.rb:190:in `public_send'
/usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.2.1/lib/rails/railtie.rb:190:in `method_missing'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/urlmap.rb:68:in `block in call'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/lib/rack/urlmap.rb:53:in `each'
/usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.6/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:160: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'
2018-11-28T16:07:36 [I|app|a21a7]   Rendering text template
2018-11-28T16:07:36 [I|app|a21a7]   Rendered text template (0.0ms)
2018-11-28T16:07:36 [I|app|a21a7] Completed 500 Internal Server Error in 36ms (Views: 0.8ms | ActiveRecord: 4.5ms)
Actions #4

Updated by Tomer Brisker over 5 years ago

Looks like there may be some issues in the template itself, which hasn't been updated in two years. try changing all calls to `@host.arch` to `@host.architecture`.
Also verify under "Hosts>Operating Systems>Windows" that the correct media, architecture, templates and partition tables are selected.

Actions #5

Updated by John D. over 5 years ago

Tomer Brisker wrote:

Looks like there may be some issues in the template itself, which hasn't been updated in two years. try changing all calls to `@host.arch` to `@host.architecture`.
Also verify under "Hosts>Operating Systems>Windows" that the correct media, architecture, templates and partition tables are selected.

I get still the same errors.
I fixed the @host.architecture on the "Windows PXE" template. The other 2 templates don't have this variable.

<%#
kind: PXELinux
name: Wimaging default PXELinux
oses:
- Windows Server 2008
- Windows Server 2008 R2
- Windows Server 2012
- Windows Server 2012 R2
- Windows
%>
DEFAULT menu    
LABEL menu         
     COM32 linux.c32 boot/wimboot
     APPEND initrdfile=<%= @host.operatingsystem.bootfile(@host.architecture,:bcd) %>,<%= @host.operatingsystem.bootfile(@host.architecture,:bootsdi) %>,<%= @host.operatingsystem.bootfile(@host.architecture,:bootwim) %>

For example my "Windows Provisioning" template looks like:

<%#
kind: provision
name: Wimaging default provision
oses:
- Windows Server 2008
- Windows Server 2008 R2
- Windows Server 2012
- Windows Server 2012 R2
- Windows
# Parameters are expected to be set in Foreman (globally or per group/host)
params:
# Gesetzt im OS
#- windowsLicenseKey: ABCDE-ABCDE-ABCDE-ABCDE-ABCDE # Valid Windows license key
#- windowsLicenseOwner: Company, INC # Legal owner of the Windows license key
- systemLocale: en-US
- systemUILanguage: en-US
- systemTimeZone: Pacific Standard Time #see https://msdn.microsoft.com/en-us/library/ms912391(v=winembedded.11).aspx
#- wimImageName = Windows 8.1 Pro # Image name seems only necessary if the WIM contains more than one image
%>
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
    <servicing></servicing>
    <settings pass="offlineServicing">
        <component name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <EnableLUA>false</EnableLUA>
        </component>
    </settings>
    <settings pass="windowsPE">
        <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <EnableFirewall>false</EnableFirewall>
            <EnableNetwork>true</EnableNetwork>
            <Restart>Restart</Restart>
            <ImageInstall>
                <OSImage>
                    <InstallFrom>
                        <MetaData wcm:action="add">
                                <Value><%= @host.params['wimImageName'] -%></Value>  
                        </MetaData>
                    </InstallFrom>
                    <InstallToAvailablePartition>true</InstallToAvailablePartition>
                    <WillShowUI>OnError</WillShowUI>
                </OSImage>
            </ImageInstall>
            <UserData>
                <AcceptEula>true</AcceptEula>
            </UserData>
        </component>
        <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <SetupUILanguage>
                <UILanguage>en-US</UILanguage>
            </SetupUILanguage>
            <% if @host.params['systemLocale'] -%>
              <InputLocale><%= @host.params['systemLocale'] %></InputLocale>
              <SystemLocale><%= @host.params['systemLocale'] %></SystemLocale>
              <UILanguageFallback>en-US</UILanguageFallback>
              <UILanguage><%= @host.params['systemUILanguage'] %></UILanguage>
              <UserLocale><%= @host.params['systemLocale'] %></UserLocale>
            <% else -%>
               <InputLocale>en-US</InputLocale>
              <SystemLocale>en-US</SystemLocale>
              <UILanguageFallback>en-US</UILanguageFallback>
              <UILanguage>en-US</UILanguage>
              <UserLocale>en-US</UserLocale>
            <% end -%>
        </component>
    </settings>
    <settings pass="oobeSystem">
        <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <% if @host.params['systemLocale'] -%>
              <InputLocale><%= @host.params['systemLocale'] -%></InputLocale>
              <SystemLocale><%= @host.params['systemLocale'] -%></SystemLocale>
              <UILanguageFallback>en-US</UILanguageFallback>
              <UILanguage><%= @host.params['systemUILanguage'] -%></UILanguage>
              <UserLocale><%= @host.params['systemLocale'] -%></UserLocale>
            <% else -%>
               <InputLocale>en-US</InputLocale>
              <SystemLocale>en-US</SystemLocale>
              <UILanguageFallback>en-US</UILanguageFallback>
              <UILanguage>en-US</UILanguage>
              <UserLocale>en-US</UserLocale>
            <% end -%>
        </component>
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <UserAccounts>
                <AdministratorPassword>
                    <PlainText>false</PlainText>
                    <Value><%= Base64.encode64(Encoding::Converter.new("UTF-8", "UTF-16LE",:undef => nil).convert(Base64.decode64(root_pass)+"AdministratorPassword")).delete!("\n").chomp %></Value>
                </AdministratorPassword>
                <% if snippet('Wimaging local users') -%>
                  <%= snippet('Wimaging local users') -%>
                <% end %>
            </UserAccounts>
            <TimeZone><%= @host.params['systemTimeZone'] -%></TimeZone>
            <% if @host.params['windowsLicenseOwner'] -%>
              <RegisteredOrganization><%= @host.params['windowsLicenseOwner'] -%></RegisteredOrganization>
              <RegisteredOwner><%= @host.params['windowsLicenseOwner'] -%></RegisteredOwner>
            <% end -%>
            <OOBE>
                <HideEULAPage>true</HideEULAPage>
                <NetworkLocation>Work</NetworkLocation>
                <ProtectYourPC>1</ProtectYourPC>
                <SkipUserOOBE>true</SkipUserOOBE>
                <SkipMachineOOBE>true</SkipMachineOOBE>
                <HideLocalAccountScreen>true</HideLocalAccountScreen>
                <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
                <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
                <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
            </OOBE>
            <ShowWindowsLive>false</ShowWindowsLive>
            <% if @host.params['windowsLicenseKey'] -%>
              <ProductKey><%= @host.params['windowsLicenseKey'].to_s -%></ProductKey>
            <% end -%>
        </component>
    </settings>
    <settings pass="specialize">
        <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <% if @host.params['systemLocale'] -%>
              <InputLocale><%= @host.params['systemLocale'] -%></InputLocale>
              <SystemLocale><%= @host.params['systemLocale'] -%></SystemLocale>
              <UILanguage><%= @host.params['systemUILanguage'] -%></UILanguage>
              <UILanguageFallback>en-US</UILanguageFallback>
              <UserLocale><%= @host.params['systemLocale'] -%></UserLocale>
            <% else -%>
              <InputLocale>en-US</InputLocale>
              <SystemLocale>en-US</SystemLocale>
              <UILanguage>en-US</UILanguage>
              <UILanguageFallback>en-US</UILanguageFallback>
              <UserLocale>en-US</UserLocale>
            <% end -%>       
        </component>
        <component name="Microsoft-Windows-IE-ESC" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <IEHardenAdmin>false</IEHardenAdmin>
        </component>
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <ComputerName><%= @host.shortname -%></ComputerName>
            <% if @host.params['windowsLicenseOwner'] -%>
              <RegisteredOrganization><%= @host.params['windowsLicenseOwner'] -%></RegisteredOrganization>
              <RegisteredOwner><%= @host.params['windowsLicenseOwner'] -%></RegisteredOwner>
            <% end -%>
            <% if @host.params['systemTimeZone'] -%>
              <TimeZone><%= @host.params['systemTimeZone'] -%></TimeZone>
            <% else -%>
              <TimeZone>Pacific Standard Time</TimeZone>
            <% end -%>
        </component>
        <component name="Networking-MPSSVC-Svc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <DomainProfile_EnableFirewall>false</DomainProfile_EnableFirewall>
            <PrivateProfile_EnableFirewall>false</PrivateProfile_EnableFirewall>
            <PublicProfile_EnableFirewall>false</PublicProfile_EnableFirewall>
        </component>
        <component name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon>
        </component>
        <component name="Microsoft-Windows-TerminalServices-LocalSessionManager" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <fDenyTSConnections>false</fDenyTSConnections>
        </component>
        <component name="Microsoft-Windows-TerminalServices-RDP-WinStationExtensions" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <SecurityLayer>1</SecurityLayer>
            <UserAuthentication>0</UserAuthentication>
        </component>
    </settings>
    <cpi:offlineImage cpi:source="catalog:c:/deploy/wimaging/sources/win81x64/sources/install_windows 8.1 pro.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>

And get's exactly the same error.

Actions #6

Updated by Tomer Brisker over 5 years ago

I'm not sure why the first stack trace show it is trying to look for debian media, which is why i suggested checking that the operating system configuration is correct.
Looks like one of the snippets (winpe setup) uses deprecated `@host.os.medium_uri(@host)` endpoint, this should be replaced with `@medium_provider.medium_uri`
Also, seems that the interface for @host.os.bootfile was changed in #19389 and now it expects @medium_provider as the first argument rather than architecture.

Actions #7

Updated by Tomer Brisker over 5 years ago

  • Related to Feature #19389: Change TFTP filename pattern to include unique installation media ID added
Actions #8

Updated by John D. over 5 years ago

Tomer Brisker wrote:

I'm not sure why the first stack trace show it is trying to look for debian media, which is why i suggested checking that the operating system configuration is correct.
Looks like one of the snippets (winpe setup) uses deprecated `@host.os.medium_uri(@host)` endpoint, this should be replaced with `@medium_provider.medium_uri`
Also, seems that the interface for @host.os.bootfile was changed in #19389 and now it expects @medium_provider as the first argument rather than architecture.

So what i should change?
I got a Wimaging peSetup.cmd which used the @host.os.medium_uri(@host) but my three provisioning templates are already not using the medium_uri method at all.

Actions #9

Updated by Lukas Zapletal over 5 years ago

  • Triaged changed from No to Yes
Actions #10

Updated by Tomer Brisker over 5 years ago

some of the changes needed to make the template compatible with latest foreman:

@host.os.medium_uri(@host)  => @medium_provider.medium_uri
@host.os.bootfile(@host.arch, ...) => @host.os.bootfile(@medium_provider, ...)
@host.params['...'] => host_param('...')

If you manage to update the templates and get them working, it would be great to contribute them to the community templates repo. That way we'll make sure they are kept up to date when changes are made in the templating engine in the future.

Actions #11

Updated by John D. over 5 years ago

<%#
kind: PXELinux
name: Wimaging default PXELinux
oses:
- Windows Server 2008
- Windows Server 2008 R2
- Windows Server 2012
- Windows Server 2012 R2
- Windows
%>
DEFAULT menu    
LABEL menu         
     COM32 linux.c32 boot/wimboot
     APPEND initrdfile=<%= @host.operatingsystem.bootfile(@medium_provider,:bcd) %>,<%= @host.operatingsystem.bootfile(@medium_provider,:bootsdi) %>,<%= @host.operatingsystem.bootfile(@medium_provider,:bootwim) %>

Still getting the same error after changing my PXE template.
I will test it with the other templates for Windows.

Actions #12

Updated by John D. over 5 years ago

And the the error on the finishing template. Which not even got a medium_uri function in it?

<%#
kind: finish
name: Wimaging default finish
oses:
- Windows Server 2008
- Windows Server 2008 R2
- Windows Server 2012
- Windows Server 2012 R2
- Windows
# Parameters are expected to be set in Foreman (globally or per group/host)
params:
- windowsLicenseKey: ABCDE-ABCDE-ABCDE-ABCDE-ABCDE # Valid Windows license key
- windowsLicenseOwner: Company, INC # Legal owner of the Windows license key
- localAdminAccountDisabled: false
- ntpSever: time.windows.com,other.time.server
- domainAdminAccount: administrator@domain.com # use this account to join domain
- domainAdminAccountPasswd: Password for the domain Admin account
- computerOU: OU=Computers,CN=domain,CN=com # Place the computer account in specified Organizational Unit
- computerDomain: domain.com # domain to join
- foremanDebug: false
%>
<%
  # safemode renderer does not support unary negation
  pm_set = @host.puppetmaster.empty? ? false : true
  puppet_enabled = pm_set || @host_param('force-puppet') && @host_param('force-puppet') == 'true'
  salt_enabled = @host_param('salt_master') ? true : false
  chef_enabled = @host.respond_to?(:chef_proxy) && @host.chef_proxy
%>

@echo off
<% unless @host_param('localAdminAccountDisabled') -%>
  echo Activating administrator
  net user administrator /active:yes
<% end -%>

<% if @host.pxe_build? %>
  set ctr=0
  set nettimeout=10

  (echo Updating time)
  (sc config w32time start= auto)
  sc start w32time
  :ntp_testip
    ::ipconfig /renew
    wget.exe <%= foreman_url('provision') %>
    if %errorlevel% == 0 goto ntp_testip_ok
    timeout /t 10 >NUL
    set /a ctr=ctr+1
    echo Retry network. Run %ctr% time(s)
    if %ctr% GTR %nettimeout% (
        echo Network error! Exiting.
        exit 1
        )
    goto ntp_testip
  :ntp_testip_ok

  echo Network test OK!

  <% if @host_param('ntpSever') %>
    echo setting time server
    w32tm /config /manualpeerlist:<%= @host_param('ntpSever') %> /syncfromflags:manual /update
  <% end %>

  echo sync time
  w32tm /resync
  w32tm /resync

  :: You can join your machine to the domain right here >

  <% if @host_param('domainAdminAccount') and @host_param('domainAdminAccountPasswd') -%>
    echo joining domain
    powershell.exe -OutputFormat text -ExecutionPolicy remotesigned -command c:\deploy\joinDomain.ps1
  <% end %>

  :: < You can join your machine to the domain right here

  <% if @host_param('localAdminAccountDisabled') %>
    echo Disabling %tempAdminUser%
    net user %tempAdminUser% %tempAdminUser% /active:no
  <% end %>

  <% if @host_param('foremanDebug') != true %>
    echo Safely remove wimaging files
    sdelete.exe -accepteula -p 2 -r c:\wimaging
    sdelete.exe -accepteula -p 2 c:\Windows\Panther\unattend.xml
    sdelete.exe -accepteula -p 2 C:\Windows\Setup\Scripts\SetupComplete.cmd
    sdelete.exe -accepteula -p 2 -r c:\minint
    sdelete.exe -accepteula -p 2 -r c:\wimaging
  <% end %>

  <% if snippets "Wimaging extraFinishCommands" -%>
    echo Running extra commands
    <%= snippets "Wimaging extraFinishCommands" %>
    echo Cleaning up extras
    sdelete.exe -accepteula -p 2 -r c:\extras
  <% end -%>

  <% if puppet_enabled %>
    echo Installing puppet
    start /w "" msiexec /qn /i C:\extras\puppet.msi PUPPET_AGENT_STARTUP_MODE=Manual PUPPET_MASTER_SERVER=<%= @host.puppetmaster -%> PUPPET_AGENT_ACCOUNT_DOMAIN=<%= @host.domain -%> PUPPET_AGENT_ACCOUNT_USER=administrator PUPPET_AGENT_ACCOUNT_PASSWORD="<%= @host.params['domainAdminAccountPasswd'] -%>" 
    echo set puppet to auto start
    sc config puppet start= auto
    sc query puppet
  <% end%>

  echo Tell foreman build has finished
  wget.exe <%= foreman_url('built') %>

  <% if @host_param('foremanDebug') != true %>
    echo Safely removing c:\deploy
    sdelete.exe -accepteula -p 2 -r c:\deploy  

    echo remove leftover directories
    rmdir /s /q c:\wimaging
    rmdir /s /q c:\minint
    rmdir /s /q c:\deploy
    rmdir /s /q c:\extras

    echo rebooting...
    shutdown /r /t 5
  <% end -%>  
<% end -%>

Actions #13

Updated by John D. over 5 years ago

And the same for the provisioning template

Actions #14

Updated by Tomer Brisker over 5 years ago

Ok, I think I figured out what is happening here - you have a misconfiguration for debian 9.5 OS, it doesn't have debian mirror as one of its media. Not sure yet why it is trying debian instead of windows, but hopefully if you fix that it will get past this error.

I also noticed you changed the template to use `host_param` but it should be just `host_param` (without the )

Actions #15

Updated by John D. over 5 years ago

Who yeah, you are right. The Debian 9.5 OS had no installation media.
After changing i get a other Debian error.. Whats going on here? I am on a Windowstemplate..

Warning! There was an error rendering the Windows PXE template: undefined method '#bootfile' for Operatingsystem::Jail (Debian)

And what do u mean with:

I also noticed you changed the template to use `host_param` but it should be just `host_param` (without the )

Above u wrote that i should change the [ to (.
@host_param('localAdminAccountDisabled') should be @host_param['localAdminAccountDisabled'] ?

Actions #16

Updated by Tomer Brisker over 5 years ago

hmmm, for some reason `@` got stripped from my previous reply, i meant that

@host_params
should be
host_params

And it looks like bootfile method is indeed missing from the os jail - as a workaround, you can add it at https://github.com/theforeman/foreman/blob/develop/app/models/operatingsystem.rb#L75 (the file should be in /usr/share/foreman) and restart apache.
Still not sure why the host is trying to look at debian os settings instead of windows.

Actions #17

Updated by John D. over 5 years ago

Now PARAMS not PARAM? Refer to

@host.params['...'] => host_param('...')

Can u write a right function call?
host_params('wimImageName')
or
host_param('wimImageName')
or
host_params['wimImageName']
or
host_param['wimImageName']

Thank you.

Actions #18

Updated by Tomer Brisker over 5 years ago

sorry, my mistake, it should be host_param('wimImageName')

Actions #19

Updated by John D. over 5 years ago

After disabling the safe mode rendering, my provisioning template get's the following error:

Warning! There was an error rendering the Windows Provision template: "\xE5" followed by "\xFA" on UTF-8

But i can't find any ú or å. But should be my mistake.. I will have a look.

This change:

https://github.com/theforeman/foreman/blob/develop/app/models/operatingsystem.rb#L75

already exists on Foreman 1.20

Actions #20

Updated by Tomer Brisker over 5 years ago

I should have been clearer, the change needed in that line is to add :bootfile to the list of permitted methods, so the line should read:

class Jail < Safemode::Jail
  allow :name, :media_url, :major, :minor, :family, :to_s, :repos, :==, :release, :release_name, :kernel, :initrd, :pxe_type, :medium_uri, :boot_files_uri, :password_hash, :bootfile
end

Actions #21

Updated by John D. over 5 years ago

Tomer Brisker wrote:

I should have been clearer, the change needed in that line is to add :bootfile to the list of permitted methods, so the line should read:
[...]

Oh sorry my fault, didn't see the change.
After changing on my PXE Tempalte i get this error:

Warning! There was an error rendering the Windows PXE template: ERF42-0336 [Foreman::Exception]: Please provide a medium provider. It can be found as @medium_provider in templates, or Foreman::Plugin.medium_providers.find_provider(host)

<%#
kind: PXELinux
name: Wimaging default PXELinux
oses:
- Windows Server 2008
- Windows Server 2008 R2
- Windows Server 2012
- Windows Server 2012 R2
- Windows
%>
DEFAULT menu    
LABEL menu         
     COM32 linux.c32 boot/wimboot
     APPEND initrdfile=<%= @host.operatingsystem.bootfile(@host.architecture,:bcd) %>,<%= @host.operatingsystem.bootfile(@host.architecture,:bootsdi) %>,<%= @host.operatingsystem.bootfile(@host.architecture,:bootwim) %>
Actions #22

Updated by The Foreman Bot over 5 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Shimon Shtein
  • Pull request https://github.com/theforeman/foreman/pull/6302 added
Actions #23

Updated by Shimon Shtein over 5 years ago

Created a pull request with needed changes to windows operating system and attached modified versions of the template to that PR.

@John, I had hard time deciphering the code you have used for administrator password. Could you please explain what is needed there, so I can adjust my PR accordingly?

Actions #24

Updated by John D. over 5 years ago

Shimon Shtein wrote:

Created a pull request with needed changes to windows operating system and attached modified versions of the template to that PR.

@John, I had hard time deciphering the code you have used for administrator password. Could you please explain what is needed there, so I can adjust my PR accordingly?

Hey Shimon, i think you should better ask kireevco
Because of:
https://github.com/kireevco/foreman-wimaging/blob/1bd8f0facff80c19a5eccc12c01e8febd00f701e/wimaging/wimaging_provision_unattend.xml.erb

Until i can't test the templates, i just copied the default ofkireevco

Actions #25

Updated by John D. over 5 years ago

I just saw the Fix on https://github.com/theforeman/foreman/pull/6302/commits/e33b8a3b1eec129b0c6f70380544595f3abbb142
Should i just add it to my Foreman code or is there something to know about the changes?

Actions #26

Updated by Tomer Brisker over 5 years ago

  • Related to Bug #25621: NoMethodError: undefined method `tr' for #<URI::Generic boot/windows-x86_64-w2k12-X4w09nh2RI/> added
Actions #27

Updated by Eric Hansen over 5 years ago

It would be nice to have a functioning example of Foreman templates that use wimboot to build Windows operating systems. I'm most interested in using the bootdisk feature to do that via iPXE, since testing this is easier that way with VMWare and doesn't require setting up dedicated, fenced networks or dealing with SYSLINUX version incompatibility issues to just proof of concept this.

Actions #28

Updated by Shimon Shtein over 5 years ago

In the PR I supplied to this bug (https://github.com/theforeman/foreman/pull/6302) I have attached a template that should be valid.
One caveat though: in order to recode root_pass to Windows stahdards (Base64 on UTF-16LE encoded string) we have to make sure we selected Base64 encryption in OperatingSystem editing page and we have to drop safe template rendering, since by default safe renderer does not know how to deal with Base64.encode method calls.

Actions #29

Updated by John D. over 5 years ago

Is there a fix for post 21?

Actions #30

Updated by Shimon Shtein over 5 years ago

Changed the PR to add proper hashing of root_pass using windows standard - base64 on utf-16le string representation.

Can you please try the following provisioning template with OS hashing algorithm set to Base64-Windows:

<%#
kind: provision
name: Wimaging default provision
oses:
- Windows Server 2008
- Windows Server 2008 R2
- Windows Server 2012
- Windows Server 2012 R2
- Windows
# Parameters are expected to be set in Foreman (globally or per group/host)
params:
# Gesetzt im OS
#- windowsLicenseKey: ABCDE-ABCDE-ABCDE-ABCDE-ABCDE # Valid Windows license key
#- windowsLicenseOwner: Company, INC # Legal owner of the Windows license key
- systemLocale: en-US
- systemUILanguage: en-US
- systemTimeZone: Pacific Standard Time #see https://msdn.microsoft.com/en-us/library/ms912391(v=winembedded.11).aspx
#- wimImageName = Windows 8.1 Pro # Image name seems only necessary if the WIM contains more than one image
%>
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
    <servicing></servicing>
    <settings pass="offlineServicing">
        <component name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <EnableLUA>false</EnableLUA>
        </component>
    </settings>
    <settings pass="windowsPE">
        <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <EnableFirewall>false</EnableFirewall>
            <EnableNetwork>true</EnableNetwork>
            <Restart>Restart</Restart>
            <ImageInstall>
                <OSImage>
                    <InstallFrom>
                        <MetaData wcm:action="add">
                                <Value><%= host_param('wimImageName') -%></Value>  
                        </MetaData>
                    </InstallFrom>
                    <InstallToAvailablePartition>true</InstallToAvailablePartition>
                    <WillShowUI>OnError</WillShowUI>
                </OSImage>
            </ImageInstall>
            <UserData>
                <AcceptEula>true</AcceptEula>
            </UserData>
        </component>
        <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <SetupUILanguage>
                <UILanguage>en-US</UILanguage>
            </SetupUILanguage>
            <% if host_param('systemLocale') -%>
              <InputLocale><%= host_param('systemLocale') %></InputLocale>
              <SystemLocale><%= host_param('systemLocale') %></SystemLocale>
              <UILanguageFallback>en-US</UILanguageFallback>
              <UILanguage><%= host_param('systemUILanguage') %></UILanguage>
              <UserLocale><%= host_param('systemLocale') %></UserLocale>
            <% else -%>
               <InputLocale>en-US</InputLocale>
              <SystemLocale>en-US</SystemLocale>
              <UILanguageFallback>en-US</UILanguageFallback>
              <UILanguage>en-US</UILanguage>
              <UserLocale>en-US</UserLocale>
            <% end -%>
        </component>
    </settings>
    <settings pass="oobeSystem">
        <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <% if host_param('systemLocale') -%>
              <InputLocale><%= host_param('systemLocale') -%></InputLocale>
              <SystemLocale><%= host_param('systemLocale') -%></SystemLocale>
              <UILanguageFallback>en-US</UILanguageFallback>
              <UILanguage><%= host_param('systemUILanguage') -%></UILanguage>
              <UserLocale><%= host_param('systemLocale') -%></UserLocale>
            <% else -%>
               <InputLocale>en-US</InputLocale>
              <SystemLocale>en-US</SystemLocale>
              <UILanguageFallback>en-US</UILanguageFallback>
              <UILanguage>en-US</UILanguage>
              <UserLocale>en-US</UserLocale>
            <% end -%>
        </component>
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <UserAccounts>
                <AdministratorPassword>
                    <PlainText>false</PlainText>
                    <Value><%= root_pass %></Value>
                </AdministratorPassword>
                <% if snippet('Wimaging local users') -%>
                  <%= snippet('Wimaging local users') -%>
                <% end %>
            </UserAccounts>
            <TimeZone><%= host_param('systemTimeZone') -%></TimeZone>
            <% if host_param('windowsLicenseOwner') -%>
              <RegisteredOrganization><%= host_param('windowsLicenseOwner') -%></RegisteredOrganization>
              <RegisteredOwner><%= host_param('windowsLicenseOwner') -%></RegisteredOwner>
            <% end -%>
            <OOBE>
                <HideEULAPage>true</HideEULAPage>
                <NetworkLocation>Work</NetworkLocation>
                <ProtectYourPC>1</ProtectYourPC>
                <SkipUserOOBE>true</SkipUserOOBE>
                <SkipMachineOOBE>true</SkipMachineOOBE>
                <HideLocalAccountScreen>true</HideLocalAccountScreen>
                <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
                <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
                <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
            </OOBE>
            <ShowWindowsLive>false</ShowWindowsLive>
            <% if host_param('windowsLicenseKey') -%>
              <ProductKey><%= host_param('windowsLicenseKey').to_s -%></ProductKey>
            <% end -%>
        </component>
    </settings>
    <settings pass="specialize">
        <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <% if host_param('systemLocale') -%>
              <InputLocale><%= host_param('systemLocale') -%></InputLocale>
              <SystemLocale><%= host_param('systemLocale') -%></SystemLocale>
              <UILanguage><%= host_param('systemUILanguage') -%></UILanguage>
              <UILanguageFallback>en-US</UILanguageFallback>
              <UserLocale><%= host_param('systemLocale') -%></UserLocale>
            <% else -%>
              <InputLocale>en-US</InputLocale>
              <SystemLocale>en-US</SystemLocale>
              <UILanguage>en-US</UILanguage>
              <UILanguageFallback>en-US</UILanguageFallback>
              <UserLocale>en-US</UserLocale>
            <% end -%>       
        </component>
        <component name="Microsoft-Windows-IE-ESC" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <IEHardenAdmin>false</IEHardenAdmin>
        </component>
        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <ComputerName><%= @host.shortname -%></ComputerName>
            <% if host_param('windowsLicenseOwner') -%>
              <RegisteredOrganization><%= host_param('windowsLicenseOwner') -%></RegisteredOrganization>
              <RegisteredOwner><%= host_param('windowsLicenseOwner') -%></RegisteredOwner>
            <% end -%>
            <% if host_param('systemTimeZone') -%>
              <TimeZone><%= host_param('systemTimeZone') -%></TimeZone>
            <% else -%>
              <TimeZone>Pacific Standard Time</TimeZone>
            <% end -%>
        </component>
        <component name="Networking-MPSSVC-Svc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <DomainProfile_EnableFirewall>false</DomainProfile_EnableFirewall>
            <PrivateProfile_EnableFirewall>false</PrivateProfile_EnableFirewall>
            <PublicProfile_EnableFirewall>false</PublicProfile_EnableFirewall>
        </component>
        <component name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon>
        </component>
        <component name="Microsoft-Windows-TerminalServices-LocalSessionManager" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <fDenyTSConnections>false</fDenyTSConnections>
        </component>
        <component name="Microsoft-Windows-TerminalServices-RDP-WinStationExtensions" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <SecurityLayer>1</SecurityLayer>
            <UserAuthentication>0</UserAuthentication>
        </component>
    </settings>
    <cpi:offlineImage cpi:source="catalog:c:/deploy/wimaging/sources/win81x64/sources/install_windows 8.1 pro.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>
Actions #31

Updated by John D. over 5 years ago

I am getting this error:

Warning! There was an error rendering the Windows Provision template: The specified snippet 'Wimaging local users' does not exist, or is not a snippet.

Actions #32

Updated by Shimon Shtein over 5 years ago

Sorry about it, forgot the dependency. Just add the template from here: https://github.com/kireevco/foreman-wimaging/blob/master/wimaging/wimaging_snip_local_users.xml.erb with the name "Wimaging local users"

Actions #33

Updated by John D. over 5 years ago

Okey, now to the other Windows template.
On the PXE template i am getting this error:

Warning! There was an error rendering the Windows PXE template: no implicit conversion of nil into String
<%#
kind: PXELinux
name: Wimaging default PXELinux
oses:
- Windows Server 2008
- Windows Server 2008 R2
- Windows Server 2012
- Windows Server 2012 R2
- Windows
%>
DEFAULT menu
LABEL menu
     COM32 linux.c32 boot/wimboot
     APPEND initrdfile=<%= @host.operatingsystem.bootfile(medium_provider,:bcd) %>,<%= @host.operatingsystem.bootfile(medium_provider,:bootsdi) %>,<%= @host.operatingsystem.bootfile(medium_provider,:bootwim) %>

At the moment i just edited password_crypt.rb, which only should concern the provisioning template. Am i right?

Actions #34

Updated by Bernard Landon over 5 years ago

I can confirm this template works for me:

DEFAULT menu
LABEL menu
     COM32 linux.c32 <%= @host.operatingsystem.bootfile(medium_provider,:kernel) %>
     APPEND initrdfile=<%= @host.operatingsystem.bootfile(medium_provider,:bcd) %>,<%= @host.operatingsystem.bootfile(medium_provider,:bootsdi) %>,<%= @host.operatingsystem.bootfile(medium_provider,:bootwim) %>

Wanna give it a go? You're using Foreman 1.20 aren't you?
How's the OS of the host you're trying to provision configured?

Actions #35

Updated by John D. over 5 years ago

Bernard Landon wrote:

I can confirm this template works for me:

[...]

Wanna give it a go? You're using Foreman 1.20 aren't you?
How's the OS of the host you're trying to provision configured?

Yeah, i am using 1.20.
Still getting the same error

Warning! There was an error rendering the Windows PXE template: no implicit conversion of nil into String
What changes did u made? Did u upgraded from Foreman 1.19 to Foreman 1.20?

Actions #36

Updated by Shimon Shtein over 5 years ago

It's a bit hard to tell without looking at the log file for a complete trace of the error.
I guess some property of the host is not set. Does it have valid operating system, medium and architecture?

Actions #37

Updated by Tomer Brisker about 5 years ago

  • Fixed in Releases 1.20.2, 1.21.0 added
Actions #38

Updated by Shimon Shtein about 5 years ago

  • Status changed from Ready For Testing to Closed
Actions #39

Updated by Ondřej Pražák about 5 years ago

  • Related to Support #26036: Windows templates are still not working with v1.21 added
Actions #40

Updated by Markus Bucher about 1 year ago

  • Related to Bug #35946: Windows password-encryption code changes input-value added
Actions #41

Updated by Markus Bucher about 1 year ago

  • Related to deleted (Bug #35946: Windows password-encryption code changes input-value)
Actions

Also available in: Atom PDF