Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

fully-qualified variable fail with error '...is not a hash or array when accessing it with class_name'

Hello,

I have the following modules and hiera and failed with error '...is not a hash or array when accessing it with class_name' when using fully-qualified variable $foo::config::writer. If I use just $writer, it will be fine.

I think this is a scoping issue but I am not sure where is it, any thoughts?

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: foo::config::writer is not a hash or array when accessing it with class_name at /etc/puppet/environments/production/modules/foo/manifests/config.pp:10 on node example.com Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run

init.pp
     ----
    class foo {
      include foo::params


  case $foo::params::application {
    'bar': {
      foo::config { 'bar':
        query_array         => [
          $foo::metrics::default_metrics,
          $foo::metrics::bar_metrics],
      }
    }
    default: {
      foo::config { 'default':
        query_array => $foo::metrics::default_metrics,
        writer      => $foo::params::writer,
        interval    => '60',
      }
    }
  }
}

config.pp
---
define foo::config (
  $writer   = hiera_hash('foo::writer'),
  $interval = hiera('foo::interval', '120'),
  ) {
  include foo

  validate_hash($writer)

  $output = {
    class      => $foo::config::writer['class'],
    attributes => $foo::config::writer['attributes'],
  }
}

node.yaml
---
foo::queries: ''
foo::writer:
    class: 'class2'
    attributes:
      fileName: '/tmp/zoo'
      showTimeStamp: 'false'
foo::interval: '60'
click to hide/show revision 2
None

fully-qualified variable fail with error '...is not a hash or array when accessing it with class_name'

Hello,

I have the following modules and hiera and failed with error '...is not a hash or array when accessing it with class_name' when using fully-qualified variable $foo::config::writer. If I use just $writer, it will be fine.

I think this is a scoping issue but I am not sure where is it, any thoughts?

Error:

**Error: Could not retrieve catalog from remote server: Error 400 on SERVER: foo::config::writer is not a hash or array when accessing it with class_name at /etc/puppet/environments/production/modules/foo/manifests/config.pp:10 on node example.com Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run

run**

init.pp
     ----
    class foo {
      include foo::params


  case $foo::params::application {
    'bar': {
      foo::config { 'bar':
        query_array         => [
          $foo::metrics::default_metrics,
          $foo::metrics::bar_metrics],
      }
    }
    default: {
      foo::config { 'default':
        query_array => $foo::metrics::default_metrics,
        writer      => $foo::params::writer,
        interval    => '60',
      }
    }
  }
}

config.pp
---
define foo::config (
  $writer   = hiera_hash('foo::writer'),
  $interval = hiera('foo::interval', '120'),
  ) {
  include foo

  validate_hash($writer)

  $output = {
    class      => $foo::config::writer['class'],
    attributes => $foo::config::writer['attributes'],
  }
}

node.yaml
---
foo::queries: ''
foo::writer:
    class: 'class2'
    attributes:
      fileName: '/tmp/zoo'
      showTimeStamp: 'false'
foo::interval: '60'
click to hide/show revision 3
None

fully-qualified variable fail with error '...is not a hash or array when accessing it with class_name'

Hello,

I have the following modules and hiera and failed with error '...is not a hash or array when accessing it with class_name' when using fully-qualified variable $foo::config::writer. If I use just $writer, it will be fine.

I think this is a scoping issue but I am not sure where is it, any thoughts?

**Error: 

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: foo::config::writer is not a hash or array when accessing it with class_name at /etc/puppet/environments/production/modules/foo/manifests/config.pp:10 on node example.com Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run** run

init.pp
     ----
    class foo {
      include foo::params


  case $foo::params::application {
    'bar': {
      foo::config { 'bar':
        query_array         => [
          $foo::metrics::default_metrics,
          $foo::metrics::bar_metrics],
      }
    }
    default: {
      foo::config { 'default':
        query_array => $foo::metrics::default_metrics,
        writer      => $foo::params::writer,
        interval    => '60',
      }
    }
  }
}

config.pp
---
define foo::config (
  $writer   = hiera_hash('foo::writer'),
  $interval = hiera('foo::interval', '120'),
  ) {
  include foo

  validate_hash($writer)

  $output = {
    class      => $foo::config::writer['class'],
    attributes => $foo::config::writer['attributes'],
  }
}

node.yaml
---
foo::queries: ''
foo::writer:
    class: 'class2'
    attributes:
      fileName: '/tmp/zoo'
      showTimeStamp: 'false'
foo::interval: '60'