You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to puppet...@googlegroups.com
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
Felix Frank
unread,
Dec 6, 2013, 9:27:47 AM12/6/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to puppet...@googlegroups.com
Hi,
this is in fact not the right approach.
Facts are evaluated on the agent side, while hiera typically belongs to
the master side only.
If you want to use $clustername instead of hiera("clustername"), just
add this to the global scope of your manifest:
$clustername = hiera("clustername")
HTH,
Felix
leed
unread,
Dec 6, 2013, 10:08:44 AM12/6/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to puppet...@googlegroups.com
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
Felix Frank
unread,
Dec 6, 2013, 10:13:24 AM12/6/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to puppet...@googlegroups.com
Again: You *cannot* get hiera values into facter, nor would that be
particularly useful (at least from the master's perspective).
Johan De Wit
unread,
Dec 8, 2013, 7:12:53 AM12/8/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to puppet...@googlegroups.com
Trying to explain a little bit more, here is the flow of a puppet run on
a node :
On the node : agent starts - gathers all the facts. ( facter -p if you
want to see what is gathered)
Node sends it to the puppet master
Puppet masters compiles the catalog, using those facte, and looking up
all classes assigned to that node. It is here hiera comes in action.
Compiled catalog is send to the Node
Node executes the catalog, and sends a report back to the puppet master
I hope you see now why hiera and facts dont work together
grts
jo
--
Johan De Wit
Open Source Consultant
Red Hat Certified Engineer (805008667232363)
Puppet Certified Professional 2013 (PCP0000006)
_________________________________________________________