pcfens/puppet-filebeat

Instanciating default fact to false is not necessarily a good idea

Opened this issue · 0 comments

filebeat_version.nil? ? false : %r{^filebeat version ([^\s]+)?}.match(filebeat_version)[1]

Hi,

We expect to have a string to keep consistency on the data instead of a boolean when no filebeat binary is detected.
We parse lots of puppet fact data, and this is a type exception, for a node we have a string version, and for another a false bool.

It seems to be used in code, it should be better to have a real boolean fact to check if filebeat exist

manifests/input.pp:58:  if 'filebeat_version' in $facts and $facts['filebeat_version'] != false {
manifests/input.pp:59:    $skip_validation = versioncmp($facts['filebeat_version'], $filebeat::major_version) ? {
manifests/input.pp:113:        default => $facts['filebeat_version'] ? {
manifests/config.pp:87:  if 'filebeat_version' in $facts and $facts['filebeat_version'] != false {
manifests/config.pp:88:    $skip_validation = versioncmp($facts['filebeat_version'], $filebeat::major_version) ? {