Ask Your Question

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

asked 2015-11-20 07:10:19 -0600

phoenixx_ gravatar image

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-11-20 20:11:53 -0600

GregLarkin gravatar image

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?


Your code might look like:

$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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2015-11-20 07:10:19 -0600

Seen: 241 times

Last updated: Nov 20 '15