Problem:
We’re finding ourselfs that in order to clean up our organisations Puppet code, we’d need a custom fact we’d be able to query and override on host/hostgroup basis. I already created a global parameter
that i can use in the way that i’d like. But it requires me to access that via $tenant. And i see a situation where at some point we’d like to add additional facts to the hash.
Expected outcome:
Ideally i’d have a Parameter that is automagically exported as a fact as well. Preferably as a facts hash, as e.g. $facts['company']['tenant']
. I can achieve such fact by creating a custom fact that is returned as a hashmap. I can’t however seem to find the right syntax to query global host params in Puppet.rb syntax.
Foreman and Proxy versions:
2.4.1
Foreman and Proxy plugin versions:
Distribution and version:
Ubuntu 18.04
Other relevant data:
I’ve tried numerous ways of achieving what i want, but so far unsuccesful. The docs are not helpful either. I’ve checked newer docs as well in the hopes that maybe someone has tried something similar and found the docs lacking and updated it with examples.
global parameter in Foreman
Name=tenant
Type=string
<%- domain = @host.certname -%>
<%- parts = @host.certname.split(".") -%>
<%- parts.shift() -%>
<%- if (parts.length > 0) -%>
<%- domain = parts.join(".") -%>
<%- end -%>
<%= domain-%>