Ask Your Question
0

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 -0500

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
0

answered 2015-11-20 20:11:53 -0500

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?

See: https://forge.puppetlabs.com/puppetlabs/stdlib#pick

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

Stats

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

Seen: 157 times

Last updated: Nov 20 '15