Hello all, I cannot seem to get Facter to always return a value. In this instance I am pulling the Java version from our systems, but would like there to be an entry that says "null" within the facts of systems that don't have any Java clients installed. Here is the basic facter that pulls the Java version, and it works as expected:
Facter.add("java_version") do confine :osfamily => "Debian" setcode do Facter::Util::Resolution.exec("java -version 2>&1 | grep Runtime | sed s/\[\\(\\)]//g | cut -d ' ' -f6") end end However, this returns nothing at all if no Java clients are installed. This fact is simply absent from those system's inventories. I have tried various if/else cases, such as this, just for testing purposes: Facter.add("java_version") do confine :osfamily => "Debian" setcode do if :osfamily == "Debian" Facter::Util::Resolution.exec("java -version 2>&1 | grep Runtime | sed s/\[\\(\\)]//g | cut -d ' ' -f6") else "null" end end end ... but this always resolves to "null", even when run on a platform that shows "osfamily => Debian". Does anone have some ideas on how to return the JAva client version when it is present, but to populate this fact with "null" if no client is present? -- 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 puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/d57a2885-1839-4bbc-a4a2-02cc4b1d5609%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.