Hello all,

I've recently experienced some inconsistencies around referencing Boolean 
values within a puppet manifest.  We've written some custom Boolean facts 
and we look to the true/false values within our manifests to help make 
decisions on what should or shouldn't be done.

The issue I have is the different behavior I see when referencing the fact 
value.  For instance, in some cases I have to reference the Boolean value 
with quotes (ie.. 'true') in order to get things working right.  In other 
cases, removing the quotes returns the results I would expect.

I understand that this is most likely due to what the fact is returning but 
I was wondering if there's a 'best practice' for approaching something like 
this.  I've also played around with stringify_facts and achieved varied 
results (in terms of referencing the Boolean values) and that may have only 
confused me.  

We're currently running: Puppet v:3.8.6/Hiera v:1.3.4

I realize this question touches on a few different things but does anybody 
have a brief explanation for how I might consistently reference these 
Boolean values throughout our puppet infrastructure?  

Here's an example of a custom fact that we use:

require 'facter'

Facter.add(:nvidia_installed) do
  setcode do
    tools_test = Facter::Util::Resolution.exec("/usr/bin/nvidia-smi")
    if tools_test
      nvidia_installed = true
    else
      nvidia_installed = false
    end
  end
end

In order to reference this particular value within my manifest, I have to 
reference the value without quotes:   elsif ($::class == 
'render_workstation') and ($::nvidia_installed == false) {

As always, thank you in advance for the help and support.

Cheers,

Mike


-- 
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/24c74385-59e2-4610-8915-0ead4ac52e72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to