I have successfully created a .rb custom fact that parses a built-in fact to create a new value, however I am now trying to use it as nested custom fact for Puppet.
The hierarchy I want to create is similar to built-in facts, eg running Facter (or Facter -p) would show:
custom_parent => {
custom_fact_1 => whatever
custom_fact_2 => whatever2
}
and usage in a puppet manifest would be:
$custom_parent.custom_fact_1
So far I have tried leading syntax such as:
Facter.add (:custom_parent)=>(custom_fact_1) do
Facter.add (:custom_parent)(:custom_fact_1) do
Facter.add (:custom_parent.custom_fact_1) do
Facter.add (:custom_parent:custom_fact_1) do
Facter.add (custom_parent:custom_fact_1) do
...and many other variations however cannot get a nested custom fact array to create. I've Googled for a while and if anyone knows if it is possible I would be very grateful.
I did find that nested facts can be created using an array in a .yaml file in the /etc/puppetlabs/facter/facts.d/ directory as below, however this sets FIXED values and does not process logic which I require in my custom fact.
{
"custom_parent":
{
"custom_fact_1": "whatever",
"custom_fact_2": "whatever2",
}
}
Thanks in advance.