[Puppet Users] Hiera in custom facts?

2013-12-06 Thread leed

Hello all

So is it possible to use hiera data in a custom facts? I'm probably going 
about this all wrong, but I was hoping something like this would work.

Facter.add(cluster_name) do
  setcode do
   hiera('clustername')
  end
end

But I get a lot of

Could not retrieve cluster_name: undefined method `hiera' for 
:Facter::Util::Resolution

The fact that googling for this returns nothing is whats making me worried 
I'm going about it all wrong.

Just want to be able to have a custom fact that returns the cluster_name 
for a host if its set in its hiera data.

Cheers
Lee



-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/ac9f9f5f-36f5-4b5d-91a6-02ae5335685a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Puppet Users] Hiera in custom facts?

2013-12-06 Thread leed
On Friday, 6 December 2013 14:27:47 UTC, Felix.Frank wrote:


 If you want to use $clustername instead of hiera(clustername), just 
 add this to the global scope of your manifest: 

 $clustername = hiera(clustername) 


Thanks for your response, I'd tried adding that to the global scope 
(confirmed with a notify), but this doesn't seem to be passed to the custom 
facts, as these seem to be processed before hand?

So with 

Facter.add(cluster_name) do
  setcode do
$clustername
  end
end

I get :-

# facter --debug -p
value for cluster_name is still nil

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/f3c1f141-6553-48cc-b7d9-5da102c1d71a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.