Global parameters and Foreman Variables

I want to be able to leverage some Foreman variables in Puppet for information already managed in Foreman. I have defined some global parameters, but they do not behave the same way when using Foreman variables vs. explicitly defining the information, even though the information is the same. For example:

Global Parameters:

nameservers  |  [<%= @host.subnet.dns_primary %>, <%= @host.subnet.dns_secondary %>] | Array
ntpservers      |  	["", ""] | Array

Host yaml output:

  nameservers: "[,]"

So, despite defining the nameservers as an Array, it is collapsed into a string when the Foreman variables are replaced.

Expected outcome:

The nameservers should be preserved as an array, and look just like the ntpservers in the yaml output.

Foreman and Proxy versions:
Foreman and Proxy plugin versions:

Distribution and version:
Centos 7.

Anyone know how it can be done to preserve the arrays? I did try defining it as YAML, and breaking each variable out as a yaml item, but those are similarly collapsed into a string.


There’s also @host.subnet.dns_servers which is an array. However, I suspect that ERB output is always a string and can never be a data type.

Thanks for that info. I tried that, and a few other things, and I’d say you’re correct in that ERB is always returning a string. I tried switching from array to yaml, and using the dns_primary and dns_secondary as yaml items, and the ENC output just showed the items as a string with the escaped new-line \r\n in between the items. I guess I’ll have to come at this from a different angle.

Thanks for the help!

/ Mike