Could not find a provider for

Problem:
Hi! Creating a new host on Foreman 1.20.0 I get this error:

Unable to save
Render user data template for edwin-holweger.svint.infocert.it task failed with the following error: undefined method ‘#params’ for Host::Managed::Jail (Host::Managed)

Expected outcome:

The new host created withoud errors.

Foreman and Proxy versions:

Foreman 1.20.0
Proxy 1.20.0

Foreman and Proxy plugin versions:

Other relevant data:

2018-12-03T11:37:49 [E|app|671a5] Could not find a provider for mindy-westrom.svint.infocert.it. Providers returned {"MediumProviders::Default"=>["CentOS 7.5 medium was not set for host 'mindy-westrom.svint.infocert.it'", "Invalid medium 
'' for 'CentOS 7.5'"]}
2018-12-03T11:37:49 [W|app|671a5] Render user data template for mindy-westrom.svint.infocert.it task failed with the following error: undefined method '#params' for Host::Managed::Jail (Host::Managed)
Safemode::NoMethodError: undefined method '#params' for Host::Managed::Jail (Host::Managed)

I found the solution.
My user data template used the attribute “params” that does not exist in Host::Managed::Jail.

This was my template:

# YAML file 
<%# 
kind: user_data 
name: vmware user data 
oses: 
- CentOS 6 
- CentOS 7 
- CentOS 7.1
- Redhat 6
- Redhat 7
- Redhat 7.1
-%> 

identity: 
  LinuxPrep: 
    domain: <%= @host.domain %> 
    hostName: <%= @host.shortname%>
    hwClockUTC: true 
    timeZone: <%= @host.params['time-zone'] || 'CET' %> 

globalIPSettings:
  dnsSuffixList: [<%= @host.domain %>]                                                                              
  <% @host.interfaces.each do |interface| %>                                                                                  # new line
  dnsServerList: [<%= interface.subnet.dns_primary %>, <%= interface.subnet.dns_secondary %>]    # new line
  <% end %>       

nicSettingMap: 
<% @host.interfaces.each do |interface| %> 
  - adapter: 
      dnsDomain: <%= interface.domain %> 
      dnsServerList: [<%= interface.subnet.dns_primary %>, <%= interface.subnet.dns_secondary %>] 
      gateway: [<%= interface.subnet.gateway %>] 
      ip: <%= interface.ip %> 
      subnetMask: <%= interface.subnet.mask %> 
<% end %> 

reboot: reboot

I removed the line

timeZone: <%= @host.params['time-zone'] || 'CET' %> 

and everything works.

Thanks

Claudio

@host.params has been deprecated in favor of the host_param macro, so you can rewrite the relevant part in the template as:

    timeZone: <%= host_param('time-zone', 'CET') %> 
1 Like