Dirtree Puppet Module Released!

Tue May 14 2013 08:49:31 GMT-0400 (EDT)

My second Puppet module has just been released on the Forge. It's called dirtree and you can download it from the Puppet Forge project page or check out the source code in the repo on GitHub.

The reason I created this module was so I could ensure an entire directory path was created by puppet. For example, if I wanted to create the folder /opt/foobar/fizzbuzz, I'd have to use the following Puppet manifest:

file { ['/opt', '/opt/foobar', '/opt/foobar/fizzbuzz']:
  ensure => present,

If any of those directories were declared in another manifest, it would throw an error about the conflict. With the dirtree module I can ensure the entire tree is created like so:

$dirtree = dirtree('/opt/foobar/fizzbuzz')
ensure_resource('file', $dirtree, {'ensure' => 'present'})

As of the 4.1.0 release of puppetlabs-stdlib, ensure_resource accepts an array of resources and will check to see if they already exist and create them if they don't. This will be a really great improvement for the DRYness of manifests that have to create directory structures.

Feel free to fork the repo on GitHub and contribute back to the project!