I am creating a custom type and I cannot access the hiera scope from the default block for
module Puppet require 'puppet/parser/functions/hiera' newtype(:my_type) do ensurable newparam(:myparam) do defaultto { Puppet::Parser::Functions.hiera('myparam') } end newproperty(:value) do desc "Value of the item." end end end
But I get
Error: undefined method `hiera' for Puppet::Parser::Functions:Module
I am using Puppet 3.8 and the future parser
As a workaround, we use
$my_vals = hiera_hash('mytype_vals') create_resource(my_type, $myvals, {myparam => hiera('myparam')})
This works fine, but it is expected that my_type objects will be created somewhere in the directory, it is expected that myparam will be the same in all instances. Therefore, multiple declaration of a default value is not required.
Another approach would be to post
My_type{ myparam => hiera('myparam') }
In the manifest node. This would also work, but we are developing a module, and the main manifest is beyond the scope of our work.
puppet hiera
Raul andres
source share