# ENC variable and facter fact with the same name. How do I differentiate the two (which are both top-scope variables)?

If I in my ENC have the variable "country" f.ex. which can be set manually (either exists or not). I also have an autoclassifying fact called "country". The ENC ovverides the fact on run, but both are top-scope variables. How can I in my code check whether or not the ENC is set or not? (I would also want to be able to diff the two values and see if they match or not)

edit retag close merge delete

Sort by » oldest newest most voted

I can't think of a way to do that in code because there's only one way to reference a top-scope variable (fact or otherwise), and that is $::country. Is there any reason you can't name the ENC variable $::country_override and then use the pick function from puppetlabs/stdlib to set the correct value?

$actual_country = pick($::country_override, \$::country)


That would be well-defined behavior. My sense is that whatever behavior you're observing now is not well-defined by the language and could act differently or break in a future release.

more