Hi,

I would like to be able to influence which files hiera reads from with
in hiera. Here is a minimal test:

$ cat hiera.yaml
---
:backends:
  - yaml
:yaml:
  :datadir: "/home/e13itfe/hieratest/yaml/"
:logger: console
:hierarchy:
  - "0_harddefaults"
  - "6_%{::redir}"
  - "9_softdefaults"
$ head -n-0 yaml/*
==> yaml/0_harddefaults.yaml <==

---

redir: in-harddef
::redir: in-harddef-with-colons


==> yaml/6_redir.yaml <==
---
foo: file-redir

==> yaml/9_softdefaults.yaml <==

---
foo: file-softdef

redir: in-softdef
::redir: in-softdef-with-colons

I would like the redir variables that are set in 0_harddefaults.yaml
and in 9_softdefaults.yaml to influence the name of the 6_%{::redir}
file that is in hiera.yaml.

But according to my tests, this does of course not work:

$ hiera --debug --config hiera.yaml foo ::redir=redir
DEBUG: 2016-09-07 13:02:56 +0200: Hiera YAML backend starting
DEBUG: 2016-09-07 13:02:56 +0200: Looking up foo in YAML backend
DEBUG: 2016-09-07 13:02:56 +0200: Looking for data source 0_harddefaults
DEBUG: 2016-09-07 13:02:56 +0200: Looking for data source 6_redir
DEBUG: 2016-09-07 13:02:56 +0200: Found foo in 6_redir
file-redir
$ hiera --debug --config hiera.yaml foo
DEBUG: 2016-09-07 13:02:59 +0200: Hiera YAML backend starting
DEBUG: 2016-09-07 13:02:59 +0200: Looking up foo in YAML backend
DEBUG: 2016-09-07 13:02:59 +0200: Looking for data source 0_harddefaults
DEBUG: 2016-09-07 13:02:59 +0200: Looking for data source 6_
DEBUG: 2016-09-07 13:02:59 +0200: Cannot find datafile 
/home/e13itfe/hieratest/yaml/6_.yaml, skipping
DEBUG: 2016-09-07 13:02:59 +0200: Looking for data source 9_softdefaults
DEBUG: 2016-09-07 13:02:59 +0200: Found foo in 9_softdefaults
file-softdef
$

That means that I can influence the file names that hiera reads from
the command line and probably later in puppet with external variables,
but not from the hiera code itself: The second that hiera starts
reading in the files from the datadir, the list of actual files to be
read is already made and the file names fully expanded.

This sounds logical, but am I reasoning correctly?

Assuming that I am right, is there a way to achieve a similar result?

Assuming that I am wrong, why does it not work?

Any hints will be appreciated.

Greetings
Marc


-- 
-----------------------------------------------------------------------------
Marc Haber         | "I don't trust Computers. They | Mailadresse im Header
Leimen, Germany    |  lose things."    Winona Ryder | Fon: *49 6224 1600402
Nordisch by Nature |  How to make an American Quilt | Fax: *49 6224 1600421

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/20160907115050.GE10115%40torres.zugschlus.de.
For more options, visit https://groups.google.com/d/optout.

Reply via email to