Hi,
This is what you are looking for, I guess.
@datacenter.rb
require 'facter'
Facter.add(:datacenter) do
setcode do
datacenters = { '10.220' => 'HOUSTON', '10.221' =>
'AUSTIN' }
ip = Facter.value(:ipaddress)
network = datacenters.keys.find { |val| ip.include? val }
datacenter = datacenters[network]
datacenter
end
end
On Sunday 09 November 2014 02:52 AM, Felix Frank wrote:
Hi,
this is a misunderstanding. What you implemented is a native custom
fact. You cannot deploy it along with your external facts.
Instead of putting is in some_module/facts.d/, move it to
some_module/lib/facter/ instead. It will be synced as a custom fact
and should then work.
With external facts, you would need to make your Ruby script print
datacenter=HOUSTON
or
datacenter=AUSTIN
on stdout.
HTH,
Felix
On 10/23/2014 09:01 PM, Difladermaus wrote:
facter --debug returns
Fact file /etc/puppetlabs/facter/facts.d/datacenter.rb was parsed but
returned an empty data set
Any help appreciate
# cat /etc/puppetlabs/facter/facts.d/datacenter.rb
Facter.add("datacenter") do
setcode do
datacenter = "unknown"
# Get current ip address from Facter's own database
ipaddr = Facter.value(:ipaddress)
######################################## HOUSTON data center
if ipaddr.match("^10.220.")
datacenter = "HOUSTON"
######################################## AUSTIN data center
elsif ipaddr.match("^10.221.")
datacenter = "AUSTIN"
end
datacenter
end
end
--
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]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/545E898C.5070606%40Alumni.TU-Berlin.de
<https://groups.google.com/d/msgid/puppet-users/545E898C.5070606%40Alumni.TU-Berlin.de?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
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/54633C97.9040605%40gmail.com.
For more options, visit https://groups.google.com/d/optout.