{"id":3023,"date":"2013-12-09T20:38:34","date_gmt":"2013-12-09T19:38:34","guid":{"rendered":"http:\/\/www.devco.net\/?p=3023"},"modified":"2013-12-09T23:22:08","modified_gmt":"2013-12-09T22:22:08","slug":"the-problem-with-params-pp","status":"publish","type":"post","link":"https:\/\/www.devco.net\/archives\/2013\/12\/09\/the-problem-with-params-pp.php","title":{"rendered":"The problem with params.pp"},"content":{"rendered":"
My recent post about using Hiera data in modules has had a great level of discussion already, several thousand blog views, comments, tweets and private messages on IRC. Thanks for the support and encouragement – it’s clear this is a very important topic.<\/p>\n
I want to expand on yesterdays post by giving some background information on the underlying motivations that caused me to write this feature and why having it as a forge module is highly undesirable but the only current option.<\/p>\n
At the heart of this discussion is the params.pp<\/em> pattern and general problems with it. To recap, the basic idea is to embed all your default data into a file params.pp typically in huge case statements and then reference this data as default. Some examples of this are the puppetlabs-ntp module<\/a>, the Beginners Guide to Modules<\/a> and the example I had in the previous post that I’ll reproduce below:<\/p>\n <\/code><\/p>\n <\/code><\/p>\n Now today as Puppet stands this is pretty much the best we can hope for. This achieves a lot of useful things:<\/p>\n You can now stick this module on the forge and users can use it, it supports many Operating Systems and pretty much works on any Puppet going back quite a way. These are all good things.<\/p>\n The list above also demonstrates the main purpose for having data in a module – different OS\/environment support, allowing users to supply their own data, validation and to transmogrify the data. The params.pp pattern achieves all of this.<\/p>\n So what’s the problem then? <\/p>\n The problem is: the data is in the code. In the pre extlookup and Hiera days we put our site data in a case statements or inheritance trees or node data or any of number of different solutions. These all solved the basic problem – our site got configured and our boxes got built just like the params.pp pattern solves the basic problem. But we wanted more, we wanted our data separate from our code. Not only did it seem natural because almost every other known programming language supports and embrace this but as Puppet users we wanted a number of things:<\/p>\n I created Hiera with these items in mind after years of talking to probably 1000+ users and iterating on extlookup in order to keep pace with the Puppet language gaining support for modern constructs like Hashes. True it’s not a perfect solution to all these points – transparency of data origin to name but one – but there are approaches to make small improvements to achieve these and it does solve a high % of the above problems.<\/p>\n Over time Hiera has gained a tremendous following – it’s now the de facto standard to solving the problem of site configuration data largely because it’s pragmatic, simple and designed to suit the task at hand. In recognition of this I donated the code to Puppet Labs and to their credit they integrated it as a default prerequisite and created the data binding systems. The elephant in the room is our modules though.<\/p>\n We want to share our modules with other users. To do this we need to support many operating systems. To do this we need to create a lot of data in the modules. We can’t use Hiera to do this in a portable fashion because the module system needs improvement. So we’re stuck in the proverbial dark ages by embedding our data in code and gaining none of the advantages Hiera brings to site data.<\/p>\n Now we have a few options open to us. We can just suck it up and keep writing params.pp files gaining none of the above advantages that Hiera brings. This is not great and the puppetlabs-ntp module example I cited shows why. We can come up with ever more elaborate ways to wrap and extend and override the data provided in a params.pp or even far out ideas like having the data binding system query the params.pp data directly. In other words we can pander to the status quo, we can assume we cannot improve the system instead we have to iterate on an inherently bad idea. The alternative is to improve Puppet.<\/p>\n Every time the question of params.pp comes up the answer seems to be how to improve how we embed data in the code. This is absolutely the wrong answer<\/em>. The answer should be how do we improve Puppet so that we do not have to embed data in code. We know people want this, the popularity and wide adoption of Hiera has shown that they do. The core advantages of Hiera might not be well understood by all but the userbase do understand and treasure the gains they get from using it.<\/p>\n Our task is to support the community in the investment they made in Hiera. We should not be rewriting it in a non backwards compatible way throwing away past learnings simply because we do not want to understand how we got here. We should be iterating with small additions and rounding out this feature as one solid ever present data system that every user of Puppet can rely on being present on every Puppet system.<\/p>\n Hiera adoption has reached critical mass, it’s now the<\/em> solution to the problem. This is a great and historical moment for the Puppet Community, to rewrite it or throw it away or propose orthogonal solutions to this problem space is to do a great disservice to the community and the Puppet product as a whole.<\/p>\n Towards this I created a Hiera backend that goes a way to resolve this in a way thats a natural progression of the design of Hiera. It improves the core features provided by Puppet in a way that will allow better patterns than the current params.pp one to be created that will in the long run greatly improve the module writing and sharing experience. This is what my previous blog post introduce<\/a>, a way forward from the current params.pp situation.<\/p>\n Now by rights a solution to this problem belong in Puppet core. A Puppet Forge dependant module just to get this ability, especially one not maintained by Puppet Labs, especially one that monkey patches its way into the system is not desirable at all. This is why the code was a PR first. The only alternatives are to wait in the dark – numerous queries by many members of the community to the Puppet product owner has yielded only vague statements of intent or outcome. Or we can take it on our hands to improve the system. <\/p>\n So I hope the community will support me in using this module and work with me to come up with better patterns to replace the params.pp ones. Iterating on and improving the system as a whole rather than just suck up the status quo and not move forward.<\/p>\n","protected":false},"excerpt":{"rendered":" My recent post about using Hiera data in modules has had a great level of discussion already, several thousand blog views, comments, tweets and private messages on IRC. Thanks for the support and encouragement – it’s clear this is a very important topic. I want to expand on yesterdays post by giving some background information […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","footnotes":""},"categories":[7,1],"tags":[121,85,21],"_links":{"self":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/3023"}],"collection":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/comments?post=3023"}],"version-history":[{"count":27,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/3023\/revisions"}],"predecessor-version":[{"id":3051,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/posts\/3023\/revisions\/3051"}],"wp:attachment":[{"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/media?parent=3023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/categories?post=3023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devco.net\/wp-json\/wp\/v2\/tags?post=3023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}<\/p>\n
\r\n# ntp\/manifests\/init.pp\r\nclass ntp (\r\n # allow for overrides using resource syntax or data bindings\r\n $config = $ntp::params::config,\r\n $keys_file = $ntp::params::keys_file\r\n ) inherits ntp::params {\r\n\r\n # validate values supplied\r\n validate_absolute_path($config)\r\n validate_absolute_path($keys_file)\r\n\r\n # optionally derive new data from supplied data\r\n\r\n # use data\r\n file{$config:\r\n ....\r\n }\r\n}\r\n<\/pre>\n
<\/p>\n
\r\n# ntp\/manifests\/params.pp\r\nclass ntp::params {\r\n # set OS specific values\r\n case $::osfamily {\r\n 'AIX': {\r\n $config = \"\/etc\/ntp.conf\"\r\n $keys_file = '\/etc\/ntp.keys'\r\n }\r\n\r\n 'Debian': {\r\n $config = \"\/etc\/ntp.conf\"\r\n $keys_file = '\/etc\/ntp\/keys'\r\n }\r\n\r\n 'RedHat': {\r\n $config = \"\/etc\/ntp.conf\"\r\n $keys_file = '\/etc\/ntp\/keys'\r\n }\r\n\r\n default: {\r\n fail(\"The ${module_name} module is not supported on an ${::osfamily} based system.\")\r\n }\r\n }\r\n}\r\n<\/pre>\n
\n
\n