Am 17.06.2020 um 13:10 schrieb Helmut Schneider:

helmut@puppet:~$ sudo puppet lookup --node mynode roles
helmut@puppet:~$

Good because does not exist.

class common inherits config {
    include $classes
    if ($roles) {
      keys($roles).each |String $role| { <== line9
[...]

Error: Could not retrieve catalog from remote server: Error 500 on
SERVER: Server Error: Evaluation Error: Error while evaluating a
Function Call, 'keys' parameter 'hsh' expects a Hash value, got Array
(file: /etc/puppetlabs/code/modules/common/manifests/init.pp, line: 9,
column: 5) on node mynode

Why? $roles does not exists so why is keys($roles).each |String $role| {
executed?

I forgot:

  $roles = lookup({
    "name" => "roles",
    "merge" => {
      "strategy" => "deep",
      "knockout_prefix" => "--",
#      "sort_merged_arrays" => true,
    },
#    "default_value" => [],
    "default_value" => undef,
  })

I had "default_value" => [] active. Anyway, I thought that if ($variable) is an empty array it also results in 'false'. Can I check if an array has elements?

--
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/rccv9s%241ugk%241%40ciao.gmane.io.

Reply via email to