Hello all,
To start, I would like to thank you in advance for your responses.
I'm attempting to create a custom fact that will determine the network
location of a node, based on it's hostname. Ideally this would be run on a
node prior to the rest of the puppet modules because I will use the result
as a top scope variable to assign certain values to nodes, based on their
network location. My node hostnames currently subscribe to this convention:
network-hostname/role-number (ie. home-elastic-01/work-mysql-02)
I've written a very simple fact to start with that looks like this (please
excuse my code as I'm quite new to ruby):
# custom fact for determining network location of node
#
require 'facter'
Facter.add(:network_geo) do
setcode do
hostname = Facter.value(:hostname)
hostname_array = hostname.split('-')
hostname_array
end
end
This fact obviously doesn't get me what I want yet, but I'd like to test
this on a node to ensure basic parsing of the hostname and this is where my
confusion comes in. I've created a puppet module called sys_ident and
added the above code into a file called network_geo.rb, located within the
/sys_ident/files/ directory.
It's my understanding that I have to add the /sys_ident/files/ path into
either the RUBYLIB or FACTERLIB environment path and I've done that
(although I don't understand how that fits into my master/agent setup and
if I need to add this into the path in the first place). However, my
expectation was that after the above, I could simply run 'facter | grep
network_geo' and I would see the hostname of my machine split up but that
is not the case. Instead, have to run 'facter -p network_geo' and I get
the desired output.
So my question is, do I want to or should I expect to use a custom fact by
simply running 'facter network_geo' or will I have to run 'facter -p
<custom fact>' to invoke my fact. Also, if I run puppet and this module
does run, can I identify this fact as a normal top scope variable in my
manifests ?
If anybody has a good link that explains this, I would be most appreciative
as I'm a bit confused.
Once again, thank you for your time in advance as it's most appreciated.
Cheers,
Mike
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/fc786711-e4ab-405a-a00e-d43121275835%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.