Hello all,
I'm attempting to create a custom fact to identify the network to which a node belongs to. Below is the fact definition (I realize this fact isn't complete but wanted to test what I have so far):
require 'facter'
Facter.add('network_geo') do
setcode do
hostname = Facter.value(:hostname)
hostname_array = hostname.split('-')
# debug info
puts "My network is #{hostname_array}"
end
end
I then added the fact into a module named sys_ident and more specifically, into a directory like so: /modules/sys_ident/lib/facter/network_geo.rb
For debugging purposes, I created a quick init.pp for the sys_ident module and added this:
class sys_ident {
notify{"My network identity is: ${network_geo}" :}
notify{"My hostname identity is: ${hostname}" :}
}
I then turned on pluginsync on both the puppetmaster and client within puppet.conf.
After an initial run on my puppet client, I'm getting the following:
seanconnery-02:/$ sudo puppet agent -tv
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts in /var/lib/puppet/lib/facter/network_geo.rb
My network is ["seanconnery", "02"]
My network is ["seanconnery", "02"]
Info: Caching catalog for seanconnery-02.domain
Info: Applying configuration version '1409685071'
Notice: My network identity is:
Notice: /Stage[main]/Sys_ident/Notify[My network identity is: ]/message: defined 'message' as 'My network identity is: '
Notice: My hostname identity is: seanconnery-02
Notice: /Stage[main]/Sys_ident/Notify[My hostname identity is: seanconnery-02]/message: defined 'message' as 'My hostname identity is: seanconnery-02'
Notice: Finished catalog run in 0.04 seconds
As you can see from the output, I'm not receiving the expected output from my "network_geo" notify parameter (also not sure why I'm getting the "My network" twice. If I run facter from the puppet client, I get nothing in return:
seanconnery-02:/$ facter -p network_geo
For good measure, running the same command with the "hostname" fact produces this:
seanconnery-02:/$ facter -p hostname
seanconnery-02
Based on the output from my client run, it does look like the fact is making it to the client but I can't seem to actually invoke it.
I feel that things are generally in the right place and after considerable troubleshooting, the only thing I can think of is a potential order-of-operations problem.
Does anybody have any suggestions as to why this may be occurring?
Thank you in advance for your time and support and my apologies for the extra-long post.
Cheers,
Mike