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
I need to create a custom fact based on a parametric information (I need to get the IP of another machine knowing the hostname, the machine name could be different for different nodes so I need it parameteric and I recover the machine hostname from a hiera, but for the purpose of the question it could also be a data in the module definition).
I'm installing a cluster and need to get the master IP and if I can set the hostname as a fixed known information the IP will be variable since I'm installing it in a cloud environment
The custom facter code is:
# master_ip.rb: #
require 'facter'
if FileTest.exists?("/usr/bin/dig") cmd = sprintf('/usr/bin/dig +short HERE_GOES_THE PARAMETRIC_HOSTNAME') result = `#{cmd}` Facter.add("master_ip") do setcode { result } end end
Any Idea on how to refer to a data present in the module like $master_hostname or a hiera hash like $master_info['hostname']
Thanks
Dan White
unread,
Aug 28, 2013, 6:43:13 AM8/28/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
Do you know this information when you set up the server ? If so, just create an appropriate "host" resource
“Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.” Bill Waterson (Calvin & Hobbes)
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
This is altogether the wrong approach. The datum you wish to evaluate is not a property of the node, but rather a property of its environment, therefore it is not a node fact.
If you want the master IP to be a top-scope variable then it is possible to make it so without making it a node fact, though I think that would be a poor design choice. Instead, you should make it a class variable of some suitable class. Wherever you hang it, you can assign the value based on your looked-up hostname, using a custom function or perhaps the built-in generate() function.
John
Luca Gioppo
unread,
Aug 30, 2013, 4:42:26 AM8/30/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
You are right is not a node fact but an "env" datum, so I developed a function that get me the IP address of a Hostname and assigned to a variable of the node. Thanks Luca