Accessing smart param in a template

Hi Team,

I am new to template writing, I am trying to create a new sh template which needs to access a class parameter.

I am trying below :

$splunk_home/bin/splunk show cluster-status -auth userId:<%=@host.info[‘classes’][‘splunk_class’][‘splunk_password’] %>

I have my password under a parameter called splunk_password defined under splunk_class (is above is the correct method to access it?)

I am getting below error when trying this. any leads ?

I’ve tried reading template writing doc but nothing specific to class paramters there.

Failed to initialize: RuntimeError - Failed rendering template: error during rendering: undefined method ‘#info’ for Host::Managed::Jail (Host::Managed)

Hello,

instead of

<%=@host.info[‘classes’][‘splunk_class’][‘splunk_password’] %>

try

<%= host_enc[‘classes’][‘splunk_class’][‘splunk_password’] %>

and let us know if that works.

Hi @Marek_Hulan,

Thanks for above, I am getting below when I preview my template before executing:

Warning! Problem with previewing the template: error during rendering: undefined method ‘#’ for NilClass::Jail (NilClass). Note that you must save template input changes before you try to preview it.

but when I save it with actual password it works fine. may be syntax is not correct what I am using?

I have added a script which directly go and get it from vault where we have stored this value.

Thanks for your inputs :slight_smile: