The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

This issue tracker is now in read-only archive mode and automatic ticket export has been disabled. Redmine users will need to create a new JIRA account to file tickets using https://tickets.puppetlabs.com. See the following page for information on filing tickets with JIRA:

Feature #21211

Hiera crashes with an unfriendly error if it doesn't have permission to read a yaml file

Added by Joseph Mulloy almost 3 years ago. Updated over 2 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Charlie Sharpsteen% Done:

0%

Category:hiera
Target version:1.3.0
Keywords: Affected Hiera Version:1.2.1
Branch:https://github.com/puppetlabs/hiera/pull/151

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com


Description

I discovered this because I was trying to protect a yaml file with secrets by setting the mode to 600 on the file which is owned by root, but I forgot that the master runs as the puppet user. It was hard to figure out what was causing the problem because the error I got from puppet was “malformed format string – %S at /data/pre-prod/puppet/modules/common/puppet/manifests/params.pp:12” which is a line that sets a variable with a hiera call. I’m fine with Hiera failing when it’s unable to open a file but an error message indicating that it wasn’t able to open the file would be very helpful.

# sudo -u puppet hiera puppet::params::is_master environment=puppet_pre_prod           /usr/lib/ruby/site_ruby/1.8/hiera/filecache.rb:35:in `%': malformed format string - %S (ArgumentError)
        from /usr/lib/ruby/site_ruby/1.8/hiera/filecache.rb:35:in `read'
        from /usr/lib/ruby/site_ruby/1.8/hiera/backend/yaml_backend.rb:22:in `lookup'
        from /usr/lib/ruby/site_ruby/1.8/hiera/backend.rb:68:in `datasources'
        from /usr/lib/ruby/site_ruby/1.8/hiera/backend.rb:66:in `map'
        from /usr/lib/ruby/site_ruby/1.8/hiera/backend.rb:66:in `datasources'
        from /usr/lib/ruby/site_ruby/1.8/hiera/backend/yaml_backend.rb:16:in `lookup'
        from /usr/lib/ruby/site_ruby/1.8/hiera/backend.rb:182:in `lookup'
        from /usr/lib/ruby/site_ruby/1.8/hiera/backend.rb:179:in `each'
        from /usr/lib/ruby/site_ruby/1.8/hiera/backend.rb:179:in `lookup'
        from /usr/lib/ruby/site_ruby/1.8/hiera.rb:64:in `lookup'
        from /usr/bin/hiera:220

I’ve installed puppet and hiera from the official open source RPMs from https://yum.puppetlabs.com/ and I’m on RHEL 6.

Versions: Puppet: 3.2.1 Hiera 1.2.1


Related issues

Related to Puppet - Bug #19955: Misleading error when Hiera databindings fail Closed

History

#1 Updated by Pablo Wright almost 3 years ago

  • Category set to hiera
  • Status changed from Unreviewed to Needs Decision
  • Assignee set to eric sorenson
  • Affected Hiera Version set to 1.2.1

I was able to reproduce this in Puppet 3.2.2 and Hiera 1.2.1 in CentOS 6.4 with the official Puppetlabs yum repos. Not sure if this should be in the feature tracker, since as the reporter said, this would not imply a change in behavoir, only error message.

$ sudo -u puppet hiera "snmp::package" environment=production -d
DEBUG: Sat Jul 13 12:16:38 -0300 2013: Hiera YAML backend starting
DEBUG: Sat Jul 13 12:16:38 -0300 2013: Looking up snmp::package in YAML backend
DEBUG: Sat Jul 13 12:16:38 -0300 2013: Looking for data source defaults
/usr/lib/ruby/site_ruby/1.8/hiera/filecache.rb:35:in `%': malformed format string - %S (ArgumentError)
from /usr/lib/ruby/site_ruby/1.8/hiera/filecache.rb:35:in `read'
from /usr/lib/ruby/site_ruby/1.8/hiera/backend/yaml_backend.rb:22:in `lookup'
from /usr/lib/ruby/site_ruby/1.8/hiera/backend.rb:68:in `datasources'
from /usr/lib/ruby/site_ruby/1.8/hiera/backend.rb:66:in `map'
from /usr/lib/ruby/site_ruby/1.8/hiera/backend.rb:66:in `datasources'
from /usr/lib/ruby/site_ruby/1.8/hiera/backend/yaml_backend.rb:16:in `lookup'
from /usr/lib/ruby/site_ruby/1.8/hiera/backend.rb:182:in `lookup'
from /usr/lib/ruby/site_ruby/1.8/hiera/backend.rb:179:in `each'
from /usr/lib/ruby/site_ruby/1.8/hiera/backend.rb:179:in `lookup'
from /usr/lib/ruby/site_ruby/1.8/hiera.rb:64:in `lookup'
from /usr/bin/hiera:220

$ ls -l /etc/puppet/hieradata/defaults.yaml 
-rw------- 1 root root 202 Apr 17 13:27 /etc/puppet/hieradata/defaults.yaml

edit: prettified command line output.

#2 Updated by Charlie Sharpsteen almost 3 years ago

  • Tracker changed from Bug to Feature
  • Assignee changed from eric sorenson to Charlie Sharpsteen

#3 Updated by Charlie Sharpsteen almost 3 years ago

Also, possibly a duplicate of the situation described by #19955.

#4 Updated by Erik Dalén over 2 years ago

  • Status changed from Needs Decision to In Topic Branch Pending Review
  • Branch set to https://github.com/puppetlabs/hiera/pull/151

Improved the error message (also when the file is malformed)

#5 Updated by eric sorenson over 2 years ago

  • Status changed from In Topic Branch Pending Review to Merged - Pending Release
  • Target version set to 1.3.0

This will see the light of day in 1.3.0, going through release checklist now.

#6 Updated by Melissa Stone over 2 years ago

  • Status changed from Merged - Pending Release to Closed

Released in Hiera 1.3.0-rc2

Also available in: Atom PDF