Issue #17896 has been updated by Vaidas Jablonskis.
So after some time spent on debugging stuff, I finally figured what is going on.
The problem is, that when I use parameterized class, for instance:
class foo(
$conf = hiera_array('foo::conf', undef)
) {...}
Puppet does not actually call `hiera_array()`, it still calls hiera() as if I
have it like:
$conf = undef # or any other default value
The same happens with `hiera_hash()` - it just gets ignored and `hiera()` is
used to fetch value from hiera backend (YAML in my case).
I can use anything I like to "fetch" data from hiera backend, for example the
following is perfectly valid and no errors are seen. Puppet will just simply
ignore the right part after the "=" and use hiera() by default.
$conf = non_existing_function('foo::conf')
This definitely seems like a bug to me the way Puppet uses Hiera to fetch data.
Using `hiera_hash()` works very well if I use it within `create_resources()`
function, for instance:
create_resources(foo::defined_type, hiera_hash('foo::conf'))
I am not very good with Ruby, but I will try to figure out where the issue lies
in the code and I will update this thread.
----------------------------------------
Bug #17896: Hiera tool and hiera_array() returns different data
https://projects.puppetlabs.com/issues/17896#change-77961
Author: Vaidas Jablonskis
Status: Unreviewed
Priority: High
Assignee:
Category:
Target version: 3.0.x
Affected Puppet version: 3.0.1
Keywords: hiera, hiera_array, puppet
Branch:
Hi People,
I came across an issue where hiera command line tool returns a different data
to what puppet3.0 builtin hiera does.
When I say different data, I mean hiera tool returns an array of items
collected throughout the hierarchy, while hiera_array() called from within a
manifest returns an array of items from the very top level of hierarchy.
Here is my setup example:
YAML data files below:
# cat nodes/node1.example.local.yaml:
foo::conf:
- 'node_specific = foo'
- 'node_specific2 = foo2'
# cat common.yaml:
foo::conf:
- 'common = foo'
- 'common2 = foo2'
That's what I get by running hiera tool on the puppet master:
# hiera -c /etc/puppet/hiera.yaml -a foo::conf environment='development'
fqdn='node1.example.local'
["node_specific = foo", "node_specific2 = foo2", "common = foo", "common2 =
foo2"]
>From within the manifest, I use as a parameter:
$conf = hiera_array('foo::conf')
and then I have a template which creates a file on a node:
<% conf.each do |item| -%>
<%= item %>
<% end -%>
.. so what this template create is the following content of a file on node1:
node_specific = foo
node_specific2 = foo2
My hiera.yaml looks like this:
# cat /etc/puppet/hiera.yaml
---
:hierarchy:
- %{environment}/nodes/%{fqdn}
- %{environment}/roles/%{role}
- %{environment}/common
:backends:
- yaml
#- puppet
:yaml:
:datadir: '/etc/puppet/hieradata'
:puppet:
:datasource: 'data'
The node is in development environment.
To me it looks like a bug unless I am doing something fundamentally wrong?
Thanks,
Vaidas
--
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-bugs?hl=en.