[chef] Re: cookbook recipe template development and unit testing?


Chronological Thread 
  • From: Jesse Campbell < >
  • To:
  • Subject: [chef] Re: cookbook recipe template development and unit testing?
  • Date: Fri, 6 Jan 2012 18:16:15 -0500

No responses here, and there didn't appear to be any test framework in place, so I just wrote a simple ruby script that can be updated and tuned on a per-template basis...

I will likely eventually tune it a bit to parse a recipe file, rather than being hard-coded with recipe-specific context and template file name, but this works for me for now.
In case anyone else might find it useful, it can be found here, tuned for the sudoers.erb template:
https://gist.github.com/2f019bc4e34887f9aefd

-Jesse

On Fri, Jan 6, 2012 at 10:44, Jesse Campbell < "> > wrote:
Good day!
I've been searching about and can't find the answers I seek... web searches for cookbook recipe testing seem to be mostly, um, food-related :]

I'm in the process of replacing my home-brew templating system with chef server and recipes with templates.

In my system, I can just run "perl templater.pl <template_file> -- <custom template arguments>" and it will take in the custom args and feed them back to the template, spitting out the result of the template to stdout. It is great for testing small template file changes before pushing them out to the server.

How can I do this with chef? There is a defaults.rb for all of the default attribute values, which should be enough to generate a template... is there a way to say "chef-solo cookbooktest /path/to/mycookbook --outputdir /tmp" or something to that effect?

Thanks,
-Jesse Campbell




Archive powered by MHonArc 2.6.16.

§