Issue #16856 has been updated by Ryan Coleman.

I gave this a try by setting out to replace my netatalk module's params.pp 
pattern with the module_json hiera backend. If you're interested in seeing 
exactly what I did with my code, [this comparison on GitHub is 
useful](https://github.com/rcoleman/puppet-netatalk/compare/in_module_hiera_data).
 I was unable to use the pull request version of this code and resorted to the 
Ruby gem. 

The problem with the params.pp pattern is that it's an attempt to supply 
default data to your classes and falls over whenever someone wants to change 
data or provide their own for their site. They're forced to either run with a 
modified module or commit changes upstream, which may contain private data. The 
module_json hiera backend does serve as a reasonable replacement for the 
params.pp pattern. I suspect it'll be better at supplying site-specific data 
too. I'll continue to play with it and figure out what the options are.

* Error handling was abysmal when I mal-formed my JSON file. This example was 
caused when I had a trailing comma.
<pre>
[root@centos6 netatalk]# puppet apply -e 'include netatalk' --noop --debug
Info: Loading facts in /etc/puppet/modules/concat/lib/facter/concat_basedir.rb
Debug: importing '/etc/puppet/modules/netatalk/manifests/init.pp' in 
environment production
Debug: Automatically imported netatalk from netatalk into production
Debug: hiera(): Hiera Module JSON backend starting
Debug: hiera(): Looking up netatalk::package_name in Module JSON backend
Debug: hiera(): Reading config from 
/etc/puppet/modules/netatalk/data/hiera.json file
Debug: hiera(): Looking for data in source 
/etc/puppet/modules/netatalk/data/hiera.json
Debug: hiera(): Looking for data in source 
/etc/puppet/modules/netatalk/data/RedHat.json
Error: malformed format string - %S at line 1 on node centos6.puppetlabs.vm
Wrapped exception:
malformed format string - %S
Error: malformed format string - %S at line 1 on node centos6.puppetlabs.vm
</pre>

* I no longer have the following construct that lets me control a friendly 
error message when Puppet encounters an OS that doesn't have data supplied.
<pre>
default: {
  fail("The ${module_name} module only supports EL variants, Ubuntu and Debian. 
Check the modules documentation for details")
 }
</pre>


Andy, this solves a problem for my value stream -- allowing authors to supply 
data with their module and allowing the consumer to add-to or modify this data 
easily. There will always be room for improvement, but this is useful to me 
as-is and I'd like to see it merged in. 

In the mean-time, I'll continue to play with this and think of what it's doing 
and how it can be improved. 
----------------------------------------
Feature #16856: puppet should support data in modules
https://projects.puppetlabs.com/issues/16856#change-79150

Author: R.I. Pienaar
Status: Needs More Information
Priority: Normal
Assignee: R.I. Pienaar
Category: 
Target version: 
Affected Puppet version: 
Keywords: 
Branch: https://github.com/puppetlabs/puppet/pull/1217


At present there is a way to store data in modules using the puppet backend for 
hiera but it is optional and kind of broken.  The site hierarchy impacts how 
the puppet backend behaves which makes it impossible for module authors to 
supply data in their modules they can rely on

I propose a new hiera backend that loads a hierarchy of data from the 'data' 
directory in the module, this module must always be present in a puppet 
install.  This ability is key to the ability to create configurable forge 
modules that do not have hard coded values thanks to the puppet 3 hiera 
integration

reference the users list thread 
https://groups.google.com/d/topic/puppet-users/pvqzeyHkrY4/discussion


-- 
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.

Reply via email to