On Thursday, October 23, 2014 2:01:37 PM UTC-5, 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
>
Here's a question: why do you need or want this as a fact? The values you
are computing are completely derivative of existing facts, so there is
little or no advantage to computing them on the client. I would recommend
you compute them on the master instead. You can make them ordinary
top-scope variables, or -- my preference -- make them class variables.
*As a top-scope variable:*
environments/production/00globals.pp
----
$datacenter = $ipaddress ? {
/^10\.220\. => 'HOUSTON',
/^10\.221\. => 'AUSTIN'
}
... (anywhere) ...
notice("${::datacenter} data center")
*As a class variable:*
modules/site/manifests/init.pp
----
class site {
$datacenter = $ipaddress ? {
/^10\.220\. => 'HOUSTON',
/^10\.221\. => 'AUSTIN'
}
}
... (elsewhere) ...
include 'site'
notice("${::site::datacenter} data center")
John
--
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/29203c3c-bdd8-4e1e-8028-7a4b6d626ab1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.