> From this example you're trying to detect it any interface is on the
> 10.55.12.0 network,

  That's correct.   I have 4 specific subnet's I'm looking for in this
example.   A host may have zero interfaces on one of the specific
subnets or just 1.  I was wanting to return the ipaddress that the
host has on one of the specific subnets.


>
> Are you looking for a custom fact that will report a magic keyword?

 I was hoping I would be able to ask facter for the information as it
already contains it.  I just couldn't even figure out how to begin
formulating such a question (like trying to decide where to bite into
an oversized submarine sandwich!).   After Ashley's response and lack
of other ideas I put together the following custom fact which will
return the ipaddress the host has on the specific subnet's (if the
host has one).  I've not ventured down the custom fact road before so
this should be an little adventure.

Facter.add("nsd_gateway") do

    setcode do
    # Get the array of ip's on the machine
    output = %x{/sbin/ifconfig -a}
    ip = []
        # Put the ip addresses into the ip array
        output.each_line do |s|
         ip.push($1) if s =~ /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
        end
    ip.grep(/(14.1.22.|19.7.28.|15.0.8.)/)
    end
end




> > You could also assign the output of a template to a variable, then
> evaluate that.

Thanks for the alternate idea on using templating to solve the
problem.  I had not thought of that approach!

  Thanks!  Derek

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to