On 2014-03-26 11:09, Craig Dunn wrote:
### Global `$facts` Hash
You have to manually enable this (along with the `$trusted` hash) by
on your puppet master(s). Itll be on by default in Puppet 4.
In addition to using `$fact_name`, you can now use
`$facts[fact_name]` to get a fact value. The `$facts` hash is
protected and cant be overridden locally, so you wont need the `$::`
idiom when using this.
Our hope is that this will visibly distinguish facts from normal
variables, make Puppet code more readable, and eventually clean up
the global variable namespace. (Thatll take a while, though --- we
probably wont be able to disable `$fact_name` until, like, Puppet
5.)
Out of curiosity what is the reasoning behind making facts different
from normal variables? What is special about them compared to
top-level variables, hiera data or ENC variables? Whilst I think
having facts in their own protected namespace/hash is a long overdue
and very good idea, in my opinion having it scoped as a top-scope
hash
and referenced as $::facts[value] is not only more familiar to people
already using Puppet but is also a lot easier to understand than
making them "special" and referencing them as if they were locally
scoped - to me that makes the code less readable, rather than more.
Without being involved in the design of that, I'd venture that this is
backed by the same reason that PHP has recently removed
register_globals: avoid allowing lesser trusted parts of the system to
provide values in unexpected regions of the code.
Regards, David
--
You received this message because you are subscribed to the Google Groups "Puppet
Developers" 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-dev/21cc8fb5a7a4daf97c6369c1bb28827e%40hosting.edv-bus.at.
For more options, visit https://groups.google.com/d/optout.