Provisioning using Red Hat Satellite 6 fails with error `undefined method '#params' for Host::Managed::Jail.` after upgrading to Red Hat Satellite 6.4

Solution Verified - Updated -

Environment

  • Red Hat Satellite 6.4

Issue

  • Getting error undefined method '#params' for Host::Managed::Jail when provisioning a VM using Red Hat Satellite 6.

Resolution

  • Follow below steps on the Red Hat Satellite server to resolve the issue:

    • After upgrading Satellite to version 6.4, customized or cloned templates requires modification as follows.
    @host.params['parameter1'] -> host_param('parameter1')
    @host.param_true?('parameter1') -> host_param_true?('parameter1')
    @host.param_false?('parameter1') -> host_param_false?('parameter1')
    @host.info['parameters']['realm']  -> host_enc['parameters']['realm']
    
    • The process uses simple text replacement which will not work in all cases, e.g. when host is assigned to a variable:
    myhost = @host
    myhost.params['wont_work']
    
    • In the customized kickstart template, use the redhat_register snippet instead of subscription_manager_registration snippet.

      • The snippet used in the versions before Satellite 6.4 was:

        <%= snippet "subscription_manager_registration" %>
        
      • The snippet used from Satellite 6.4 onwards is:

        <%= snippet 'redhat_register' %>
        
  • After upgrading Satellite to version 6.4, verify all templates, parameters, lookup keys, and values of the old-syntax and replace them manually.

  • You can run the following query on the Satellite server to check what templates are still using the old syntax.

    # su - postgres -c "psql foreman -c \"select name, type, snippet from templates where template ilike '%host.params%';\""
    

Root Cause

  • Red Hat Satellite 6.4 upgrade process automatically tries to find macros that have been deprecated and convert them into new syntax for all templates, parameters, and lookup keys and values but this is done only for read-only (default) templates. All customized templates need to be modified manually.

  • From Satellite 6.4 onwards, the subscription_manager_registration snippet has been deprecated and replaced with redhat_register snippet.

Diagnostic Steps

  • The following error can be seen in /var/log/foreman/production.log.

    2018-04-29T08:11:03 [W|app|eac4b] There was an error rendering the Satellite Kickstart Default Finish template:
    | ActionView::Template::Error: undefined method '#params' for Host::Managed::Jail (Host::Managed)
    | /opt/theforeman/tfm/root/usr/share/gems/gems/safemode-1.3.4/lib/safemode/jail.rb:22:in `method_missing'
    | Satellite Kickstart Default Finish:66:in `bind'
    | /opt/theforeman/tfm/root/usr/share/gems/gems/safemode-1.3.4/lib/safemode.rb:51:in `eval'
    | /opt/theforeman/tfm/root/usr/share/gems/gems/safemode-1.3.4/lib/safemode.rb:51:in `eval'
    | /usr/share/foreman/lib/foreman/renderer.rb:128:in `render_safe'
    | /usr/share/foreman/lib/foreman/renderer.rb:246:in `unattended_render'
    

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

5 Comments

I Don't really like the idea " replace manually". Do you have any helper scripts for debugging?

Hello,

I have made all of the necessary changes but still get this error when this snippet is reached. I changed the @host.info to host_enc but there is still something in this block that isn't working. Still trying to dig into it, but if anybody could possibly take a look here and help, it would be greatly appreciated. Thank you!

<%= snippet "subscription_manager_registration" %>

<% if host_enc['parameters']['realm'] && @host.realm && @host.realm.realm_type == 'Red Hat Identity Management' -%> <%= snippet "idm_register" %> <% end -%>

Hi Alexander,

Is the error still '#params' for Host::Managed::Jail?

Did you change the syntax in "subscription_manager_registration" snippet too? It has a reference @host.params['kt_activation_keys'].

/var/log/foreman/production.log, will tell if issue is with any of the snippets.

A support case will help to identify faster.

Hi Rohan,

I did not realize it was referencing another template there. I found that template and will try correcting the syntax. Thank you very much for looking into this. I will report back when I have corrected all referenced templates.

There are periodic changes and deprecations of methods that are used with in templates. These are documented. If there have been any of these issues in Red Hat provided templates, they have been corrected in the release where the change occurs to the best of my knowledge. If you come across an issue like this, try taking a look at one of the Red Hat templates and you will usually see the problem. I ran into this the other day with my RHV provisioning template due to the change of media_uri to a function... Found the new template and fixed my cloned one. The preview tab really helps track these things down before trying to run another deployment.