How do I use facter's variables with Foreman smart classes?

Hi everyone!

I need to understand - what exactly method I can use to map facter’s output with ERB variables?
I trying to do something like this: import class which one parameter - ipaddr, then i’m going to Foreman - Smart Class Parameters and select ipaddr, I wanr to override this by ip-address of server where this class applied. I’ve try to set to override value the following string: <%= @facts.networking.ip %>. But it doesn’t work.

Could everybody point me to list of variables which I can use within overrides?
Thanks in advance!

Hi and welcome to the forum :slight_smile:

If you are looking for the network information specifically, Foreman provides that already via the ENC. It should be available as ::foreman_interfaces topscope variable in Puppet and so can be easily utilized in Puppetcode (although not through smart-class parameters).
For facts, you can generally do something in the form of <%= @host.facts['timezone'] %> to get fact values. I was not able to get networking information through this, but that might be due to some fact filter settings we’ve made.
For the primary IP (what you are looking for) though, you can also do <%= @host.primary_interface['ip'] %>. You can take a look at https://<yourforman>/templates_doc for a list of what you can reference in template strings.

Hi areyus!

Thanks a lot for you answer! I will test this and give you feedback.