Ask Your Question

Hiera hash or array error

asked 2016-06-14 13:08:51 -0600

Gabor gravatar image

I developed an AWS S3 bakcup modul, but after the latest modify, puppet client not running (for run I using a following command: puppet agent --no-daemonize --debug --onetime).

My hiera.yaml:

  - yaml
  :datadir: /etc/puppet/hieradata
  - "%{hostname}"
  - "%{domain}"
  - common
:merge_behavior: deeper


  aws-region: "XYZ"
  aws-bucket-name: XYZ
  aws-access-key-id: "XYZ"
  aws-secret-acces-key: "XYZ"
  gpgkey: XYZ
  gpgpass: "XYZ"


    backuptype: database
    backuptypeselect: all
    backupdescription: ""


    include backupaws

    $awsbackupdetails = hiera('awsbackupdetails')

    class {
            aws_region           => $awsbackupdetails['aws-region'],
            aws_bucket_name      => $awsbackupdetails['aws-bucket-name'],
            aws_access_key_id    => $awsbackupdetails['aws-access-key-id'],
            aws_secret_acces_key => $awsbackupdetails['aws-secret-acces-key'];
            gpgkey  => $awsbackupdetails['gpgkey'],
            gpgpass => $awsbackupdetails['gpgpass'];

    $awss3backup = hiera('awss3backup')
    create_resources('backupaws::duply', $awss3backup)

/etc/puppet/modules/backupaws/manifests/duply.pp (detail):

$var = $awsbackupdetails['aws-bucket-name']

exec {
        refreshonly => true,
        cwd         => "/root/.duply/${hostname}-${name}/",
        command     => "aws s3 cp .backupdetails.txt s3://${var}/${$hostname}/${name}/backupdetails.txt",
        path        => '/usr/local/bin/';

I gave a following error in puppet client:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: awsbackupdetails is not a hash or array when accessing it with aws-bucket-name at /etc/puppet/modules/backupaws/manifests/duply.pp:30 on node

Any idea ?

Thank you!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2016-06-15 11:31:02 -0600

jon6000 gravatar image

updated 2016-06-16 03:47:26 -0600

Hi there,

It looks like you're assuming that the $awsbackupdetails var you set in server.pp will be available to your defined type, which isn't the case. A solution would be to explicity pass it as a param. create_resources has an optional third argument which allows you to pass in params, so you could do something like this in server.pp:

$defaults = {
  var => $awsbackupdetails,
create_resources('backupaws::duply', $awss3backup, $defaults)

Then get duply.pp to expect $var as a param:

define backupaws::duply($var) {
edit flag offensive delete link more


That's the danger of putting a define inside of your class, it looks like it should have 'local scope' for the variables, but that's not how it works in puppet.

DarylW gravatar imageDarylW ( 2016-06-15 20:07:32 -0600 )edit

answered 2016-06-16 00:36:00 -0600

Gabor gravatar image

Thanks for answer! This is a very interest, because one of the VMs wokring well this solution .... and I don't give this error.....

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-06-14 13:08:51 -0600

Seen: 161 times

Last updated: Jun 16 '16