ghoneycutt / puppet-module-ssh

Puppet module to manage SSH
Other
34 stars 184 forks source link

case type($variable) never evaluated as string or boolean #329

Closed bjarnirafn closed 1 year ago

bjarnirafn commented 4 years ago

I'm using Foreman (if that's relevant) trying to set up ssh on Ubuntu 18.04. I set hiera_merge as string with value false (I've also tried setting it as boolean with value false).

No matter what I do I always get the error: "Error while evaluating a Function Call, ssh::hiera_merge type must be true or false."

Somehow the "case type($hiera_merge)" is never evaluated as string or boolean, it always goes to the default case.

The yaml generated by Foreman is below.

parameters: ... foreman_env: production classes: ssh: hiera_merge: false environment: production

hirnschmalz commented 4 years ago

Hi @bjarnirafn ,

I had the same problem. It looks like the comparision value is invalid (at least in Puppet 6.11). It works with the following code

  case type($hiera_merge) {
    Type[String]: {
      validate_re($hiera_merge, '^(true|false)$', "ssh::hiera_merge may be either 'true' or 'false' and is set to <${hiera_merge}>.")
      $hiera_merge_real = str2bool($hiera_merge)
    }   
    Type[Boolean]: {
      $hiera_merge_real = $hiera_merge
    }   
    default: {
      fail("ssh::hiera_merge type must be true or false. Set to <type(${hiera_merge})>")
    }   
  }
Phil-Friderici commented 1 year ago

Sorry, hiera_merge functionality was removed in v4. You'll need to configure your merge strategy in hiera directly. Check https://www.puppet.com/docs/puppet/5.5/configure_merge_behavior_hiera.html and https://www.puppet.com/docs/puppet/7/hiera_automatic.html for more information.