"How can I utilize Facter's variables in conjunction with Foreman's smart classes?"

"Hello, everyone!

I’m trying to figure out the method for mapping Facter’s output with ERB variables. Specifically, I want to import a class with a parameter like ‘ipaddr’ and then navigate to Foreman’s Smart Class Parameters to select ‘ipaddr.’ I aim to override it with the server’s IP address where this class is applied. I attempted to use the following string as the override value: ‘<%= @facts.networking.ip %>’, but it didn’t yield the desired result.

Could someone please direct me to a list of variables I can use within overrides?

Thanks in advance!"

Hi,

templates in smart-class parameters behave just like any template would anywhere else. You can look up a lot of information on template writing on your Foreman’s edit page of any templates (ptables, provisioning templates, etc) under the help tab. There you can also find a like to <yourforeman>/templates_doc which has more information on many of the available functions.

From what you provided, you are probably looking for @host.facts or @host.facts_hash, though the networking information that is configured in Foreman for a host (and automatically updated through Puppet reports by default) can also be accessed through @host.interfaces.

Hope this helps :slight_smile: