1

I'm testing out hiera and hitting a snag on the hierarchy configuration. What I have is extremely simple, the part that isn't working is specification of hiera datadir files based on environment. Here's the config file (/etc/hiera.yaml) I'm trying

---
:backends:
  - yaml
:logger: console
:hierarchy:
  - "%{::environment}"

:yaml:
   :datadir: /var/lib/hiera

Now, I have a file /var/lib/hiera/development.yaml

blah: meh

When I run hiera it's not finding the file or the value

$ hiera -d blah
DEBUG: Fri Oct 25 15:50:52 -0600 2013: Hiera YAML backend starting
DEBUG: Fri Oct 25 15:50:52 -0600 2013: Looking up blah in YAML backend
nil

I've verified this agent is configured for development

$ sudo puppet agent --configprint environment
development

Now let me prove hiera is capable of finding something; a change to the hiera.yaml file:

:hierarchy:
  - development

And now hiera finds the file and the value

$ hiera -d blah
DEBUG: Fri Oct 25 15:53:25 -0600 2013: Hiera YAML backend starting
DEBUG: Fri Oct 25 15:53:25 -0600 2013: Looking up blah in YAML backend
DEBUG: Fri Oct 25 15:53:25 -0600 2013: Looking for data source development
DEBUG: Fri Oct 25 15:53:25 -0600 2013: Found blah in development
meh

So why isn't it working with the dynamic environment configuration? I got that straight from the documentation. Note, I have tried running the hiera command via sudo with no change in the result.

quickshiftin
  • 2,025
  • 5
  • 27
  • 41
  • Running the hiera command doesn't get the variables like $environment. It only gets them when it is called from puppet. So calling hiera -d blah isn't going give you much useful if your hiera configuration is purely based on variables supplied by puppet. – Zoredache Oct 25 '13 at 22:52
  • Thanks. How are you supposed to test then? – quickshiftin Oct 25 '13 at 23:16
  • @quickshiftin Test Hiera in the development environment on a puppet master - the Hiera data and evaluations are on the master and not the agent, so that's the only way to test how a realistic deployment will function. – Shane Madden Oct 25 '13 at 23:54

1 Answers1

1

There are multiple ways to feed hiera facts. Try hiera -d blah environment=development.

sciurus
  • 12,493
  • 2
  • 30
  • 49
  • Looks like I had to flip the order `hiera -d blah environment=development` per `Usage: hiera [options] key [default value] [variable='text'...]`, but that's what I was looking for! – quickshiftin Oct 26 '13 at 05:22