Issue #19188 has been updated by Peter Meier.

So you would like to have something like a global default? Or did you still 
think of a global default per key?

1. Why don't you define a default yourself directly in the code? Like:

<pre>
$a=hiera('a','a')
$b=hiera('b','b')
</pre>

2. What speaks against a solution where you define all these defaults in your 
lowest hierarchy level? That you might not be able to control it? -> Maybe add 
a third level, that you can control. Can't be another yaml hierarchy, but could 
be a json one.
----------------------------------------
Feature #19188: configurable behavior with non-existing hiera variables
https://projects.puppetlabs.com/issues/19188#change-83117

Author: micah -
Status: Unreviewed
Priority: Normal
Assignee: 
Category: 
Target version: 
Affected Puppet version: 
Keywords: hiera
Branch: 


puppet-hiera will fail if it wants to read a variable and can't find it.

It would be nice if you could configure the behaviour in hiera.yaml for how 
hiera would deal with non-existent variables.

For example:

<pre>
--- dev/puppet » cat manifests/hiera_test2.pp 
$a=hiera('a')
$b=hiera('b')
notice($a)
notice($b)

--- dev/puppet » cat /home/varac/.puppet/hiera.yaml     
---
:backends:
  - yaml
  - puppet

:logger: console

:yaml:
   :datadir: /home/varac/.puppet 

:hierarchy:
  - hiera_test

:puppet:
   :datasource: data

--- dev/puppet » cat /home/varac/.puppet/hiera_test.yaml 
---
a: a
b: b

--- dev/puppet » puppet apply -v manifests/hiera_test2.pp
notice: Scope(Class[main]): a
notice: Scope(Class[main]): b
info: Applying configuration version '1360597894'
notice: Finished catalog run in 0.07 seconds

--- dev/puppet » vi /home/varac/.puppet/hiera_test.yaml # remove variable b

--- dev/puppet » puppet apply -v manifests/hiera_test2.pp
Could not find data item b in any Hiera data file and no default supplied at 
/home/varac/dev/Projects/Puppet/dev/puppet/manifests/hiera_test2.pp:2 on node 
rocinante.bitrigger.de

</pre>


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to