Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.

Bug 1364491

Summary: [RFE] for extending safemode to include hostname resolution
Product: Red Hat Satellite 6 Reporter: ckyriaki
Component: Provisioning TemplatesAssignee: Lukas Zapletal <lzap>
Status: CLOSED ERRATA QA Contact: Jitendra Yejare <jyejare>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1.9CC: bbuckingham, bkearney, jcallaha, lzap, sghai, tbrisker
Target Milestone: UnspecifiedKeywords: FutureFeature, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/16057
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-21 16:54:17 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description ckyriaki 2016-08-05 13:39:04 UTC
Description of problem:
I am testing a discovery method for the following use case:
Company has an external DNS and DHCP method that isn't allowed to integrate with satellite. 
Each host is entered in DHCP  and DNS as a static entry therefore each host on boot is getting a valid IP, gateway and hostname. This means that the hostname parameter in a discovery rule can just be a lookup of the IP address the host is booting with.

This seems to work in discovery rules with safemode off <%=  Resolv.getname(@host.ip) %>. Safemode off allows for other things that aren't as harmless to the product. It would make sense to add Resolv.getname(@host.ip) to the safe list.


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.Follow the documentation to enable discovery mode 
ckyriakidou
5:04 PM https://access.redhat.com/documentation/en-US/Red_Hat_Satellite/6.1/html/User_Guide/chap-Red_Hat_Satellite-User_Guide-Discovering_Bare_metal_Hosts_on_Satellite.html
2.Create the necessary hostgroups and subnets to do it automatically
3. Create an entry in dhcp and dns for the host you're booting up 
4. create a discovery rule to point to the host group you have created  with <%=  Resolv.getname(@host.ip) %> as the hostname parameter
5. Create a tftp configuration for the above
6. boot the host

Actual results:
Satellite returns error 500 to host
and I can see the following satellite error message in the log

2016-08-05 14:32:35 [E] Safemode doesn't allow to access 'constant' on Resolv (Safemode::SecurityError)
/opt/rh/ruby193/root/usr/share/gems/gems/safemode-1.2.1/lib/safemode/parser.rb:123:in `raise_security_error'
/opt/rh/ruby193/root/usr/share/gems/gems/safemode-1.2.1/lib/safemode/parser.rb:118:in `process_const'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:218:in `block (2 levels) in process'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:275:in `error_handler'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:217:in `block in process'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:340:in `in_context'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:194:in `process'
/opt/rh/ruby193/root/usr/share/gems/gems/safemode-1.2.1/lib/safemode/parser.rb:131:in `process_call_receiver'
/opt/rh/ruby193/root/usr/share/gems/gems/safemode-1.2.1/lib/safemode/parser.rb:36:in `process_call'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:218:in `block (2 levels) in process'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:275:in `error_handler'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:217:in `block in process'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:340:in `in_context'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:194:in `process'
/opt/rh/ruby193/root/usr/share/gems/gems/safemode-1.2.1/lib/safemode/parser.rb:131:in `process_call_receiver'
/opt/rh/ruby193/root/usr/share/gems/gems/safemode-1.2.1/lib/safemode/parser.rb:36:in `process_call'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:218:in `block (2 levels) in process'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:275:in `error_handler'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:217:in `block in process'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:340:in `in_context'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:194:in `process'
/opt/rh/ruby193/root/usr/share/gems/gems/safemode-1.2.1/lib/safemode/parser.rb:144:in `process_call_args'
/opt/rh/ruby193/root/usr/share/gems/gems/safemode-1.2.1/lib/safemode/parser.rb:38:in `process_call'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:218:in `block (2 levels) in process'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:275:in `error_handler'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:217:in `block in process'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:340:in `in_context'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:194:in `process'
/opt/rh/ruby193/root/usr/share/gems/gems/ruby2ruby-2.0.1/lib/ruby2ruby.rb:152:in `process_block'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:218:in `block (2 levels) in process'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:275:in `error_handler'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:217:in `block in process'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:340:in `in_context'
/opt/rh/ruby193/root/usr/share/gems/gems/sexp_processor-4.1.3/lib/sexp_processor.rb:194:in `process'
/opt/rh/ruby193/root/usr/share/gems/gems/safemode-1.2.1/lib/safemode/parser.rb:10:in `jail'
/opt/rh/ruby193/root/usr/share/gems/gems/safemode-1.2.1/lib/safemode.rb:49:in `eval'
/usr/share/foreman/lib/foreman/renderer.rb:20:in `render_safe'
/usr/share/foreman/lib/foreman/renderer.rb:105:in `unattended_render'
/usr/share/foreman/app/models/host/managed.rb:824:in `render_template'
/opt/rh/ruby193/root/usr/share/gems/gems/foreman_discovery-2.0.0.23/app/controllers/concerns/foreman/controller/discovered_extensions.rb:40:in `block in perform_auto_provision'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:208:in `transaction'
/usr/share/foreman/app/models/host.rb:16:in `method_missing'
/opt/rh/ruby193/root/usr/share/gems/gems/foreman_discovery-2.0.0.23/app/controllers/concerns/foreman/controller/discovered_extensions.rb:33:in `perform_auto_provision'
/opt/rh/ruby193/root/usr/share/gems/gems/foreman_discovery-2.0.0.23/app/controllers/api/v2/discovered_hosts_controller.rb:105:in `block in facts'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:208:in `transaction'
/usr/share/foreman/app/models/host.rb:16:in `method_missing'
/opt/rh/ruby193/root/usr/share/gems/gems/foreman_discovery-2.0.0.23/app/controllers/api/v2/discovered_hosts_controller.rb:103:in `facts'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/abstract_controller/base.rb:167:in `process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/rendering.rb:10:in `process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:506:in `block (4 levels) in _run__3781711380016289953__process_action__2630655747117609488__callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_11486'
/usr/share/foreman/app/controllers/api/v2/base_controller.rb:151:in `disable_json_root'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_11486'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:505:in `block (3 levels) in _run__3781711380016289953__process_action__2630655747117609488__callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_11485'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:326:in `around'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:310:in `_callback_around_3883'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_11485'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:493:in `block (2 levels) in _run__3781711380016289953__process_action__2630655747117609488__callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_11484'
/usr/share/foreman/app/models/concerns/foreman/thread_session.rb:33:in `clear_thread'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_11484'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:426:in `block in _run__3781711380016289953__process_action__2630655747117609488__callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_11483'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:326:in `around'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:310:in `_callback_around_13'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_11483'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:414:in `_run__3781711380016289953__process_action__2630655747117609488__callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/abstract_controller/callbacks.rb:17:in `process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/rescue.rb:29:in `process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/notifications.rb:123:in `block in instrument'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/notifications.rb:123:in `instrument'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/abstract_controller/base.rb:121:in `process'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/abstract_controller/rendering.rb:45:in `process'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal.rb:203:in `dispatch'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal.rb:246:in `block in action'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:73:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:36:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/routing/mapper.rb:42:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
/opt/rh/ruby193/root/usr/share/gems/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
/opt/rh/ruby193/root/usr/share/gems/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:600:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/static.rb:62:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/static.rb:62:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/apipie-rails-0.2.5/lib/apipie/extractor/recorder.rb:97:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/static.rb:62:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/static.rb:62:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/static.rb:62:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/static.rb:62:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:205:in `context'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:200:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/apipie-rails-0.2.5/lib/apipie/middleware/checksum_in_headers.rb:27:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/etag.rb:23:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/conditionalget.rb:35:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/head.rb:14:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
/usr/share/foreman/lib/middleware/catch_json_parse_errors.rb:9:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/flash.rb:242:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:205:in `context'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:200:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/cookies.rb:339:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/query_cache.rb:64:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `_run__1000070191998565431__call__4146440614982097847__callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-2.2.0.92/lib/katello/middleware/silenced_logger.rb:29:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/request_id.rb:22:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_dispatch/middleware/static.rb:62:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:143:in `pass'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:155:in `invalidate'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:71:in `call!'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/engine.rb:479:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/application.rb:223:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/builder.rb:134:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/urlmap.rb:64:in `block in call'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/urlmap.rb:49:in `each'
/opt/rh/ruby193/root/usr/share/gems/gems/rack-1.4.1/lib/rack/urlmap.rb:49:in `call'
/usr/share/gems/gems/passenger-4.0.18/lib/phusion_passenger/rack/thread_handler_extension.rb:77:in `process_request'
/usr/share/gems/gems/passenger-4.0.18/lib/phusion_passenger/request_handler/thread_handler.rb:140:in `accept_and_process_next_request'
/usr/share/gems/gems/passenger-4.0.18/lib/phusion_passenger/request_handler/thread_handler.rb:108:in `main_loop'
/usr/share/gems/gems/passenger-4.0.18/lib/phusion_passenger/request_handler.rb:441:in `block (3 levels) in start_threads'
/opt/rh/ruby193/root/usr/share/gems/gems/logging-1.8.1/lib/logging/diagnostic_context.rb:323:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/logging-1.8.1/lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'
2016-08-05 14:32:35 [I]   Rendered api/v2/errors/standard_error.json.rabl within api/v2/layouts/error_layout (0.5ms)
2016-08-05 14:32:35 [I] Completed 500 Internal Server Error in 379ms (Views: 1.5ms | ActiveRecord: 47.0ms)


Expected results:
To allow the bit of code that looks up a hostname as part of the safemode rendering.

Additional info:

Comment 1 ckyriaki 2016-08-10 14:16:35 UTC
Hello,
given that this is a sensible way that things would work with an external DNS and DHCP (non-integrated) installation, shouldn't this be considered as a bug and have the priority increased?
Regards,
Christina Kyriakidou

Comment 2 Brad Buckingham 2016-08-10 16:52:30 UTC
Hi Christina, I'd like for the component owner to take a look at the bugzilla as it has not gone through devel triaging.  During that phase an engineer more familiar with this area will be able to validate the request and can adjust priority accordingly.  Thanks!

Comment 3 Lukas Zapletal 2016-08-11 08:25:28 UTC
This is an easy change, let's put it on product backlog and we can put it on our sprint for upstream work.

Comment 4 Bryan Kearney 2016-08-11 10:16:53 UTC
Upstream bug component is Provisioning Templates

Comment 5 Bryan Kearney 2016-08-26 10:18:39 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/16057 has been closed

Comment 11 Jitendra Yejare 2018-02-07 10:25:55 UTC
Verified!

@ Satellite 6.3 snap 32/33

Steps:

As per discussion with Assignee on irc:

```
<lzap> jyejare: the purpose of this BZ is that there is now new helper function: dns_lookup
<lzap> https://github.com/theforeman/foreman/pull/3758/files
<lzap> jyejare: it resolves you IP address to name and vice versa (name to IP)
<lzap> jyejare: test scenario - in safemode create a template that resolves www.google.com and an ip address back to name
<lzap> that's all
<lzap> jyejare: you dont need anything configured, it uses satellites /etc/resolv.conf
jyejare> lzap, so even i need not to have discovery and host?
<lzap> nope
```
So as per chat,
1.  Created new / modified provisioning template with new dns_lookup function and provided www.google.com as a parameter.
<%= dns_lookup('www.google.com') %>
2. Rendered the template in safe mode

Observation:
In safemode, The template rendered without any error and it resolved ip from host (and vice-versa).


Logs:
```
2018-02-07 05:16:16 9ea6ddf0 [app] [I] Started POST "/templates/provisioning_templates/136-Satellite%20Kickstart%20Default_test2/preview" for 10.65.223.209 at 2018-02-07 05:16:16 -0500
2018-02-07 05:16:16 9ea6ddf0 [app] [I] Processing by ProvisioningTemplatesController#preview as */*
2018-02-07 05:16:16 9ea6ddf0 [app] [I]   Parameters: {"template"=>"<%#\nkind: provision\nname: Satellite Kickstart default\noses:\n- CentOS 5\n- CentOS 6\n- CentOS 7\n- RedHat 5\n- RedHat 6\n- RedHat 7\n- Fedora 19\n- Fedora 20\n%>\n<%= dns_lookup('www.google.com') %>\n<%\n  rhel_compatible = @host.operatingsystem.family == 'Redhat' && @host.operatingsystem.name != 'Fedora'\n  os_major = @host.operatingsystem.major.to_i\n  # safemode renderer does not support unary negation\n  pm_set = @host.puppetmaster.empty? ? false : true\n  puppet_enabled = pm_set || @host.params['force-puppet']\n  salt_enabled = @host.params['salt_master'] ? true : false\n  chef_enabled = @host.respond_to?(:chef_proxy) && @host.chef_proxy\n  section_end = (rhel_compatible && os_major <= 5) ? '' : '%end'\n%>\ninstall\n<%= @mediapath %>\nlang en_US.UTF-8\nselinux --enforcing\nkeyboard us\nskipx\n\n<% subnet = @host.subnet -%>\n<% if subnet.respond_to?(:dhcp_boot_mode?) -%>\n<% dhcp = subnet.dhcp_boot_mode? && !@static -%>\n<% else -%>\n<% dhcp = !@static -%>\n<% end -%>\n\nnetwork --bootproto <%= dhcp ? 'dhcp' : \"static --ip=\#{@host.ip} --netmask=\#{subnet.mask} --gateway=\#{subnet.gateway} --nameserver=\#{[subnet.dns_primary, subnet.dns_secondary].select{ |item| item.present? }.join(',')}\" %> --hostname <%= @host %><%= os_major >= 6 ? \" --device=\#{@host.mac}\" : '' -%>\n\nrootpw --iscrypted <%= root_pass %>\nfirewall --<%= os_major >= 6 ? 'service=' : '' %>ssh\nauthconfig --useshadow --passalgo=<%= @host.operatingsystem.password_hash || 'sha256' %> --kickstart\ntimezone --utc <%= @host.params['time-zone'] || 'UTC' %>\n\n<% if @host.operatingsystem.name == 'Fedora' and os_major <= 16 -%>\n# Bootloader exception for Fedora 16:\nbootloader --append=\"nofb quiet splash=quiet <%=ks_console%>\" <%= grub_pass %>\npart biosboot --fstype=biosboot --size=1\n<% else -%>\nbootloader --location=mbr --append=\"nofb quiet splash=quiet\" <%= grub_pass %>\n<% end -%>\n\n<% if os_major == 5 -%>\nkey --skip\n<% end -%>\n\n<% if @dynamic -%>\n%include /tmp/diskpart.cfg\n<% else -%>\n<%= @host.diskLayout %>\n<% end -%>\n\ntext\nreboot\n\n%packages --ignoremissing\nyum\ndhclient\nntp\nwget\n@Core\n<%= section_end -%>\n\n<% if @dynamic -%>\n%pre\n<%= @host.diskLayout %>\n<%= section_end -%>\n<% end -%>\n\n%post --nochroot\nexec < /dev/tty3 > /dev/tty3\n#changing to VT 3 so that we can see whats going on....\n/usr/bin/chvt 3\n(\ncp -va /etc/resolv.conf /mnt/sysimage/etc/resolv.conf\n/usr/bin/chvt 1\n) 2>&1 | tee /mnt/sysimage/root/install.postnochroot.log\n<%= section_end -%>\n\n\n%post\nlogger \"Starting anaconda <%= @host %> postinstall\"\nexec < /dev/tty3 > /dev/tty3\n#changing to VT 3 so that we can see whats going on....\n/usr/bin/chvt 3\n(\n<% if subnet.respond_to?(:dhcp_boot_mode?) -%>\n<%= snippet 'kickstart_networking_setup' %>\n<% end -%>\n\n#update local time\necho \"updating system time\"\n/usr/sbin/ntpdate -sub <%= @host.params['ntp-server'] || '0.fedora.pool.ntp.org' %>\n/usr/sbin/hwclock --systohc\n\n<%= snippet \"subscription_manager_registration\" %>\n\n<% if @host.info['parameters']['realm'] && @host.realm && @host.realm.realm_type == 'Red Hat Identity Management' -%>\n<%= snippet \"idm_register\" %>\n<% end -%>\n\n# update all the base packages from the updates repository\nyum -t -y -e 0 update\n\n<%= snippet('remote_execution_ssh_keys') %>\n\n<% if chef_enabled %>\n<%= snippet 'chef_client' %>\n<% end -%>\n\n<% if puppet_enabled %>\n<%= snippet 'puppet_setup' %>\n<% end -%>\n\n<% if salt_enabled %>\n<%= snippet 'saltstack_setup' %>\n<% end -%>\n\n<%= snippet('ansible_provisioning_callback') %>\n\nsync\n\n<% if @provisioning_type == nil || @provisioning_type == 'host' -%>\n# Inform the build system that we are done.\necho \"Informing Foreman that we are built\"\nwget -q -O /dev/null --no-check-certificate <%= foreman_url('built') %>\n<% end -%>\n) 2>&1 | tee /root/install.post.log\nexit 0\n\n<%= section_end -%>\n", "preview_host_id"=>"", "id"=>"136-Satellite Kickstart Default_test2"}
2018-02-07 05:16:16 9ea6ddf0 [app] [I] Current user: admin (administrator)
2018-02-07 05:16:16 9ea6ddf0 [app] [I] Expire fragment views/tabs_and_title_records-3 (0.1ms)
2018-02-07 05:16:16 9ea6ddf0 [templates] [I] Rendering template 'Kickstart default'
2018-02-07 05:16:16 9ea6ddf0 [templates] [I] Rendering template 'Satellite Kickstart Default_test2'
2018-02-07 05:16:16 9ea6ddf0 [app] [W] DEPRECATION WARNING: you are using deprecated @host.params in a template, it will be removed in 1.17. Use host_param instead.
2018-02-07 05:16:16 9ea6ddf0 [app] [W] DEPRECATION WARNING: you are using deprecated @host.params in a template, it will be removed in 1.17. Use host_param instead.
2018-02-07 05:16:16 9ea6ddf0 [templates] [I] Rendering template 'Kickstart default'
2018-02-07 05:16:16 9ea6ddf0 [templates] [I] Rendering template 'kickstart_networking_setup'
2018-02-07 05:16:16 9ea6ddf0 [templates] [I] Rendering template 'kickstart_ifcfg_get_identifier_names'
2018-02-07 05:16:16 9ea6ddf0 [templates] [I] Rendering template 'kickstart_ifcfg_generic_interface'
2018-02-07 05:16:16 9ea6ddf0 [app] [W] DEPRECATION WARNING: you are using deprecated @host.params in a template, it will be removed in 1.17. Use host_param instead.
2018-02-07 05:16:16 9ea6ddf0 [templates] [I] Rendering template 'subscription_manager_registration'
2018-02-07 05:16:16 9ea6ddf0 [app] [W] DEPRECATION WARNING: you are using deprecated @host.params in a template, it will be removed in 1.17. Use host_param instead.
2018-02-07 05:16:16 9ea6ddf0 [app] [W] DEPRECATION WARNING: you are using deprecated @host.params in a template, it will be removed in 1.17. Use host_param instead.
2018-02-07 05:16:16 9ea6ddf0 [app] [W] DEPRECATION WARNING: you are using deprecated @host.info in a template, it will be removed in 1.17. Use host_enc instead.
2018-02-07 05:16:16 9ea6ddf0 [templates] [I] Rendering template 'remote_execution_ssh_keys'
2018-02-07 05:16:16 9ea6ddf0 [app] [W] DEPRECATION WARNING: you are using deprecated @host.params in a template, it will be removed in 1.17. Use host_param instead.
2018-02-07 05:16:16 9ea6ddf0 [app] [W] DEPRECATION WARNING: you are using deprecated @host.params in a template, it will be removed in 1.17. Use host_param instead.
2018-02-07 05:16:16 9ea6ddf0 [app] [W] DEPRECATION WARNING: you are using deprecated @host.params in a template, it will be removed in 1.17. Use host_param instead.
2018-02-07 05:16:16 9ea6ddf0 [templates] [I] Rendering template 'puppet_setup'
2018-02-07 05:16:16 9ea6ddf0 [app] [W] DEPRECATION WARNING: you are using deprecated @host.param_true? in a template, it will be removed in 1.17. Use host_param_true? instead.
2018-02-07 05:16:16 9ea6ddf0 [app] [W] DEPRECATION WARNING: you are using deprecated @host.params in a template, it will be removed in 1.17. Use host_param instead.
2018-02-07 05:16:16 9ea6ddf0 [app] [W] DEPRECATION WARNING: you are using deprecated @host.param_true? in a template, it will be removed in 1.17. Use host_param_true? instead.
2018-02-07 05:16:16 9ea6ddf0 [app] [W] DEPRECATION WARNING: you are using deprecated @host.params in a template, it will be removed in 1.17. Use host_param instead.
2018-02-07 05:16:16 9ea6ddf0 [templates] [I] Rendering template 'puppet.conf'
2018-02-07 05:16:16 9ea6ddf0 [app] [W] DEPRECATION WARNING: you are using deprecated @host.param_true? in a template, it will be removed in 1.17. Use host_param_true? instead.
2018-02-07 05:16:16 9ea6ddf0 [app] [W] DEPRECATION WARNING: you are using deprecated @host.params in a template, it will be removed in 1.17. Use host_param instead.
2018-02-07 05:16:16 9ea6ddf0 [app] [W] DEPRECATION WARNING: you are using deprecated @host.param_true? in a template, it will be removed in 1.17. Use host_param_true? instead.
2018-02-07 05:16:16 9ea6ddf0 [app] [W] DEPRECATION WARNING: you are using deprecated @host.params in a template, it will be removed in 1.17. Use host_param instead.
2018-02-07 05:16:17 9ea6ddf0 [app] [W] DEPRECATION WARNING: you are using deprecated @host.param_true? in a template, it will be removed in 1.17. Use host_param_true? instead.
2018-02-07 05:16:17 9ea6ddf0 [app] [W] DEPRECATION WARNING: you are using deprecated @host.params in a template, it will be removed in 1.17. Use host_param instead.
2018-02-07 05:16:17 9ea6ddf0 [templates] [I] Rendering template 'ansible_provisioning_callback'
2018-02-07 05:16:17 9ea6ddf0 [app] [I]   Rendered text template (0.0ms)
2018-02-07 05:16:17 9ea6ddf0 [app] [I] Completed 200 OK in 1033ms (Views: 0.6ms | ActiveRecord: 59.8ms)

```
Hence changing the state to Verified.

Comment 12 pm-sat@redhat.com 2018-02-21 16:54:17 UTC
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA.
> 
> For information on the advisory, and where to find the updated files, follow the link below.
> 
> If the solution does not work for you, open a new bug report.
> 
> https://access.redhat.com/errata/RHSA-2018:0336