Use scope.lookupvar on the variable from the manifest: ## Manifest class foo ( $ip = hiera(''jrs_config_server1', ''), ) { }
## Template <% ip = scope.lookupvar('foo::ip') -%> ... On May 10, 2013, at 6:18 AM, Jonathan Gazeley <jonathan.gaze...@bristol.ac.uk> wrote: > Hi, > > I'm having a problem accessing Hiera data from within templates. Yes, I know > this is not the recommended way to access Hiera data, but in my use case I > think it will be easier overall. > > In manifests, this code works: > > { > ip => hiera('jrs_config_server1'), > } > > In a template, part of the same module as the manifest, this does not work: > > ipaddr = <%= scope.function_hiera(["jrs_config_server1"]) %> > > It fails with this error: > > Could not find data item jrs_config_server1 in any Hiera data file and no > default supplied > > The value of " jrs_config_server1" is in Hiera, specific to the fqdn of the > node. I'm struggling to see why it would not be working. Any ideas? > > Cheers, > Jonathan > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscr...@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.