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:

Bug #21669

Hiera.yaml will not interpolate variables if datadir is specified as an array

Added by Nick Walker almost 3 years ago. Updated over 2 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Franz Pletz% Done:

0%

Category:hiera
Target version:1.3.0
Keywords:Customer Affected Hiera Version:1.1.2
Branch:https://github.com/puppetlabs/hiera/pull/147

We've Moved!

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


Description

I created the following hiera.yaml file.

---
:backends:
  - yaml
:hierarchy:
  - one
  - global

:yaml:
  :datadir: 
    - "/etc/puppetlabs/%{::environment}/hiera"

I ran

hiera mykey ::environment=production --debug
DEBUG: Tue Jul 09 10:46:55 -0700 2013: Hiera YAML backend starting
DEBUG: Tue Jul 09 10:46:55 -0700 2013: Looking up mykey in YAML backend
DEBUG: Tue Jul 09 10:46:55 -0700 2013: Looking for data source one
DEBUG: Tue Jul 09 10:46:55 -0700 2013: Cannot find datafile /etc/puppetlabs/%{::environment}/hiera/one.yaml, skipping
DEBUG: Tue Jul 09 10:46:55 -0700 2013: Looking for data source global
DEBUG: Tue Jul 09 10:46:55 -0700 2013: Cannot find datafile /etc/puppetlabs/%{::environment}/hiera/global.yaml, skipping
nil

So I hardcoded the value that I wanted…

---
:backends:
  - yaml
:hierarchy:
  - one
  - global

:yaml:
  :datadir: 
    - "/etc/puppetlabs/production/hiera"

Now hiera finds my value.

Hiera should either:

  • Fail when datadir is specified as an array and give a clear error message.

  • Interpolate variables with datadir is specified as an array


Related issues

Related to Hiera - Feature #11784: Hiera should support alternate environments Needs More Information 01/05/2012

History

#1 Updated by Charlie Sharpsteen almost 3 years ago

  • Assignee set to Charlie Sharpsteen

#3 Updated by Franz Pletz almost 3 years ago

  • Category set to hiera
  • Status changed from Unreviewed to Needs Decision

In my opinion, Hiera should warn about using an array as datadir. There was a question on the mailing lists about it here https://groups.google.com/forum/#!topic/puppet-users/Gj32AXNgJ0w which could potentially confuse user because it’s one of the first results on Google when searching for “hiera datadir”.

It should not fix it because it’s semantically wrong as Hiera doesn’t (and won’t?) support multiple datadirs.

Should I continue and add a warning if the datadir of a backend is not a string?

#4 Updated by eric sorenson almost 3 years ago

  • Status changed from Needs Decision to Accepted
  • Assignee changed from Charlie Sharpsteen to Franz Pletz

Yes that’s right Franz — this silently failed in a weird way because datadir only accepts an array.

The original poster’s request for variable interpolation in datadir does actually work if datadir is a string, see #11784.

#5 Updated by Anonymous over 2 years ago

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

#6 Updated by Anonymous over 2 years ago

  • Status changed from In Topic Branch Pending Review to Merged - Pending Release

#7 Updated by Nick Walker over 2 years ago

So to clarify the new behavior. If someone specifies the datadir as an array it will now fail outright and tell the user they need to specify datadir as a string. Is that correct?

#8 Updated by Melissa Stone over 2 years ago

  • Target version set to 1.3.0

#9 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