tohuwabohu / puppet-duplicity

Puppet module to manage backups based on duplicity.
Apache License 2.0
8 stars 33 forks source link

Error: empty(): Requires either array, hash or string to work with at profile.pp:112 #13

Closed TJM closed 7 years ago

TJM commented 9 years ago

I got the following error...

Error:

Error: empty(): Requires either array, hash or string to work with at /etc/puppet/modules/duplicity/manifests/profile.pp:112 on node app.dev

Puppet Code:

# Duplicity Profile to implement all the types
class site::profile::duplicity (
  $profiles = {},
  $public_keys = {},
  $private_keys = {},
  $files = {},

) {
  validate_hash($profiles)
  validate_hash($public_keys)
  validate_hash($private_keys)
  validate_hash($files)

  # Base Class
  # -- note set any settings in hiera
  include ::duplicity

  create_resources( '::duplicity::profile', $profiles)
  create_resources( '::duplicity::public_key', $public_keys)
  create_resources( '::duplicity::private_key', $private_keys)
  create_resources( '::duplicity::file', $files)

}

HieraData:

site::profile::duplicity::profiles:
  system:
    full_if_older_than: 7D
    max_full_backups: 4
    cron_hour: 1
    cron_minute: 0
    volsize: 100
    include_filelist:
      - /web
      - /etc
      - /opt
    exclude_filelist:
      - /var/log/lastlog
      - '**/tmp'
      - '**/cache'

Puppet Open Source v 3.8.1 ├── puppetlabs-stdlib (v4.9.0)

So... It would appear that empty() doesn't like integers?

For what its worth, it would be nice if the duplicity init did this so that I wouldn't have to implement this wrapper at all ;)

~tommy

TJM commented 9 years ago

It is fairly simple to workaround the issue by putting the values in "quote" in hieradata, but it should accept the integers directly. Perhaps a better way to handle this would be to make the default value "undef" then check to see if its defined? Puppet itself is fairly loose about converting strings to integers, but apparently not the other way around. Probably because in ruby 123.empty? is NoMethodError.

tohuwabohu commented 8 years ago

Sorry, somehow missed the issue. I remember seeing some issue with empty() and ints but don't remember if it was an issue in the stdlib or with Puppet 4. Will have a look at it.

tohuwabohu commented 8 years ago

I've released version 4.0.0 to the forge which fixes a very similar issue for Puppet 4. Can you try again, please?

tohuwabohu commented 7 years ago

Timeout, please reopen if this is still a problem.